LLVM  8.0.0svn
BasicBlock.cpp
Go to the documentation of this file.
1 //===-- BasicBlock.cpp - Implement BasicBlock related methods -------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the BasicBlock class for the IR library.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "llvm/IR/BasicBlock.h"
16 #include "llvm/ADT/STLExtras.h"
17 #include "llvm/IR/CFG.h"
18 #include "llvm/IR/Constants.h"
19 #include "llvm/IR/Instructions.h"
20 #include "llvm/IR/IntrinsicInst.h"
21 #include "llvm/IR/LLVMContext.h"
22 #include "llvm/IR/Type.h"
23 #include <algorithm>
24 
25 using namespace llvm;
26 
28  if (Function *F = getParent())
29  return F->getValueSymbolTable();
30  return nullptr;
31 }
32 
34  return getType()->getContext();
35 }
36 
37 // Explicit instantiation of SymbolTableListTraits since some of the methods
38 // are not in the public header file...
40 
42  BasicBlock *InsertBefore)
43  : Value(Type::getLabelTy(C), Value::BasicBlockVal), Parent(nullptr) {
44 
45  if (NewParent)
46  insertInto(NewParent, InsertBefore);
47  else
48  assert(!InsertBefore &&
49  "Cannot insert block before another block with no function!");
50 
51  setName(Name);
52 }
53 
54 void BasicBlock::insertInto(Function *NewParent, BasicBlock *InsertBefore) {
55  assert(NewParent && "Expected a parent");
56  assert(!Parent && "Already has a parent");
57 
58  if (InsertBefore)
59  NewParent->getBasicBlockList().insert(InsertBefore->getIterator(), this);
60  else
61  NewParent->getBasicBlockList().push_back(this);
62 }
63 
65  // If the address of the block is taken and it is being deleted (e.g. because
66  // it is dead), this means that there is either a dangling constant expr
67  // hanging off the block, or an undefined use of the block (source code
68  // expecting the address of a label to keep the block alive even though there
69  // is no indirect branch). Handle these cases by zapping the BlockAddress
70  // nodes. There are no other possible uses at this point.
71  if (hasAddressTaken()) {
72  assert(!use_empty() && "There should be at least one blockaddress!");
73  Constant *Replacement =
75  while (!use_empty()) {
76  BlockAddress *BA = cast<BlockAddress>(user_back());
78  BA->getType()));
79  BA->destroyConstant();
80  }
81  }
82 
83  assert(getParent() == nullptr && "BasicBlock still linked into the program!");
85  InstList.clear();
86 }
87 
88 void BasicBlock::setParent(Function *parent) {
89  // Set Parent=parent, updating instruction symtab entries as appropriate.
90  InstList.setSymTabObject(&Parent, parent);
91 }
92 
94  std::function<bool(const Instruction &)>>>
96  std::function<bool(const Instruction &)> Fn = [](const Instruction &I) {
97  return !isa<DbgInfoIntrinsic>(I);
98  };
99  return make_filter_range(*this, Fn);
100 }
101 
103  std::function<bool(Instruction &)>>>
105  std::function<bool(Instruction &)> Fn = [](Instruction &I) {
106  return !isa<DbgInfoIntrinsic>(I);
107  };
108  return make_filter_range(*this, Fn);
109 }
110 
113 }
114 
117 }
118 
119 /// Unlink this basic block from its current function and
120 /// insert it into the function that MovePos lives in, right before MovePos.
122  MovePos->getParent()->getBasicBlockList().splice(
123  MovePos->getIterator(), getParent()->getBasicBlockList(), getIterator());
124 }
125 
126 /// Unlink this basic block from its current function and
127 /// insert it into the function that MovePos lives in, right after MovePos.
129  MovePos->getParent()->getBasicBlockList().splice(
130  ++MovePos->getIterator(), getParent()->getBasicBlockList(),
131  getIterator());
132 }
133 
135  return getParent()->getParent();
136 }
137 
139  if (InstList.empty() || !InstList.back().isTerminator())
140  return nullptr;
141  return &InstList.back();
142 }
143 
145  if (InstList.empty())
146  return nullptr;
147  const ReturnInst *RI = dyn_cast<ReturnInst>(&InstList.back());
148  if (!RI || RI == &InstList.front())
149  return nullptr;
150 
151  const Instruction *Prev = RI->getPrevNode();
152  if (!Prev)
153  return nullptr;
154 
155  if (Value *RV = RI->getReturnValue()) {
156  if (RV != Prev)
157  return nullptr;
158 
159  // Look through the optional bitcast.
160  if (auto *BI = dyn_cast<BitCastInst>(Prev)) {
161  RV = BI->getOperand(0);
162  Prev = BI->getPrevNode();
163  if (!Prev || RV != Prev)
164  return nullptr;
165  }
166  }
167 
168  if (auto *CI = dyn_cast<CallInst>(Prev)) {
169  if (CI->isMustTailCall())
170  return CI;
171  }
172  return nullptr;
173 }
174 
176  if (InstList.empty())
177  return nullptr;
178  auto *RI = dyn_cast<ReturnInst>(&InstList.back());
179  if (!RI || RI == &InstList.front())
180  return nullptr;
181 
182  if (auto *CI = dyn_cast_or_null<CallInst>(RI->getPrevNode()))
183  if (Function *F = CI->getCalledFunction())
184  if (F->getIntrinsicID() == Intrinsic::experimental_deoptimize)
185  return CI;
186 
187  return nullptr;
188 }
189 
191  for (const Instruction &I : *this)
192  if (!isa<PHINode>(I))
193  return &I;
194  return nullptr;
195 }
196 
198  for (const Instruction &I : *this)
199  if (!isa<PHINode>(I) && !isa<DbgInfoIntrinsic>(I))
200  return &I;
201  return nullptr;
202 }
203 
205  for (const Instruction &I : *this) {
206  if (isa<PHINode>(I) || isa<DbgInfoIntrinsic>(I))
207  continue;
208 
209  if (auto *II = dyn_cast<IntrinsicInst>(&I))
210  if (II->getIntrinsicID() == Intrinsic::lifetime_start ||
211  II->getIntrinsicID() == Intrinsic::lifetime_end)
212  continue;
213 
214  return &I;
215  }
216  return nullptr;
217 }
218 
220  const Instruction *FirstNonPHI = getFirstNonPHI();
221  if (!FirstNonPHI)
222  return end();
223 
224  const_iterator InsertPt = FirstNonPHI->getIterator();
225  if (InsertPt->isEHPad()) ++InsertPt;
226  return InsertPt;
227 }
228 
230  for (Instruction &I : *this)
231  I.dropAllReferences();
232 }
233 
234 /// If this basic block has a single predecessor block,
235 /// return the block, otherwise return a null pointer.
237  const_pred_iterator PI = pred_begin(this), E = pred_end(this);
238  if (PI == E) return nullptr; // No preds.
239  const BasicBlock *ThePred = *PI;
240  ++PI;
241  return (PI == E) ? ThePred : nullptr /*multiple preds*/;
242 }
243 
244 /// If this basic block has a unique predecessor block,
245 /// return the block, otherwise return a null pointer.
246 /// Note that unique predecessor doesn't mean single edge, there can be
247 /// multiple edges from the unique predecessor to this block (for example
248 /// a switch statement with multiple cases having the same destination).
250  const_pred_iterator PI = pred_begin(this), E = pred_end(this);
251  if (PI == E) return nullptr; // No preds.
252  const BasicBlock *PredBB = *PI;
253  ++PI;
254  for (;PI != E; ++PI) {
255  if (*PI != PredBB)
256  return nullptr;
257  // The same predecessor appears multiple times in the predecessor list.
258  // This is OK.
259  }
260  return PredBB;
261 }
262 
264  succ_const_iterator SI = succ_begin(this), E = succ_end(this);
265  if (SI == E) return nullptr; // no successors
266  const BasicBlock *TheSucc = *SI;
267  ++SI;
268  return (SI == E) ? TheSucc : nullptr /* multiple successors */;
269 }
270 
272  succ_const_iterator SI = succ_begin(this), E = succ_end(this);
273  if (SI == E) return nullptr; // No successors
274  const BasicBlock *SuccBB = *SI;
275  ++SI;
276  for (;SI != E; ++SI) {
277  if (*SI != SuccBB)
278  return nullptr;
279  // The same successor appears multiple times in the successor list.
280  // This is OK.
281  }
282  return SuccBB;
283 }
284 
286  PHINode *P = empty() ? nullptr : dyn_cast<PHINode>(&*begin());
287  return make_range<phi_iterator>(P, nullptr);
288 }
289 
290 /// This method is used to notify a BasicBlock that the
291 /// specified Predecessor of the block is no longer able to reach it. This is
292 /// actually not used to update the Predecessor list, but is actually used to
293 /// update the PHI nodes that reside in the block. Note that this should be
294 /// called while the predecessor still refers to this block.
295 ///
297  bool DontDeleteUselessPHIs) {
298  assert((hasNUsesOrMore(16)||// Reduce cost of this assertion for complex CFGs.
299  find(pred_begin(this), pred_end(this), Pred) != pred_end(this)) &&
300  "removePredecessor: BB is not a predecessor!");
301 
302  if (InstList.empty()) return;
303  PHINode *APN = dyn_cast<PHINode>(&front());
304  if (!APN) return; // Quick exit.
305 
306  // If there are exactly two predecessors, then we want to nuke the PHI nodes
307  // altogether. However, we cannot do this, if this in this case:
308  //
309  // Loop:
310  // %x = phi [X, Loop]
311  // %x2 = add %x, 1 ;; This would become %x2 = add %x2, 1
312  // br Loop ;; %x2 does not dominate all uses
313  //
314  // This is because the PHI node input is actually taken from the predecessor
315  // basic block. The only case this can happen is with a self loop, so we
316  // check for this case explicitly now.
317  //
318  unsigned max_idx = APN->getNumIncomingValues();
319  assert(max_idx != 0 && "PHI Node in block with 0 predecessors!?!?!");
320  if (max_idx == 2) {
321  BasicBlock *Other = APN->getIncomingBlock(APN->getIncomingBlock(0) == Pred);
322 
323  // Disable PHI elimination!
324  if (this == Other) max_idx = 3;
325  }
326 
327  // <= Two predecessors BEFORE I remove one?
328  if (max_idx <= 2 && !DontDeleteUselessPHIs) {
329  // Yup, loop through and nuke the PHI nodes
330  while (PHINode *PN = dyn_cast<PHINode>(&front())) {
331  // Remove the predecessor first.
332  PN->removeIncomingValue(Pred, !DontDeleteUselessPHIs);
333 
334  // If the PHI _HAD_ two uses, replace PHI node with its now *single* value
335  if (max_idx == 2) {
336  if (PN->getIncomingValue(0) != PN)
337  PN->replaceAllUsesWith(PN->getIncomingValue(0));
338  else
339  // We are left with an infinite loop with no entries: kill the PHI.
340  PN->replaceAllUsesWith(UndefValue::get(PN->getType()));
341  getInstList().pop_front(); // Remove the PHI node
342  }
343 
344  // If the PHI node already only had one entry, it got deleted by
345  // removeIncomingValue.
346  }
347  } else {
348  // Okay, now we know that we need to remove predecessor #pred_idx from all
349  // PHI nodes. Iterate over each PHI node fixing them up
350  PHINode *PN;
351  for (iterator II = begin(); (PN = dyn_cast<PHINode>(II)); ) {
352  ++II;
353  PN->removeIncomingValue(Pred, false);
354  // If all incoming values to the Phi are the same, we can replace the Phi
355  // with that value.
356  Value* PNV = nullptr;
357  if (!DontDeleteUselessPHIs && (PNV = PN->hasConstantValue()))
358  if (PNV != PN) {
359  PN->replaceAllUsesWith(PNV);
360  PN->eraseFromParent();
361  }
362  }
363  }
364 }
365 
367  const Instruction *FirstNonPHI = getFirstNonPHI();
368  if (isa<LandingPadInst>(FirstNonPHI))
369  return true;
370  // This is perhaps a little conservative because constructs like
371  // CleanupBlockInst are pretty easy to split. However, SplitBlockPredecessors
372  // cannot handle such things just yet.
373  if (FirstNonPHI->isEHPad())
374  return false;
375  return true;
376 }
377 
379  auto *Term = getTerminator();
380  // No terminator means the block is under construction.
381  if (!Term)
382  return true;
383 
384  // If the block has no successors, there can be no instructions to hoist.
385  assert(Term->getNumSuccessors() > 0);
386 
387  // Instructions should not be hoisted across exception handling boundaries.
388  return !Term->isExceptionalTerminator();
389 }
390 
391 /// This splits a basic block into two at the specified
392 /// instruction. Note that all instructions BEFORE the specified iterator stay
393 /// as part of the original basic block, an unconditional branch is added to
394 /// the new BB, and the rest of the instructions in the BB are moved to the new
395 /// BB, including the old terminator. This invalidates the iterator.
396 ///
397 /// Note that this only works on well formed basic blocks (must have a
398 /// terminator), and 'I' must not be the end of instruction list (which would
399 /// cause a degenerate basic block to be formed, having a terminator inside of
400 /// the basic block).
401 ///
403  assert(getTerminator() && "Can't use splitBasicBlock on degenerate BB!");
404  assert(I != InstList.end() &&
405  "Trying to get me to create degenerate basic block!");
406 
408  this->getNextNode());
409 
410  // Save DebugLoc of split point before invalidating iterator.
411  DebugLoc Loc = I->getDebugLoc();
412  // Move all of the specified instructions from the original basic block into
413  // the new basic block.
414  New->getInstList().splice(New->end(), this->getInstList(), I, end());
415 
416  // Add a branch instruction to the newly formed basic block.
417  BranchInst *BI = BranchInst::Create(New, this);
418  BI->setDebugLoc(Loc);
419 
420  // Now we must loop through all of the successors of the New block (which
421  // _were_ the successors of the 'this' block), and update any PHI nodes in
422  // successors. If there were PHI nodes in the successors, then they need to
423  // know that incoming branches will be from New, not from Old.
424  //
425  for (succ_iterator I = succ_begin(New), E = succ_end(New); I != E; ++I) {
426  // Loop over any phi nodes in the basic block, updating the BB field of
427  // incoming values...
428  BasicBlock *Successor = *I;
429  for (auto &PN : Successor->phis()) {
430  int Idx = PN.getBasicBlockIndex(this);
431  while (Idx != -1) {
432  PN.setIncomingBlock((unsigned)Idx, New);
433  Idx = PN.getBasicBlockIndex(this);
434  }
435  }
436  }
437  return New;
438 }
439 
441  Instruction *TI = getTerminator();
442  if (!TI)
443  // Cope with being called on a BasicBlock that doesn't have a terminator
444  // yet. Clang's CodeGenFunction::EmitReturnBlock() likes to do this.
445  return;
446  for (BasicBlock *Succ : successors(TI)) {
447  // N.B. Succ might not be a complete BasicBlock, so don't assume
448  // that it ends with a non-phi instruction.
449  for (iterator II = Succ->begin(), IE = Succ->end(); II != IE; ++II) {
450  PHINode *PN = dyn_cast<PHINode>(II);
451  if (!PN)
452  break;
453  int i;
454  while ((i = PN->getBasicBlockIndex(this)) >= 0)
455  PN->setIncomingBlock(i, New);
456  }
457  }
458 }
459 
460 /// Return true if this basic block is a landing pad. I.e., it's
461 /// the destination of the 'unwind' edge of an invoke instruction.
463  return isa<LandingPadInst>(getFirstNonPHI());
464 }
465 
466 /// Return the landingpad instruction associated with the landing pad.
469 }
470 
472  const Instruction *TI = getTerminator();
473  if (MDNode *MDIrrLoopHeader =
475  MDString *MDName = cast<MDString>(MDIrrLoopHeader->getOperand(0));
476  if (MDName->getString().equals("loop_header_weight")) {
477  auto *CI = mdconst::extract<ConstantInt>(MDIrrLoopHeader->getOperand(1));
478  return Optional<uint64_t>(CI->getValue().getZExtValue());
479  }
480  }
481  return Optional<uint64_t>();
482 }
483 
485  while (isa<DbgInfoIntrinsic>(It))
486  ++It;
487  return It;
488 }
uint64_t CallInst * C
Return a value (possibly void), from a function.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks &#39;this&#39; from the containing basic block and deletes it.
Definition: Instruction.cpp:68
bool canSplitPredecessors() const
Definition: BasicBlock.cpp:366
This class provides a symbol table of name/value pairs.
void removePredecessor(BasicBlock *Pred, bool DontDeleteUselessPHIs=false)
Notify the BasicBlock that the predecessor Pred is no longer able to reach it.
Definition: BasicBlock.cpp:296
void dropAllReferences()
Drop all references to operands.
Definition: User.h:295
BasicBlock * getNextNode()
Get the next node, or nullptr for the list tail.
Definition: ilist_node.h:289
iterator erase(iterator where)
Definition: ilist.h:267
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
bool isLegalToHoistInto() const
Return true if it is legal to hoist instructions into this block.
Definition: BasicBlock.cpp:378
Various leaf nodes.
Definition: ISDOpcodes.h:60
void insertInto(Function *Parent, BasicBlock *InsertBefore=nullptr)
Insert unlinked basic block into a function.
Definition: BasicBlock.cpp:54
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:64
const CallInst * getTerminatingMustTailCall() const
Returns the call instruction marked &#39;musttail&#39; prior to the terminating return instruction of this ba...
Definition: BasicBlock.cpp:144
This class represents a function call, abstracting a target machine&#39;s calling convention.
static Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:1737
A debug info location.
Definition: DebugLoc.h:34
Metadata node.
Definition: Metadata.h:864
F(f)
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Definition: BasicBlock.cpp:138
LLVMContext & getContext() const
Get the context in which this basic block lives.
Definition: BasicBlock.cpp:33
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition: Type.h:130
iterator begin()
Instruction iterator methods.
Definition: BasicBlock.h:263
InstListType::const_iterator const_iterator
Definition: BasicBlock.h:91
The address of a basic block.
Definition: Constants.h:836
const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr if the function does no...
Definition: BasicBlock.cpp:134
amdgpu Simplify well known AMD library false Value Value const Twine & Name
const CallInst * getTerminatingDeoptimizeCall() const
Returns the call instruction calling @llvm.experimental.deoptimize prior to the terminating return in...
Definition: BasicBlock.cpp:175
Value * removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty=true)
Remove an incoming value.
int getBasicBlockIndex(const BasicBlock *BB) const
Return the first index of the specified basic block in the value list for this PHI.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
void setName(const Twine &Name)
Change the name of the value.
Definition: Value.cpp:295
ELFYAML::ELF_STO Other
Definition: ELFYAML.cpp:773
Interval::succ_iterator succ_begin(Interval *I)
succ_begin/succ_end - define methods so that Intervals may be used just like BasicBlocks can with the...
Definition: Interval.h:103
bool empty() const
Definition: BasicBlock.h:274
const Instruction * getFirstNonPHIOrDbgOrLifetime() const
Returns a pointer to the first instruction in this block that is not a PHINode, a debug intrinsic...
Definition: BasicBlock.cpp:204
static Type * getLabelTy(LLVMContext &C)
Definition: Type.cpp:162
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:245
const BasicBlock * getUniquePredecessor() const
Return the predecessor of this block if it has a unique predecessor block.
Definition: BasicBlock.cpp:249
const BasicBlock * getSingleSuccessor() const
Return the successor of this block if it has a single successor.
Definition: BasicBlock.cpp:263
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
Definition: Instruction.h:217
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition: Value.cpp:439
Value * getOperand(unsigned i) const
Definition: User.h:170
Interval::succ_iterator succ_end(Interval *I)
Definition: Interval.h:106
StringRef getString() const
Definition: Metadata.cpp:464
void replaceSuccessorsPhiUsesWith(BasicBlock *New)
Update all phi nodes in this basic block&#39;s successors to refer to basic block New instead of to it...
Definition: BasicBlock.cpp:440
#define P(N)
bool hasNUsesOrMore(unsigned N) const
Return true if this value has N users or more.
Definition: Value.cpp:140
The landingpad instruction holds all of the information necessary to generate correct exception handl...
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
Definition: BasicBlock.cpp:190
const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
Definition: BasicBlock.cpp:219
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
Definition: Instruction.h:304
const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
Definition: BasicBlock.cpp:236
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:69
Conditional or Unconditional Branch instruction.
iterator_range< filter_iterator< BasicBlock::const_iterator, std::function< bool(const Instruction &)> > > instructionsWithoutDebug() const
Return a const iterator range over the instructions in the block, skipping any debug instructions...
Definition: BasicBlock.cpp:95
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
Definition: Constant.h:42
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const Instruction & front() const
Definition: BasicBlock.h:275
Interval::pred_iterator pred_begin(Interval *I)
pred_begin/pred_end - define methods so that Intervals may be used just like BasicBlocks can with the...
Definition: Interval.h:113
void pop_front()
Definition: ilist.h:314
void setSymTabObject(TPtr *, TPtr)
setSymTabObject - This is called when (f.e.) the parent of a basic block changes. ...
void splice(iterator where, iplist_impl &L2)
Definition: ilist.h:329
Interval::pred_iterator pred_end(Interval *I)
Definition: Interval.h:116
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Definition: BasicBlock.h:100
self_iterator getIterator()
Definition: ilist_node.h:82
static UndefValue * get(Type *T)
Static factory methods - Return an &#39;undef&#39; object of the specified type.
Definition: Constants.cpp:1392
Value(Type *Ty, unsigned scid)
Definition: Value.cpp:54
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:1063
bool isLandingPad() const
Return true if this basic block is a landing pad.
Definition: BasicBlock.cpp:462
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches, switches, etc.
Definition: BasicBlock.h:386
Value * hasConstantValue() const
If the specified PHI node always merges together the same value, return the value, otherwise return null.
const InstListType & getInstList() const
Return the underlying instruction list container.
Definition: BasicBlock.h:328
void removeFromParent()
Unlink &#39;this&#39; from the containing function, but do not delete it.
Definition: BasicBlock.cpp:111
Iterator for intrusive lists based on ilist_node.
void moveAfter(BasicBlock *MovePos)
Unlink this basic block from its current function and insert it right after MovePos in the function M...
Definition: BasicBlock.cpp:128
void setIncomingBlock(unsigned i, BasicBlock *BB)
iterator end()
Definition: BasicBlock.h:265
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Definition: Constants.cpp:621
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
unsigned getNumIncomingValues() const
Return the number of incoming edges.
A range adaptor for a pair of iterators.
void push_back(pointer val)
Definition: ilist.h:313
InstListType::iterator iterator
Instruction iterators...
Definition: BasicBlock.h:90
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
Definition: StringRef.h:169
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
pointer remove(iterator &IT)
Definition: ilist.h:251
iterator insert(iterator where, pointer New)
Definition: ilist.h:228
static IntegerType * getInt32Ty(LLVMContext &C)
Definition: Type.cpp:176
void clear()
Definition: ilist.h:309
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:107
SymbolTableList< BasicBlock >::iterator eraseFromParent()
Unlink &#39;this&#39; from the containing function and delete it.
Definition: BasicBlock.cpp:115
ValueSymbolTable * getValueSymbolTable()
Returns a pointer to the symbol table if one exists.
Definition: BasicBlock.cpp:27
#define I(x, y, z)
Definition: MD5.cpp:58
Optional< uint64_t > getIrrLoopHeaderWeight() const
Definition: BasicBlock.cpp:471
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:323
const BasicBlockListType & getBasicBlockList() const
Get the underlying elements of the Function...
Definition: Function.h:633
void destroyConstant()
Called if some element of this constant is no longer valid.
Definition: Constants.cpp:361
iterator_range< const_phi_iterator > phis() const
Returns a range that iterates over the phis in the basic block.
Definition: BasicBlock.h:319
BasicBlock * splitBasicBlock(iterator I, const Twine &BBName="")
Split the basic block into two basic blocks at the specified instruction.
Definition: BasicBlock.cpp:402
Value * getReturnValue() const
Convenience accessor. Returns null if there is no return value.
iterator_range< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)
Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...
Definition: STLExtras.h:412
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:566
LLVM Value Representation.
Definition: Value.h:73
succ_range successors(Instruction *I)
Definition: CFG.h:262
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
Definition: Instruction.h:569
Specialization of filter_iterator_base for forward iteration only.
Definition: STLExtras.h:338
A single uniqued string.
Definition: Metadata.h:604
const LandingPadInst * getLandingPadInst() const
Return the landingpad instruction associated with the landing pad.
Definition: BasicBlock.cpp:467
const Instruction * getFirstNonPHIOrDbg() const
Returns a pointer to the first instruction in this block that is not a PHINode or a debug intrinsic...
Definition: BasicBlock.cpp:197
BasicBlock::iterator skipDebugIntrinsics(BasicBlock::iterator It)
Advance It while it points to a debug instruction and return the result.
Definition: BasicBlock.cpp:484
void moveBefore(BasicBlock *MovePos)
Unlink this basic block from its current function and insert it into the function that MovePos lives ...
Definition: BasicBlock.cpp:121
bool use_empty() const
Definition: Value.h:323
void dropAllReferences()
Cause all subinstructions to "let go" of all the references that said subinstructions are maintaining...
Definition: BasicBlock.cpp:229
User * user_back()
Definition: Value.h:386
const BasicBlock * getUniqueSuccessor() const
Return the successor of this block if it has a unique successor.
Definition: BasicBlock.cpp:271