LLVM  10.0.0
SelectionDAGBuilder.h
Go to the documentation of this file.
1 //===- SelectionDAGBuilder.h - Selection-DAG building -----------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This implements routines for translating from LLVM IR into SelectionDAG IR.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_CODEGEN_SELECTIONDAG_SELECTIONDAGBUILDER_H
14 #define LLVM_LIB_CODEGEN_SELECTIONDAG_SELECTIONDAGBUILDER_H
15 
16 #include "StatepointLowering.h"
17 #include "llvm/ADT/APInt.h"
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/DenseMap.h"
20 #include "llvm/ADT/MapVector.h"
21 #include "llvm/ADT/SmallVector.h"
29 #include "llvm/IR/CallSite.h"
30 #include "llvm/IR/DebugLoc.h"
31 #include "llvm/IR/Instruction.h"
32 #include "llvm/IR/Statepoint.h"
34 #include "llvm/Support/CodeGen.h"
37 #include <algorithm>
38 #include <cassert>
39 #include <cstdint>
40 #include <utility>
41 #include <vector>
42 
43 namespace llvm {
44 
45 class AllocaInst;
46 class AtomicCmpXchgInst;
47 class AtomicRMWInst;
48 class BasicBlock;
49 class BranchInst;
50 class CallInst;
51 class CallBrInst;
52 class CatchPadInst;
53 class CatchReturnInst;
54 class CatchSwitchInst;
55 class CleanupPadInst;
56 class CleanupReturnInst;
57 class Constant;
58 class ConstantInt;
59 class ConstrainedFPIntrinsic;
60 class DbgValueInst;
61 class DataLayout;
62 class DIExpression;
63 class DILocalVariable;
64 class DILocation;
65 class FenceInst;
66 class FunctionLoweringInfo;
67 class GCFunctionInfo;
68 class GCRelocateInst;
69 class GCResultInst;
70 class IndirectBrInst;
71 class InvokeInst;
72 class LandingPadInst;
73 class LLVMContext;
74 class LoadInst;
75 class MachineBasicBlock;
76 class PHINode;
77 class ResumeInst;
78 class ReturnInst;
79 class SDDbgValue;
80 class StoreInst;
81 class SwiftErrorValueTracking;
82 class SwitchInst;
83 class TargetLibraryInfo;
84 class TargetMachine;
85 class Type;
86 class VAArgInst;
87 class UnreachableInst;
88 class Use;
89 class User;
90 class Value;
91 
92 //===----------------------------------------------------------------------===//
93 /// SelectionDAGBuilder - This is the common target-independent lowering
94 /// implementation that is parameterized by a TargetLowering object.
95 ///
97  /// The current instruction being visited.
98  const Instruction *CurInst = nullptr;
99 
101 
102  /// Maps argument value for unused arguments. This is used
103  /// to preserve debug information for incoming arguments.
104  DenseMap<const Value*, SDValue> UnusedArgNodeMap;
105 
106  /// Helper type for DanglingDebugInfoMap.
107  class DanglingDebugInfo {
108  const DbgValueInst* DI = nullptr;
109  DebugLoc dl;
110  unsigned SDNodeOrder = 0;
111 
112  public:
113  DanglingDebugInfo() = default;
114  DanglingDebugInfo(const DbgValueInst *di, DebugLoc DL, unsigned SDNO)
115  : DI(di), dl(std::move(DL)), SDNodeOrder(SDNO) {}
116 
117  const DbgValueInst* getDI() { return DI; }
118  DebugLoc getdl() { return dl; }
119  unsigned getSDNodeOrder() { return SDNodeOrder; }
120  };
121 
122  /// Helper type for DanglingDebugInfoMap.
123  typedef std::vector<DanglingDebugInfo> DanglingDebugInfoVector;
124 
125  /// Keeps track of dbg_values for which we have not yet seen the referent.
126  /// We defer handling these until we do see it.
128 
129 public:
130  /// Loads are not emitted to the program immediately. We bunch them up and
131  /// then emit token factor nodes when possible. This allows us to get simple
132  /// disambiguation between loads without worrying about alias analysis.
134 
135  /// State used while lowering a statepoint sequence (gc_statepoint,
136  /// gc_relocate, and gc_result). See StatepointLowering.hpp/cpp for details.
138 
139 private:
140  /// CopyToReg nodes that copy values to virtual registers for export to other
141  /// blocks need to be emitted before any terminator instruction, but they have
142  /// no other ordering requirements. We bunch them up and the emit a single
143  /// tokenfactor for them just before terminator instructions.
144  SmallVector<SDValue, 8> PendingExports;
145 
146  /// Similar to loads, nodes corresponding to constrained FP intrinsics are
147  /// bunched up and emitted when necessary. These can be moved across each
148  /// other and any (normal) memory operation (load or store), but not across
149  /// calls or instructions having unspecified side effects. As a special
150  /// case, constrained FP intrinsics using fpexcept.strict may not be deleted
151  /// even if otherwise unused, so they need to be chained before any
152  /// terminator instruction (like PendingExports). We track the latter
153  /// set of nodes in a separate list.
154  SmallVector<SDValue, 8> PendingConstrainedFP;
155  SmallVector<SDValue, 8> PendingConstrainedFPStrict;
156 
157  /// Update root to include all chains from the Pending list.
158  SDValue updateRoot(SmallVectorImpl<SDValue> &Pending);
159 
160  /// A unique monotonically increasing number used to order the SDNodes we
161  /// create.
162  unsigned SDNodeOrder;
163 
164  /// Determine the rank by weight of CC in [First,Last]. If CC has more weight
165  /// than each cluster in the range, its rank is 0.
166  unsigned caseClusterRank(const SwitchCG::CaseCluster &CC,
169 
170  /// Emit comparison and split W into two subtrees.
171  void splitWorkItem(SwitchCG::SwitchWorkList &WorkList,
172  const SwitchCG::SwitchWorkListItem &W, Value *Cond,
173  MachineBasicBlock *SwitchMBB);
174 
175  /// Lower W.
176  void lowerWorkItem(SwitchCG::SwitchWorkListItem W, Value *Cond,
177  MachineBasicBlock *SwitchMBB,
178  MachineBasicBlock *DefaultMBB);
179 
180  /// Peel the top probability case if it exceeds the threshold
182  peelDominantCaseCluster(const SwitchInst &SI,
183  SwitchCG::CaseClusterVector &Clusters,
184  BranchProbability &PeeledCaseProb);
185 
186  /// A class which encapsulates all of the information needed to generate a
187  /// stack protector check and signals to isel via its state being initialized
188  /// that a stack protector needs to be generated.
189  ///
190  /// *NOTE* The following is a high level documentation of SelectionDAG Stack
191  /// Protector Generation. The reason that it is placed here is for a lack of
192  /// other good places to stick it.
193  ///
194  /// High Level Overview of SelectionDAG Stack Protector Generation:
195  ///
196  /// Previously, generation of stack protectors was done exclusively in the
197  /// pre-SelectionDAG Codegen LLVM IR Pass "Stack Protector". This necessitated
198  /// splitting basic blocks at the IR level to create the success/failure basic
199  /// blocks in the tail of the basic block in question. As a result of this,
200  /// calls that would have qualified for the sibling call optimization were no
201  /// longer eligible for optimization since said calls were no longer right in
202  /// the "tail position" (i.e. the immediate predecessor of a ReturnInst
203  /// instruction).
204  ///
205  /// Then it was noticed that since the sibling call optimization causes the
206  /// callee to reuse the caller's stack, if we could delay the generation of
207  /// the stack protector check until later in CodeGen after the sibling call
208  /// decision was made, we get both the tail call optimization and the stack
209  /// protector check!
210  ///
211  /// A few goals in solving this problem were:
212  ///
213  /// 1. Preserve the architecture independence of stack protector generation.
214  ///
215  /// 2. Preserve the normal IR level stack protector check for platforms like
216  /// OpenBSD for which we support platform-specific stack protector
217  /// generation.
218  ///
219  /// The main problem that guided the present solution is that one can not
220  /// solve this problem in an architecture independent manner at the IR level
221  /// only. This is because:
222  ///
223  /// 1. The decision on whether or not to perform a sibling call on certain
224  /// platforms (for instance i386) requires lower level information
225  /// related to available registers that can not be known at the IR level.
226  ///
227  /// 2. Even if the previous point were not true, the decision on whether to
228  /// perform a tail call is done in LowerCallTo in SelectionDAG which
229  /// occurs after the Stack Protector Pass. As a result, one would need to
230  /// put the relevant callinst into the stack protector check success
231  /// basic block (where the return inst is placed) and then move it back
232  /// later at SelectionDAG/MI time before the stack protector check if the
233  /// tail call optimization failed. The MI level option was nixed
234  /// immediately since it would require platform-specific pattern
235  /// matching. The SelectionDAG level option was nixed because
236  /// SelectionDAG only processes one IR level basic block at a time
237  /// implying one could not create a DAG Combine to move the callinst.
238  ///
239  /// To get around this problem a few things were realized:
240  ///
241  /// 1. While one can not handle multiple IR level basic blocks at the
242  /// SelectionDAG Level, one can generate multiple machine basic blocks
243  /// for one IR level basic block. This is how we handle bit tests and
244  /// switches.
245  ///
246  /// 2. At the MI level, tail calls are represented via a special return
247  /// MIInst called "tcreturn". Thus if we know the basic block in which we
248  /// wish to insert the stack protector check, we get the correct behavior
249  /// by always inserting the stack protector check right before the return
250  /// statement. This is a "magical transformation" since no matter where
251  /// the stack protector check intrinsic is, we always insert the stack
252  /// protector check code at the end of the BB.
253  ///
254  /// Given the aforementioned constraints, the following solution was devised:
255  ///
256  /// 1. On platforms that do not support SelectionDAG stack protector check
257  /// generation, allow for the normal IR level stack protector check
258  /// generation to continue.
259  ///
260  /// 2. On platforms that do support SelectionDAG stack protector check
261  /// generation:
262  ///
263  /// a. Use the IR level stack protector pass to decide if a stack
264  /// protector is required/which BB we insert the stack protector check
265  /// in by reusing the logic already therein. If we wish to generate a
266  /// stack protector check in a basic block, we place a special IR
267  /// intrinsic called llvm.stackprotectorcheck right before the BB's
268  /// returninst or if there is a callinst that could potentially be
269  /// sibling call optimized, before the call inst.
270  ///
271  /// b. Then when a BB with said intrinsic is processed, we codegen the BB
272  /// normally via SelectBasicBlock. In said process, when we visit the
273  /// stack protector check, we do not actually emit anything into the
274  /// BB. Instead, we just initialize the stack protector descriptor
275  /// class (which involves stashing information/creating the success
276  /// mbbb and the failure mbb if we have not created one for this
277  /// function yet) and export the guard variable that we are going to
278  /// compare.
279  ///
280  /// c. After we finish selecting the basic block, in FinishBasicBlock if
281  /// the StackProtectorDescriptor attached to the SelectionDAGBuilder is
282  /// initialized, we produce the validation code with one of these
283  /// techniques:
284  /// 1) with a call to a guard check function
285  /// 2) with inlined instrumentation
286  ///
287  /// 1) We insert a call to the check function before the terminator.
288  ///
289  /// 2) We first find a splice point in the parent basic block
290  /// before the terminator and then splice the terminator of said basic
291  /// block into the success basic block. Then we code-gen a new tail for
292  /// the parent basic block consisting of the two loads, the comparison,
293  /// and finally two branches to the success/failure basic blocks. We
294  /// conclude by code-gening the failure basic block if we have not
295  /// code-gened it already (all stack protector checks we generate in
296  /// the same function, use the same failure basic block).
297  class StackProtectorDescriptor {
298  public:
299  StackProtectorDescriptor() = default;
300 
301  /// Returns true if all fields of the stack protector descriptor are
302  /// initialized implying that we should/are ready to emit a stack protector.
303  bool shouldEmitStackProtector() const {
304  return ParentMBB && SuccessMBB && FailureMBB;
305  }
306 
307  bool shouldEmitFunctionBasedCheckStackProtector() const {
308  return ParentMBB && !SuccessMBB && !FailureMBB;
309  }
310 
311  /// Initialize the stack protector descriptor structure for a new basic
312  /// block.
313  void initialize(const BasicBlock *BB, MachineBasicBlock *MBB,
314  bool FunctionBasedInstrumentation) {
315  // Make sure we are not initialized yet.
316  assert(!shouldEmitStackProtector() && "Stack Protector Descriptor is "
317  "already initialized!");
318  ParentMBB = MBB;
319  if (!FunctionBasedInstrumentation) {
320  SuccessMBB = AddSuccessorMBB(BB, MBB, /* IsLikely */ true);
321  FailureMBB = AddSuccessorMBB(BB, MBB, /* IsLikely */ false, FailureMBB);
322  }
323  }
324 
325  /// Reset state that changes when we handle different basic blocks.
326  ///
327  /// This currently includes:
328  ///
329  /// 1. The specific basic block we are generating a
330  /// stack protector for (ParentMBB).
331  ///
332  /// 2. The successor machine basic block that will contain the tail of
333  /// parent mbb after we create the stack protector check (SuccessMBB). This
334  /// BB is visited only on stack protector check success.
335  void resetPerBBState() {
336  ParentMBB = nullptr;
337  SuccessMBB = nullptr;
338  }
339 
340  /// Reset state that only changes when we switch functions.
341  ///
342  /// This currently includes:
343  ///
344  /// 1. FailureMBB since we reuse the failure code path for all stack
345  /// protector checks created in an individual function.
346  ///
347  /// 2.The guard variable since the guard variable we are checking against is
348  /// always the same.
349  void resetPerFunctionState() {
350  FailureMBB = nullptr;
351  }
352 
353  MachineBasicBlock *getParentMBB() { return ParentMBB; }
354  MachineBasicBlock *getSuccessMBB() { return SuccessMBB; }
355  MachineBasicBlock *getFailureMBB() { return FailureMBB; }
356 
357  private:
358  /// The basic block for which we are generating the stack protector.
359  ///
360  /// As a result of stack protector generation, we will splice the
361  /// terminators of this basic block into the successor mbb SuccessMBB and
362  /// replace it with a compare/branch to the successor mbbs
363  /// SuccessMBB/FailureMBB depending on whether or not the stack protector
364  /// was violated.
365  MachineBasicBlock *ParentMBB = nullptr;
366 
367  /// A basic block visited on stack protector check success that contains the
368  /// terminators of ParentMBB.
369  MachineBasicBlock *SuccessMBB = nullptr;
370 
371  /// This basic block visited on stack protector check failure that will
372  /// contain a call to __stack_chk_fail().
373  MachineBasicBlock *FailureMBB = nullptr;
374 
375  /// Add a successor machine basic block to ParentMBB. If the successor mbb
376  /// has not been created yet (i.e. if SuccMBB = 0), then the machine basic
377  /// block will be created. Assign a large weight if IsLikely is true.
378  MachineBasicBlock *AddSuccessorMBB(const BasicBlock *BB,
379  MachineBasicBlock *ParentMBB,
380  bool IsLikely,
381  MachineBasicBlock *SuccMBB = nullptr);
382  };
383 
384 private:
385  const TargetMachine &TM;
386 
387 public:
388  /// Lowest valid SDNodeOrder. The special case 0 is reserved for scheduling
389  /// nodes without a corresponding SDNode.
390  static const unsigned LowestSDNodeOrder = 1;
391 
393  const DataLayout *DL = nullptr;
394  AliasAnalysis *AA = nullptr;
396 
398  public:
400  : SwitchCG::SwitchLowering(funcinfo), SDB(sdb) {}
401 
402  virtual void addSuccessorWithProb(
405  SDB->addSuccessorWithProb(Src, Dst, Prob);
406  }
407 
408  private:
409  SelectionDAGBuilder *SDB;
410  };
411 
412  std::unique_ptr<SDAGSwitchLowering> SL;
413 
414  /// A StackProtectorDescriptor structure used to communicate stack protector
415  /// information in between SelectBasicBlock and FinishBasicBlock.
416  StackProtectorDescriptor SPDescriptor;
417 
418  // Emit PHI-node-operand constants only once even if used by multiple
419  // PHI nodes.
421 
422  /// Information about the function as a whole.
424 
425  /// Information about the swifterror values used throughout the function.
427 
428  /// Garbage collection metadata for the function.
430 
431  /// Map a landing pad to the call site indexes.
433 
434  /// This is set to true if a call in the current block has been translated as
435  /// a tail call. In this case, no subsequent DAG nodes should be created.
436  bool HasTailCall = false;
437 
439 
442  : SDNodeOrder(LowestSDNodeOrder), TM(dag.getTarget()), DAG(dag),
443  SL(std::make_unique<SDAGSwitchLowering>(this, funcinfo)), FuncInfo(funcinfo),
444  SwiftError(swifterror) {}
445 
446  void init(GCFunctionInfo *gfi, AliasAnalysis *AA,
447  const TargetLibraryInfo *li);
448 
449  /// Clear out the current SelectionDAG and the associated state and prepare
450  /// this SelectionDAGBuilder object to be used for a new block. This doesn't
451  /// clear out information about additional blocks that are needed to complete
452  /// switch lowering or PHI node updating; that information is cleared out as
453  /// it is consumed.
454  void clear();
455 
456  /// Clear the dangling debug information map. This function is separated from
457  /// the clear so that debug information that is dangling in a basic block can
458  /// be properly resolved in a different basic block. This allows the
459  /// SelectionDAG to resolve dangling debug information attached to PHI nodes.
460  void clearDanglingDebugInfo();
461 
462  /// Return the current virtual root of the Selection DAG, flushing any
463  /// PendingLoad items. This must be done before emitting a store or any other
464  /// memory node that may need to be ordered after any prior load instructions.
466 
467  /// Similar to getMemoryRoot, but also flushes PendingConstrainedFP(Strict)
468  /// items. This must be done before emitting any call other any other node
469  /// that may need to be ordered after FP instructions due to other side
470  /// effects.
471  SDValue getRoot();
472 
473  /// Similar to getRoot, but instead of flushing all the PendingLoad items,
474  /// flush all the PendingExports (and PendingConstrainedFPStrict) items.
475  /// It is necessary to do this before emitting a terminator instruction.
477 
478  SDLoc getCurSDLoc() const {
479  return SDLoc(CurInst, SDNodeOrder);
480  }
481 
483  return CurInst ? CurInst->getDebugLoc() : DebugLoc();
484  }
485 
486  void CopyValueToVirtualRegister(const Value *V, unsigned Reg);
487 
488  void visit(const Instruction &I);
489 
490  void visit(unsigned Opcode, const User &I);
491 
492  /// If there was virtual register allocated for the value V emit CopyFromReg
493  /// of the specified type Ty. Return empty SDValue() otherwise.
494  SDValue getCopyFromRegs(const Value *V, Type *Ty);
495 
496  /// If we have dangling debug info that describes \p Variable, or an
497  /// overlapping part of variable considering the \p Expr, then this method
498  /// will drop that debug info as it isn't valid any longer.
499  void dropDanglingDebugInfo(const DILocalVariable *Variable,
500  const DIExpression *Expr);
501 
502  /// If we saw an earlier dbg_value referring to V, generate the debug data
503  /// structures now that we've seen its definition.
504  void resolveDanglingDebugInfo(const Value *V, SDValue Val);
505 
506  /// For the given dangling debuginfo record, perform last-ditch efforts to
507  /// resolve the debuginfo to something that is represented in this DAG. If
508  /// this cannot be done, produce an Undef debug value record.
509  void salvageUnresolvedDbgValue(DanglingDebugInfo &DDI);
510 
511  /// For a given Value, attempt to create and record a SDDbgValue in the
512  /// SelectionDAG.
513  bool handleDebugValue(const Value *V, DILocalVariable *Var,
514  DIExpression *Expr, DebugLoc CurDL,
515  DebugLoc InstDL, unsigned Order);
516 
517  /// Evict any dangling debug information, attempting to salvage it first.
518  void resolveOrClearDbgInfo();
519 
520  SDValue getValue(const Value *V);
521  bool findValue(const Value *V) const;
522 
523  /// Return the SDNode for the specified IR value if it exists.
525  if (NodeMap.find(V) == NodeMap.end())
526  return nullptr;
527  return NodeMap[V].getNode();
528  }
529 
531  SDValue getValueImpl(const Value *V);
532 
533  void setValue(const Value *V, SDValue NewN) {
534  SDValue &N = NodeMap[V];
535  assert(!N.getNode() && "Already set a value for this node!");
536  N = NewN;
537  }
538 
539  void setUnusedArgValue(const Value *V, SDValue NewN) {
540  SDValue &N = UnusedArgNodeMap[V];
541  assert(!N.getNode() && "Already set a value for this node!");
542  N = NewN;
543  }
544 
545  void FindMergedConditions(const Value *Cond, MachineBasicBlock *TBB,
547  MachineBasicBlock *SwitchBB,
549  BranchProbability FProb, bool InvertCond);
551  MachineBasicBlock *FBB,
552  MachineBasicBlock *CurBB,
553  MachineBasicBlock *SwitchBB,
555  bool InvertCond);
556  bool ShouldEmitAsBranches(const std::vector<SwitchCG::CaseBlock> &Cases);
557  bool isExportableFromCurrentBlock(const Value *V, const BasicBlock *FromBB);
558  void CopyToExportRegsIfNeeded(const Value *V);
559  void ExportFromCurrentBlock(const Value *V);
560  void LowerCallTo(ImmutableCallSite CS, SDValue Callee, bool IsTailCall,
561  const BasicBlock *EHPadBB = nullptr);
562 
563  // Lower range metadata from 0 to N to assert zext to an integer of nearest
564  // floor power of two.
566  SDValue Op);
567 
569  const CallBase *Call, unsigned ArgIdx,
570  unsigned NumArgs, SDValue Callee,
571  Type *ReturnTy, bool IsPatchPoint);
572 
573  std::pair<SDValue, SDValue>
575  const BasicBlock *EHPadBB = nullptr);
576 
577  /// When an MBB was split during scheduling, update the
578  /// references that need to refer to the last resulting block.
580 
581  /// Describes a gc.statepoint or a gc.statepoint like thing for the purposes
582  /// of lowering into a STATEPOINT node.
584  /// Bases[i] is the base pointer for Ptrs[i]. Together they denote the set
585  /// of gc pointers this STATEPOINT has to relocate.
588 
589  /// The set of gc.relocate calls associated with this gc.statepoint.
591 
592  /// The full list of gc arguments to the gc.statepoint being lowered.
594 
595  /// The gc.statepoint instruction.
596  const Instruction *StatepointInstr = nullptr;
597 
598  /// The list of gc transition arguments present in the gc.statepoint being
599  /// lowered.
601 
602  /// The ID that the resulting STATEPOINT instruction has to report.
603  unsigned ID = -1;
604 
605  /// Information regarding the underlying call instruction.
607 
608  /// The deoptimization state associated with this gc.statepoint call, if
609  /// any.
611 
612  /// Flags associated with the meta arguments being lowered.
613  uint64_t StatepointFlags = -1;
614 
615  /// The number of patchable bytes the call needs to get lowered into.
616  unsigned NumPatchBytes = -1;
617 
618  /// The exception handling unwind destination, in case this represents an
619  /// invoke of gc.statepoint.
620  const BasicBlock *EHPadBB = nullptr;
621 
622  explicit StatepointLoweringInfo(SelectionDAG &DAG) : CLI(DAG) {}
623  };
624 
625  /// Lower \p SLI into a STATEPOINT instruction.
627 
628  // This function is responsible for the whole statepoint lowering process.
629  // It uniformly handles invoke and call statepoints.
631  const BasicBlock *EHPadBB = nullptr);
632 
633  void LowerCallSiteWithDeoptBundle(const CallBase *Call, SDValue Callee,
634  const BasicBlock *EHPadBB);
635 
636  void LowerDeoptimizeCall(const CallInst *CI);
638 
639  void LowerCallSiteWithDeoptBundleImpl(const CallBase *Call, SDValue Callee,
640  const BasicBlock *EHPadBB,
641  bool VarArgDisallowed,
642  bool ForceVoidReturnTy);
643 
644  /// Returns the type of FrameIndex and TargetFrameIndex nodes.
647  }
648 
649 private:
650  // Terminator instructions.
651  void visitRet(const ReturnInst &I);
652  void visitBr(const BranchInst &I);
653  void visitSwitch(const SwitchInst &I);
654  void visitIndirectBr(const IndirectBrInst &I);
655  void visitUnreachable(const UnreachableInst &I);
656  void visitCleanupRet(const CleanupReturnInst &I);
657  void visitCatchSwitch(const CatchSwitchInst &I);
658  void visitCatchRet(const CatchReturnInst &I);
659  void visitCatchPad(const CatchPadInst &I);
660  void visitCleanupPad(const CleanupPadInst &CPI);
661 
662  BranchProbability getEdgeProbability(const MachineBasicBlock *Src,
663  const MachineBasicBlock *Dst) const;
664  void addSuccessorWithProb(
667 
668 public:
670  void visitSPDescriptorParent(StackProtectorDescriptor &SPD,
671  MachineBasicBlock *ParentBB);
672  void visitSPDescriptorFailure(StackProtectorDescriptor &SPD);
674  MachineBasicBlock *SwitchBB);
676  BranchProbability BranchProbToNext, unsigned Reg,
681  MachineBasicBlock *SwitchBB);
682 
683 private:
684  // These all get lowered before this pass.
685  void visitInvoke(const InvokeInst &I);
686  void visitCallBr(const CallBrInst &I);
687  void visitResume(const ResumeInst &I);
688 
689  void visitUnary(const User &I, unsigned Opcode);
690  void visitFNeg(const User &I) { visitUnary(I, ISD::FNEG); }
691 
692  void visitBinary(const User &I, unsigned Opcode);
693  void visitShift(const User &I, unsigned Opcode);
694  void visitAdd(const User &I) { visitBinary(I, ISD::ADD); }
695  void visitFAdd(const User &I) { visitBinary(I, ISD::FADD); }
696  void visitSub(const User &I) { visitBinary(I, ISD::SUB); }
697  void visitFSub(const User &I);
698  void visitMul(const User &I) { visitBinary(I, ISD::MUL); }
699  void visitFMul(const User &I) { visitBinary(I, ISD::FMUL); }
700  void visitURem(const User &I) { visitBinary(I, ISD::UREM); }
701  void visitSRem(const User &I) { visitBinary(I, ISD::SREM); }
702  void visitFRem(const User &I) { visitBinary(I, ISD::FREM); }
703  void visitUDiv(const User &I) { visitBinary(I, ISD::UDIV); }
704  void visitSDiv(const User &I);
705  void visitFDiv(const User &I) { visitBinary(I, ISD::FDIV); }
706  void visitAnd (const User &I) { visitBinary(I, ISD::AND); }
707  void visitOr (const User &I) { visitBinary(I, ISD::OR); }
708  void visitXor (const User &I) { visitBinary(I, ISD::XOR); }
709  void visitShl (const User &I) { visitShift(I, ISD::SHL); }
710  void visitLShr(const User &I) { visitShift(I, ISD::SRL); }
711  void visitAShr(const User &I) { visitShift(I, ISD::SRA); }
712  void visitICmp(const User &I);
713  void visitFCmp(const User &I);
714  // Visit the conversion instructions
715  void visitTrunc(const User &I);
716  void visitZExt(const User &I);
717  void visitSExt(const User &I);
718  void visitFPTrunc(const User &I);
719  void visitFPExt(const User &I);
720  void visitFPToUI(const User &I);
721  void visitFPToSI(const User &I);
722  void visitUIToFP(const User &I);
723  void visitSIToFP(const User &I);
724  void visitPtrToInt(const User &I);
725  void visitIntToPtr(const User &I);
726  void visitBitCast(const User &I);
727  void visitAddrSpaceCast(const User &I);
728 
729  void visitExtractElement(const User &I);
730  void visitInsertElement(const User &I);
731  void visitShuffleVector(const User &I);
732 
733  void visitExtractValue(const User &I);
734  void visitInsertValue(const User &I);
735  void visitLandingPad(const LandingPadInst &LP);
736 
737  void visitGetElementPtr(const User &I);
738  void visitSelect(const User &I);
739 
740  void visitAlloca(const AllocaInst &I);
741  void visitLoad(const LoadInst &I);
742  void visitStore(const StoreInst &I);
743  void visitMaskedLoad(const CallInst &I, bool IsExpanding = false);
744  void visitMaskedStore(const CallInst &I, bool IsCompressing = false);
745  void visitMaskedGather(const CallInst &I);
746  void visitMaskedScatter(const CallInst &I);
747  void visitAtomicCmpXchg(const AtomicCmpXchgInst &I);
748  void visitAtomicRMW(const AtomicRMWInst &I);
749  void visitFence(const FenceInst &I);
750  void visitPHI(const PHINode &I);
751  void visitCall(const CallInst &I);
752  bool visitMemCmpCall(const CallInst &I);
753  bool visitMemPCpyCall(const CallInst &I);
754  bool visitMemChrCall(const CallInst &I);
755  bool visitStrCpyCall(const CallInst &I, bool isStpcpy);
756  bool visitStrCmpCall(const CallInst &I);
757  bool visitStrLenCall(const CallInst &I);
758  bool visitStrNLenCall(const CallInst &I);
759  bool visitUnaryFloatCall(const CallInst &I, unsigned Opcode);
760  bool visitBinaryFloatCall(const CallInst &I, unsigned Opcode);
761  void visitAtomicLoad(const LoadInst &I);
762  void visitAtomicStore(const StoreInst &I);
763  void visitLoadFromSwiftError(const LoadInst &I);
764  void visitStoreToSwiftError(const StoreInst &I);
765  void visitFreeze(const FreezeInst &I);
766 
767  void visitInlineAsm(ImmutableCallSite CS);
768  void visitIntrinsicCall(const CallInst &I, unsigned Intrinsic);
769  void visitTargetIntrinsic(const CallInst &I, unsigned Intrinsic);
770  void visitConstrainedFPIntrinsic(const ConstrainedFPIntrinsic &FPI);
771 
772  void visitVAStart(const CallInst &I);
773  void visitVAArg(const VAArgInst &I);
774  void visitVAEnd(const CallInst &I);
775  void visitVACopy(const CallInst &I);
776  void visitStackmap(const CallInst &I);
777  void visitPatchpoint(ImmutableCallSite CS,
778  const BasicBlock *EHPadBB = nullptr);
779 
780  // These two are implemented in StatepointLowering.cpp
781  void visitGCRelocate(const GCRelocateInst &Relocate);
782  void visitGCResult(const GCResultInst &I);
783 
784  void visitVectorReduce(const CallInst &I, unsigned Intrinsic);
785 
786  void visitUserOp1(const Instruction &I) {
787  llvm_unreachable("UserOp1 should not exist at instruction selection time!");
788  }
789  void visitUserOp2(const Instruction &I) {
790  llvm_unreachable("UserOp2 should not exist at instruction selection time!");
791  }
792 
793  void processIntegerCallValue(const Instruction &I,
794  SDValue Value, bool IsSigned);
795 
796  void HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB);
797 
798  void emitInlineAsmError(ImmutableCallSite CS, const Twine &Message);
799 
800  /// If V is an function argument then create corresponding DBG_VALUE machine
801  /// instruction for it now. At the end of instruction selection, they will be
802  /// inserted to the entry BB.
803  bool EmitFuncArgumentDbgValue(const Value *V, DILocalVariable *Variable,
804  DIExpression *Expr, DILocation *DL,
805  bool IsDbgDeclare, const SDValue &N);
806 
807  /// Return the next block after MBB, or nullptr if there is none.
808  MachineBasicBlock *NextBlock(MachineBasicBlock *MBB);
809 
810  /// Update the DAG and DAG builder with the relevant information after
811  /// a new root node has been created which could be a tail call.
812  void updateDAGForMaybeTailCall(SDValue MaybeTC);
813 
814  /// Return the appropriate SDDbgValue based on N.
815  SDDbgValue *getDbgValue(SDValue N, DILocalVariable *Variable,
816  DIExpression *Expr, const DebugLoc &dl,
817  unsigned DbgSDNodeOrder);
818 
819  /// Lowers CallInst to an external symbol.
820  void lowerCallToExternalSymbol(const CallInst &I, const char *FunctionName);
821 };
822 
823 /// This struct represents the registers (physical or virtual)
824 /// that a particular set of values is assigned, and the type information about
825 /// the value. The most common situation is to represent one value at a time,
826 /// but struct or array values are handled element-wise as multiple values. The
827 /// splitting of aggregates is performed recursively, so that we never have
828 /// aggregate-typed registers. The values at this point do not necessarily have
829 /// legal types, so each value may require one or more registers of some legal
830 /// type.
831 ///
832 struct RegsForValue {
833  /// The value types of the values, which may not be legal, and
834  /// may need be promoted or synthesized from one or more registers.
836 
837  /// The value types of the registers. This is the same size as ValueVTs and it
838  /// records, for each value, what the type of the assigned register or
839  /// registers are. (Individual values are never synthesized from more than one
840  /// type of register.)
841  ///
842  /// With virtual registers, the contents of RegVTs is redundant with TLI's
843  /// getRegisterType member function, however when with physical registers
844  /// it is necessary to have a separate record of the types.
846 
847  /// This list holds the registers assigned to the values.
848  /// Each legal or promoted value requires one register, and each
849  /// expanded value requires multiple registers.
851 
852  /// This list holds the number of registers for each value.
854 
855  /// Records if this value needs to be treated in an ABI dependant manner,
856  /// different to normal type legalization.
858 
859  RegsForValue() = default;
860  RegsForValue(const SmallVector<unsigned, 4> &regs, MVT regvt, EVT valuevt,
863  const DataLayout &DL, unsigned Reg, Type *Ty,
865 
866  bool isABIMangled() const {
867  return CallConv.hasValue();
868  }
869 
870  /// Add the specified values to this one.
871  void append(const RegsForValue &RHS) {
872  ValueVTs.append(RHS.ValueVTs.begin(), RHS.ValueVTs.end());
873  RegVTs.append(RHS.RegVTs.begin(), RHS.RegVTs.end());
874  Regs.append(RHS.Regs.begin(), RHS.Regs.end());
875  RegCount.push_back(RHS.Regs.size());
876  }
877 
878  /// Emit a series of CopyFromReg nodes that copies from this value and returns
879  /// the result as a ValueVTs value. This uses Chain/Flag as the input and
880  /// updates them for the output Chain/Flag. If the Flag pointer is NULL, no
881  /// flag is used.
883  const SDLoc &dl, SDValue &Chain, SDValue *Flag,
884  const Value *V = nullptr) const;
885 
886  /// Emit a series of CopyToReg nodes that copies the specified value into the
887  /// registers specified by this object. This uses Chain/Flag as the input and
888  /// updates them for the output Chain/Flag. If the Flag pointer is nullptr, no
889  /// flag is used. If V is not nullptr, then it is used in printing better
890  /// diagnostic messages on error.
891  void getCopyToRegs(SDValue Val, SelectionDAG &DAG, const SDLoc &dl,
892  SDValue &Chain, SDValue *Flag, const Value *V = nullptr,
893  ISD::NodeType PreferredExtendType = ISD::ANY_EXTEND) const;
894 
895  /// Add this value to the specified inlineasm node operand list. This adds the
896  /// code marker, matching input operand index (if applicable), and includes
897  /// the number of values added into it.
898  void AddInlineAsmOperands(unsigned Code, bool HasMatching,
899  unsigned MatchingIdx, const SDLoc &dl,
900  SelectionDAG &DAG, std::vector<SDValue> &Ops) const;
901 
902  /// Check if the total RegCount is greater than one.
903  bool occupiesMultipleRegs() const {
904  return std::accumulate(RegCount.begin(), RegCount.end(), 0) > 1;
905  }
906 
907  /// Return a list of registers and their sizes.
908  SmallVector<std::pair<unsigned, unsigned>, 4> getRegsAndSizes() const;
909 };
910 
911 } // end namespace llvm
912 
913 #endif // LLVM_LIB_CODEGEN_SELECTIONDAG_SELECTIONDAGBUILDER_H
Return a value (possibly void), from a function.
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
Represents calls to the gc.result intrinsic.
Definition: Statepoint.h:393
bool ShouldEmitAsBranches(const std::vector< SwitchCG::CaseBlock > &Cases)
If the set of cases should be emitted as a series of branches, return true.
CaseClusterVector::iterator CaseClusterIt
This class represents lattice values for constants.
Definition: AllocatorList.h:23
void ExportFromCurrentBlock(const Value *V)
ExportFromCurrentBlock - If this condition isn&#39;t known to be exported from the current basic block...
const TargetLibraryInfo * LibInfo
StatepointFlags
The statepoint intrinsic accepts a set of flags as its third argument.
Definition: Statepoint.h:40
Various leaf nodes.
Definition: ISDOpcodes.h:61
DenseMap< MachineBasicBlock *, SmallVector< unsigned, 4 > > LPadToCallSiteMap
Map a landing pad to the call site indexes.
void LowerDeoptimizeCall(const CallInst *CI)
An instruction for ordering other memory operations.
Definition: Instructions.h:471
TargetLowering::CallLoweringInfo CLI
Information regarding the underlying call instruction.
void CopyValueToVirtualRegister(const Value *V, unsigned Reg)
An instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
Definition: Instructions.h:547
SmallVector< const GCRelocateInst *, 16 > GCRelocates
The set of gc.relocate calls associated with this gc.statepoint.
SelectionDAGBuilder - This is the common target-independent lowering implementation that is parameter...
A specialization of it&#39;s base class for read only access to a gc.statepoint.
Definition: Statepoint.h:292
void push_back(const T &Elt)
Definition: SmallVector.h:211
void visitBitTestCase(SwitchCG::BitTestBlock &BB, MachineBasicBlock *NextMBB, BranchProbability BranchProbToNext, unsigned Reg, SwitchCG::BitTestCase &B, MachineBasicBlock *SwitchBB)
visitBitTestCase - this function produces one "bit test"
void LowerCallSiteWithDeoptBundle(const CallBase *Call, SDValue Callee, const BasicBlock *EHPadBB)
This class represents a function call, abstracting a target machine&#39;s calling convention.
unsigned Reg
void setValue(const Value *V, SDValue NewN)
Optional< CallingConv::ID > CallConv
Records if this value needs to be treated in an ABI dependant manner, different to normal type legali...
SwiftErrorValueTracking & SwiftError
Information about the swifterror values used throughout the function.
SDNode * getNodeForIRValue(const Value *V)
Return the SDNode for the specified IR value if it exists.
This class implements a map that also provides access to all stored values in a deterministic order...
Definition: MapVector.h:37
A debug info location.
Definition: DebugLoc.h:33
This structure is used to communicate between SelectionDAGBuilder and SDISel for the code generation ...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1105
An instruction for reading from memory.
Definition: Instructions.h:169
an instruction that atomically reads a memory location, combines it with another value, and then stores the result back.
Definition: Instructions.h:710
SDNode * getNode() const
get the SDNode which holds the desired result
This is the common base class for constrained floating point intrinsics.
SDValue getValueImpl(const Value *V)
getValueImpl - Helper function for getValue and getNonRegisterValue.
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
Definition: ISDOpcodes.h:40
void FindMergedConditions(const Value *Cond, MachineBasicBlock *TBB, MachineBasicBlock *FBB, MachineBasicBlock *CurBB, MachineBasicBlock *SwitchBB, Instruction::BinaryOps Opc, BranchProbability TProb, BranchProbability FProb, bool InvertCond)
void EmitBranchForMergedCondition(const Value *Cond, MachineBasicBlock *TBB, MachineBasicBlock *FBB, MachineBasicBlock *CurBB, MachineBasicBlock *SwitchBB, BranchProbability TProb, BranchProbability FProb, bool InvertCond)
EmitBranchForMergedCondition - Helper method for FindMergedConditions.
void visitBitTestHeader(SwitchCG::BitTestBlock &B, MachineBasicBlock *SwitchBB)
visitBitTestHeader - This function emits necessary code to produce value suitable for "bit tests" ...
SDValue getValue(const Value *V)
getValue - Return an SDValue for the given Value.
StackProtectorDescriptor SPDescriptor
A StackProtectorDescriptor structure used to communicate stack protector information in between Selec...
std::unique_ptr< SDAGSwitchLowering > SL
void visitSPDescriptorParent(StackProtectorDescriptor &SPD, MachineBasicBlock *ParentBB)
Codegen a new tail for a stack protector check ParentMBB which has had its tail spliced into a stack ...
SDValue getRoot()
Similar to getMemoryRoot, but also flushes PendingConstrainedFP(Strict) items.
Definition: BitVector.h:937
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:80
Shift and rotation operations.
Definition: ISDOpcodes.h:471
void resolveOrClearDbgInfo()
Evict any dangling debug information, attempting to salvage it first.
ArrayRef< const Use > GCTransitionArgs
The list of gc transition arguments present in the gc.statepoint being lowered.
SDAGSwitchLowering(SelectionDAGBuilder *sdb, FunctionLoweringInfo &funcinfo)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
SmallVector< EVT, 4 > ValueVTs
The value types of the values, which may not be legal, and may need be promoted or synthesized from o...
std::vector< CaseCluster > CaseClusterVector
const DataLayout & getDataLayout() const
Definition: SelectionDAG.h:423
SDValue LowerAsSTATEPOINT(StatepointLoweringInfo &SI)
Lower SLI into a STATEPOINT instruction.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
This file implements a class to represent arbitrary precision integral constant values and operations...
Simple integer binary arithmetic operators.
Definition: ISDOpcodes.h:202
SDValue getNonRegisterValue(const Value *V)
getNonRegisterValue - Return an SDValue for the given Value, but don&#39;t look in FuncInfo.ValueMap for a virtual register.
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)
Initialize the set of available library functions based on the specified target triple.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
SDValue lowerRangeToAssertZExt(SelectionDAG &DAG, const Instruction &I, SDValue Op)
SDValue getMemoryRoot()
Return the current virtual root of the Selection DAG, flushing any PendingLoad items.
An instruction for storing to memory.
Definition: Instructions.h:331
void init(GCFunctionInfo *gfi, AliasAnalysis *AA, const TargetLibraryInfo *li)
bool findValue(const Value *V) const
Debug location.
void visitJumpTable(SwitchCG::JumpTable &JT)
visitJumpTable - Emit JumpTable node in the current MBB
void append(const RegsForValue &RHS)
Add the specified values to this one.
void salvageUnresolvedDbgValue(DanglingDebugInfo &DDI)
For the given dangling debuginfo record, perform last-ditch efforts to resolve the debuginfo to somet...
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:139
bool handleDebugValue(const Value *V, DILocalVariable *Var, DIExpression *Expr, DebugLoc CurDL, DebugLoc InstDL, unsigned Order)
For a given Value, attempt to create and record a SDDbgValue in the SelectionDAG. ...
std::pair< SDValue, SDValue > lowerInvokable(TargetLowering::CallLoweringInfo &CLI, const BasicBlock *EHPadBB=nullptr)
The landingpad instruction holds all of the information necessary to generate correct exception handl...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
bool HasTailCall
This is set to true if a call in the current block has been translated as a tail call.
ArrayRef< const Use > DeoptState
The deoptimization state associated with this gc.statepoint call, if any.
Machine Value Type.
LLVM Basic Block Representation.
Definition: BasicBlock.h:57
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:63
Simple binary floating point operators.
Definition: ISDOpcodes.h:295
Conditional or Unconditional Branch instruction.
This function has undefined behavior.
Resume the propagation of an exception.
Indirect Branch Instruction.
void LowerCallSiteWithDeoptBundleImpl(const CallBase *Call, SDValue Callee, const BasicBlock *EHPadBB, bool VarArgDisallowed, bool ForceVoidReturnTy)
void dropDanglingDebugInfo(const DILocalVariable *Variable, const DIExpression *Expr)
If we have dangling debug info that describes Variable, or an overlapping part of variable considerin...
This class tracks both per-statepoint and per-selectiondag information.
Extended Value Type.
Definition: ValueTypes.h:34
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
This structure contains all information that is necessary for lowering calls.
size_t size() const
Definition: SmallVector.h:52
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
void CopyToExportRegsIfNeeded(const Value *V)
CopyToExportRegsIfNeeded - If the given value has virtual registers created for it, emit nodes to copy the value into the virtual registers.
static BranchProbability getUnknown()
void visitSPDescriptorFailure(StackProtectorDescriptor &SPD)
Codegen the failure basic block for a stack protector check.
const TargetLowering & getTargetLoweringInfo() const
Definition: SelectionDAG.h:426
SmallVector< unsigned, 4 > RegCount
This list holds the number of registers for each value.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:223
This struct represents the registers (physical or virtual) that a particular set of values is assigne...
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:837
Provides information about what library functions are available for the current target.
void clear()
Clear out the current SelectionDAG and the associated state and prepare this SelectionDAGBuilder obje...
This class represents a freeze function that returns random concrete value if an operand is either a ...
void visit(const Instruction &I)
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
virtual void addSuccessorWithProb(MachineBasicBlock *Src, MachineBasicBlock *Dst, BranchProbability Prob=BranchProbability::getUnknown()) override
Represents one node in the SelectionDAG.
void UpdateSplitBlock(MachineBasicBlock *First, MachineBasicBlock *Last)
When an MBB was split during scheduling, update the references that need to refer to the last resulti...
DWARF expression.
GCFunctionInfo * GFI
Garbage collection metadata for the function.
amdgpu Simplify well known AMD library false FunctionCallee Callee
ANY_EXTEND - Used for integer types. The high bits are undefined.
Definition: ISDOpcodes.h:532
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
Definition: SmallVector.h:387
could "use" a pointer
SelectionDAGBuilder(SelectionDAG &dag, FunctionLoweringInfo &funcinfo, SwiftErrorValueTracking &swifterror, CodeGenOpt::Level ol)
SmallVector< SDValue, 8 > PendingLoads
Loads are not emitted to the program immediately.
bool hasValue() const
Definition: Optional.h:259
void LowerStatepoint(ImmutableStatepoint ISP, const BasicBlock *EHPadBB=nullptr)
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Definition: Instruction.h:331
Bitwise operators - logical and, logical or, logical xor.
Definition: ISDOpcodes.h:448
This represents the llvm.dbg.value instruction.
Establish a view to a call site for examination.
Definition: CallSite.h:697
#define I(x, y, z)
Definition: MD5.cpp:58
#define N
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
void visitJumpTableHeader(SwitchCG::JumpTable &JT, SwitchCG::JumpTableHeader &JTH, MachineBasicBlock *SwitchBB)
visitJumpTableHeader - This function emits necessary code to produce index in the JumpTable from swit...
SmallVector< const Value *, 16 > Bases
Bases[i] is the base pointer for Ptrs[i].
StatepointLoweringState StatepointLowering
State used while lowering a statepoint sequence (gc_statepoint, gc_relocate, and gc_result).
SDValue getCopyFromRegs(const Value *V, Type *Ty)
If there was virtual register allocated for the value V emit CopyFromReg of the specified type Ty...
void LowerCallTo(ImmutableCallSite CS, SDValue Callee, bool IsTailCall, const BasicBlock *EHPadBB=nullptr)
Multiway switch.
FunctionLoweringInfo & FuncInfo
Information about the function as a whole.
SmallVector< MVT, 4 > RegVTs
The value types of the registers.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void setUnusedArgValue(const Value *V, SDValue NewN)
Represents calls to the gc.relocate intrinsic.
Definition: Statepoint.h:360
LLVM Value Representation.
Definition: Value.h:74
void populateCallLoweringInfo(TargetLowering::CallLoweringInfo &CLI, const CallBase *Call, unsigned ArgIdx, unsigned NumArgs, SDValue Callee, Type *ReturnTy, bool IsPatchPoint)
Populate a CallLowerinInfo (into CLI) based on the properties of the call being lowered.
ArrayRef< const Use > GCArgs
The full list of gc arguments to the gc.statepoint being lowered.
MVT getFrameIndexTy()
Returns the type of FrameIndex and TargetFrameIndex nodes.
Invoke instruction.
MVT getFrameIndexTy(const DataLayout &DL) const
Return the type for frame index, which is determined by the alloca address space specified through th...
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:65
SDValue getControlRoot()
Similar to getRoot, but instead of flushing all the PendingLoad items, flush all the PendingExports (...
Garbage collection metadata for a single function.
Definition: GCMetadata.h:77
void clearDanglingDebugInfo()
Clear the dangling debug information map.
DenseMap< const Constant *, unsigned > ConstantsOut
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
bool isExportableFromCurrentBlock(const Value *V, const BasicBlock *FromBB)
Holds the information from a dbg_value node through SDISel.
A cluster of case labels.
Perform various unary floating-point operations inspired by libm.
Definition: ISDOpcodes.h:640
SmallVector< unsigned, 4 > Regs
This list holds the registers assigned to the values.
static const unsigned LowestSDNodeOrder
Lowest valid SDNodeOrder.
void visitSwitchCase(SwitchCG::CaseBlock &CB, MachineBasicBlock *SwitchBB)
visitSwitchCase - Emits the necessary code to represent a single node in the binary search tree resul...
void resolveDanglingDebugInfo(const Value *V, SDValue Val)
If we saw an earlier dbg_value referring to V, generate the debug data structures now that we&#39;ve seen...
Describes a gc.statepoint or a gc.statepoint like thing for the purposes of lowering into a STATEPOIN...
This file describes how to lower LLVM code to machine code.
an instruction to allocate memory on the stack
Definition: Instructions.h:59
bool occupiesMultipleRegs() const
Check if the total RegCount is greater than one.