LLVM  14.0.0git
BasicBlock.cpp
Go to the documentation of this file.
1 //===-- BasicBlock.cpp - Implement BasicBlock related methods -------------===//
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 file implements the BasicBlock class for the IR library.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "llvm/IR/BasicBlock.h"
15 #include "llvm/ADT/Statistic.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 
27 #define DEBUG_TYPE "ir"
28 STATISTIC(NumInstrRenumberings, "Number of renumberings across all blocks");
29 
31  if (Function *F = getParent())
32  return F->getValueSymbolTable();
33  return nullptr;
34 }
35 
37  return getType()->getContext();
38 }
39 
41  BB->invalidateOrders();
42 }
43 
44 // Explicit instantiation of SymbolTableListTraits since some of the methods
45 // are not in the public header file...
47 
48 BasicBlock::BasicBlock(LLVMContext &C, const Twine &Name, Function *NewParent,
49  BasicBlock *InsertBefore)
50  : Value(Type::getLabelTy(C), Value::BasicBlockVal), Parent(nullptr) {
51 
52  if (NewParent)
53  insertInto(NewParent, InsertBefore);
54  else
55  assert(!InsertBefore &&
56  "Cannot insert block before another block with no function!");
57 
58  setName(Name);
59 }
60 
61 void BasicBlock::insertInto(Function *NewParent, BasicBlock *InsertBefore) {
62  assert(NewParent && "Expected a parent");
63  assert(!Parent && "Already has a parent");
64 
65  if (InsertBefore)
66  NewParent->getBasicBlockList().insert(InsertBefore->getIterator(), this);
67  else
68  NewParent->getBasicBlockList().push_back(this);
69 }
70 
73 
74  // If the address of the block is taken and it is being deleted (e.g. because
75  // it is dead), this means that there is either a dangling constant expr
76  // hanging off the block, or an undefined use of the block (source code
77  // expecting the address of a label to keep the block alive even though there
78  // is no indirect branch). Handle these cases by zapping the BlockAddress
79  // nodes. There are no other possible uses at this point.
80  if (hasAddressTaken()) {
81  assert(!use_empty() && "There should be at least one blockaddress!");
82  Constant *Replacement =
84  while (!use_empty()) {
85  BlockAddress *BA = cast<BlockAddress>(user_back());
87  BA->getType()));
88  BA->destroyConstant();
89  }
90  }
91 
92  assert(getParent() == nullptr && "BasicBlock still linked into the program!");
94  InstList.clear();
95 }
96 
97 void BasicBlock::setParent(Function *parent) {
98  // Set Parent=parent, updating instruction symtab entries as appropriate.
99  InstList.setSymTabObject(&Parent, parent);
100 }
101 
103  std::function<bool(const Instruction &)>>>
104 BasicBlock::instructionsWithoutDebug(bool SkipPseudoOp) const {
105  std::function<bool(const Instruction &)> Fn = [=](const Instruction &I) {
106  return !isa<DbgInfoIntrinsic>(I) &&
107  !(SkipPseudoOp && isa<PseudoProbeInst>(I));
108  };
109  return make_filter_range(*this, Fn);
110 }
111 
115  std::function<bool(Instruction &)> Fn = [=](Instruction &I) {
116  return !isa<DbgInfoIntrinsic>(I) &&
117  !(SkipPseudoOp && isa<PseudoProbeInst>(I));
118  };
119  return make_filter_range(*this, Fn);
120 }
121 
123  std::function<bool(const Instruction &)>>::difference_type
125  return std::distance(instructionsWithoutDebug().begin(),
127 }
128 
130  getParent()->getBasicBlockList().remove(getIterator());
131 }
132 
134  return getParent()->getBasicBlockList().erase(getIterator());
135 }
136 
138  MovePos->getParent()->getBasicBlockList().splice(
139  MovePos->getIterator(), getParent()->getBasicBlockList(), getIterator());
140 }
141 
143  MovePos->getParent()->getBasicBlockList().splice(
144  ++MovePos->getIterator(), getParent()->getBasicBlockList(),
145  getIterator());
146 }
147 
149  return getParent()->getParent();
150 }
151 
153  if (InstList.empty() || !InstList.back().isTerminator())
154  return nullptr;
155  return &InstList.back();
156 }
157 
159  if (InstList.empty())
160  return nullptr;
161  const ReturnInst *RI = dyn_cast<ReturnInst>(&InstList.back());
162  if (!RI || RI == &InstList.front())
163  return nullptr;
164 
165  const Instruction *Prev = RI->getPrevNode();
166  if (!Prev)
167  return nullptr;
168 
169  if (Value *RV = RI->getReturnValue()) {
170  if (RV != Prev)
171  return nullptr;
172 
173  // Look through the optional bitcast.
174  if (auto *BI = dyn_cast<BitCastInst>(Prev)) {
175  RV = BI->getOperand(0);
176  Prev = BI->getPrevNode();
177  if (!Prev || RV != Prev)
178  return nullptr;
179  }
180  }
181 
182  if (auto *CI = dyn_cast<CallInst>(Prev)) {
183  if (CI->isMustTailCall())
184  return CI;
185  }
186  return nullptr;
187 }
188 
190  if (InstList.empty())
191  return nullptr;
192  auto *RI = dyn_cast<ReturnInst>(&InstList.back());
193  if (!RI || RI == &InstList.front())
194  return nullptr;
195 
196  if (auto *CI = dyn_cast_or_null<CallInst>(RI->getPrevNode()))
197  if (Function *F = CI->getCalledFunction())
198  if (F->getIntrinsicID() == Intrinsic::experimental_deoptimize)
199  return CI;
200 
201  return nullptr;
202 }
203 
205  const BasicBlock* BB = this;
207  Visited.insert(BB);
208  while (auto *Succ = BB->getUniqueSuccessor()) {
209  if (!Visited.insert(Succ).second)
210  return nullptr;
211  BB = Succ;
212  }
213  return BB->getTerminatingDeoptimizeCall();
214 }
215 
217  for (const Instruction &I : *this)
218  if (!isa<PHINode>(I))
219  return &I;
220  return nullptr;
221 }
222 
223 const Instruction *BasicBlock::getFirstNonPHIOrDbg(bool SkipPseudoOp) const {
224  for (const Instruction &I : *this) {
225  if (isa<PHINode>(I) || isa<DbgInfoIntrinsic>(I))
226  continue;
227 
228  if (SkipPseudoOp && isa<PseudoProbeInst>(I))
229  continue;
230 
231  return &I;
232  }
233  return nullptr;
234 }
235 
236 const Instruction *
238  for (const Instruction &I : *this) {
239  if (isa<PHINode>(I) || isa<DbgInfoIntrinsic>(I))
240  continue;
241 
242  if (I.isLifetimeStartOrEnd())
243  continue;
244 
245  if (SkipPseudoOp && isa<PseudoProbeInst>(I))
246  continue;
247 
248  return &I;
249  }
250  return nullptr;
251 }
252 
254  const Instruction *FirstNonPHI = getFirstNonPHI();
255  if (!FirstNonPHI)
256  return end();
257 
258  const_iterator InsertPt = FirstNonPHI->getIterator();
259  if (InsertPt->isEHPad()) ++InsertPt;
260  return InsertPt;
261 }
262 
264  for (Instruction &I : *this)
265  I.dropAllReferences();
266 }
267 
269  const_pred_iterator PI = pred_begin(this), E = pred_end(this);
270  if (PI == E) return nullptr; // No preds.
271  const BasicBlock *ThePred = *PI;
272  ++PI;
273  return (PI == E) ? ThePred : nullptr /*multiple preds*/;
274 }
275 
277  const_pred_iterator PI = pred_begin(this), E = pred_end(this);
278  if (PI == E) return nullptr; // No preds.
279  const BasicBlock *PredBB = *PI;
280  ++PI;
281  for (;PI != E; ++PI) {
282  if (*PI != PredBB)
283  return nullptr;
284  // The same predecessor appears multiple times in the predecessor list.
285  // This is OK.
286  }
287  return PredBB;
288 }
289 
290 bool BasicBlock::hasNPredecessors(unsigned N) const {
291  return hasNItems(pred_begin(this), pred_end(this), N);
292 }
293 
294 bool BasicBlock::hasNPredecessorsOrMore(unsigned N) const {
295  return hasNItemsOrMore(pred_begin(this), pred_end(this), N);
296 }
297 
299  const_succ_iterator SI = succ_begin(this), E = succ_end(this);
300  if (SI == E) return nullptr; // no successors
301  const BasicBlock *TheSucc = *SI;
302  ++SI;
303  return (SI == E) ? TheSucc : nullptr /* multiple successors */;
304 }
305 
307  const_succ_iterator SI = succ_begin(this), E = succ_end(this);
308  if (SI == E) return nullptr; // No successors
309  const BasicBlock *SuccBB = *SI;
310  ++SI;
311  for (;SI != E; ++SI) {
312  if (*SI != SuccBB)
313  return nullptr;
314  // The same successor appears multiple times in the successor list.
315  // This is OK.
316  }
317  return SuccBB;
318 }
319 
321  PHINode *P = empty() ? nullptr : dyn_cast<PHINode>(&*begin());
322  return make_range<phi_iterator>(P, nullptr);
323 }
324 
326  bool KeepOneInputPHIs) {
327  // Use hasNUsesOrMore to bound the cost of this assertion for complex CFGs.
328  assert((hasNUsesOrMore(16) || llvm::is_contained(predecessors(this), Pred)) &&
329  "Pred is not a predecessor!");
330 
331  // Return early if there are no PHI nodes to update.
332  if (empty() || !isa<PHINode>(begin()))
333  return;
334 
335  unsigned NumPreds = cast<PHINode>(front()).getNumIncomingValues();
336  for (PHINode &Phi : make_early_inc_range(phis())) {
337  Phi.removeIncomingValue(Pred, !KeepOneInputPHIs);
338  if (KeepOneInputPHIs)
339  continue;
340 
341  // If we have a single predecessor, removeIncomingValue may have erased the
342  // PHI node itself.
343  if (NumPreds == 1)
344  continue;
345 
346  // Try to replace the PHI node with a constant value.
347  if (Value *PhiConstant = Phi.hasConstantValue()) {
348  Phi.replaceAllUsesWith(PhiConstant);
349  Phi.eraseFromParent();
350  }
351  }
352 }
353 
355  const Instruction *FirstNonPHI = getFirstNonPHI();
356  if (isa<LandingPadInst>(FirstNonPHI))
357  return true;
358  // This is perhaps a little conservative because constructs like
359  // CleanupBlockInst are pretty easy to split. However, SplitBlockPredecessors
360  // cannot handle such things just yet.
361  if (FirstNonPHI->isEHPad())
362  return false;
363  return true;
364 }
365 
367  auto *Term = getTerminator();
368  // No terminator means the block is under construction.
369  if (!Term)
370  return true;
371 
372  // If the block has no successors, there can be no instructions to hoist.
373  assert(Term->getNumSuccessors() > 0);
374 
375  // Instructions should not be hoisted across exception handling boundaries.
376  return !Term->isExceptionalTerminator();
377 }
378 
380  const Function *F = getParent();
381  assert(F && "Block must have a parent function to use this API");
382  return this == &F->getEntryBlock();
383 }
384 
386  bool Before) {
387  if (Before)
388  return splitBasicBlockBefore(I, BBName);
389 
390  assert(getTerminator() && "Can't use splitBasicBlock on degenerate BB!");
391  assert(I != InstList.end() &&
392  "Trying to get me to create degenerate basic block!");
393 
395  this->getNextNode());
396 
397  // Save DebugLoc of split point before invalidating iterator.
398  DebugLoc Loc = I->getDebugLoc();
399  // Move all of the specified instructions from the original basic block into
400  // the new basic block.
401  New->getInstList().splice(New->end(), this->getInstList(), I, end());
402 
403  // Add a branch instruction to the newly formed basic block.
404  BranchInst *BI = BranchInst::Create(New, this);
405  BI->setDebugLoc(Loc);
406 
407  // Now we must loop through all of the successors of the New block (which
408  // _were_ the successors of the 'this' block), and update any PHI nodes in
409  // successors. If there were PHI nodes in the successors, then they need to
410  // know that incoming branches will be from New, not from Old (this).
411  //
412  New->replaceSuccessorsPhiUsesWith(this, New);
413  return New;
414 }
415 
417  assert(getTerminator() &&
418  "Can't use splitBasicBlockBefore on degenerate BB!");
419  assert(I != InstList.end() &&
420  "Trying to get me to create degenerate basic block!");
421 
422  assert((!isa<PHINode>(*I) || getSinglePredecessor()) &&
423  "cannot split on multi incoming phis");
424 
425  BasicBlock *New = BasicBlock::Create(getContext(), BBName, getParent(), this);
426  // Save DebugLoc of split point before invalidating iterator.
427  DebugLoc Loc = I->getDebugLoc();
428  // Move all of the specified instructions from the original basic block into
429  // the new basic block.
430  New->getInstList().splice(New->end(), this->getInstList(), begin(), I);
431 
432  // Loop through all of the predecessors of the 'this' block (which will be the
433  // predecessors of the New block), replace the specified successor 'this'
434  // block to point at the New block and update any PHI nodes in 'this' block.
435  // If there were PHI nodes in 'this' block, the PHI nodes are updated
436  // to reflect that the incoming branches will be from the New block and not
437  // from predecessors of the 'this' block.
438  for (BasicBlock *Pred : predecessors(this)) {
439  Instruction *TI = Pred->getTerminator();
440  TI->replaceSuccessorWith(this, New);
441  this->replacePhiUsesWith(Pred, New);
442  }
443  // Add a branch instruction from "New" to "this" Block.
444  BranchInst *BI = BranchInst::Create(this, New);
445  BI->setDebugLoc(Loc);
446 
447  return New;
448 }
449 
451  // N.B. This might not be a complete BasicBlock, so don't assume
452  // that it ends with a non-phi instruction.
453  for (iterator II = begin(), IE = end(); II != IE; ++II) {
454  PHINode *PN = dyn_cast<PHINode>(II);
455  if (!PN)
456  break;
457  PN->replaceIncomingBlockWith(Old, New);
458  }
459 }
460 
462  BasicBlock *New) {
463  Instruction *TI = getTerminator();
464  if (!TI)
465  // Cope with being called on a BasicBlock that doesn't have a terminator
466  // yet. Clang's CodeGenFunction::EmitReturnBlock() likes to do this.
467  return;
468  for (BasicBlock *Succ : successors(TI))
469  Succ->replacePhiUsesWith(Old, New);
470 }
471 
473  this->replaceSuccessorsPhiUsesWith(this, New);
474 }
475 
477  return isa<LandingPadInst>(getFirstNonPHI());
478 }
479 
481  return dyn_cast<LandingPadInst>(getFirstNonPHI());
482 }
483 
485  const Instruction *TI = getTerminator();
486  if (MDNode *MDIrrLoopHeader =
487  TI->getMetadata(LLVMContext::MD_irr_loop)) {
488  MDString *MDName = cast<MDString>(MDIrrLoopHeader->getOperand(0));
489  if (MDName->getString().equals("loop_header_weight")) {
490  auto *CI = mdconst::extract<ConstantInt>(MDIrrLoopHeader->getOperand(1));
491  return Optional<uint64_t>(CI->getValue().getZExtValue());
492  }
493  }
494  return Optional<uint64_t>();
495 }
496 
498  while (isa<DbgInfoIntrinsic>(It))
499  ++It;
500  return It;
501 }
502 
504  unsigned Order = 0;
505  for (Instruction &I : *this)
506  I.Order = Order++;
507 
508  // Set the bit to indicate that the instruction order valid and cached.
509  BasicBlockBits Bits = getBasicBlockBits();
510  Bits.InstrOrderValid = true;
511  setBasicBlockBits(Bits);
512 
513  NumInstrRenumberings++;
514 }
515 
516 #ifndef NDEBUG
517 /// In asserts builds, this checks the numbering. In non-asserts builds, it
518 /// is defined as a no-op inline function in BasicBlock.h.
520  if (!isInstrOrderValid())
521  return;
522  const Instruction *Prev = nullptr;
523  for (const Instruction &I : *this) {
524  assert((!Prev || Prev->comesBefore(&I)) &&
525  "cached instruction ordering is incorrect");
526  Prev = &I;
527  }
528 }
529 #endif
llvm::SuccIterator
Definition: CFG.h:139
llvm::BasicBlock::getTerminatingDeoptimizeCall
const CallInst * getTerminatingDeoptimizeCall() const
Returns the call instruction calling @llvm.experimental.deoptimize prior to the terminating return in...
Definition: BasicBlock.cpp:189
llvm::BasicBlock::end
iterator end()
Definition: BasicBlock.h:298
llvm::predecessors
pred_range predecessors(BasicBlock *BB)
Definition: CFG.h:127
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::Instruction::replaceSuccessorWith
void replaceSuccessorWith(BasicBlock *OldBB, BasicBlock *NewBB)
Replace specified successor OldBB to point at the provided block.
Definition: Instruction.cpp:801
llvm::ReturnInst
Return a value (possibly void), from a function.
Definition: Instructions.h:2986
llvm::BasicBlock::iterator
InstListType::iterator iterator
Instruction iterators...
Definition: BasicBlock.h:90
llvm::BasicBlock::getParent
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:107
IntrinsicInst.h
llvm::hasNItems
bool hasNItems(IterTy &&Begin, IterTy &&End, unsigned N, Pred &&ShouldBeCounted=[](const decltype(*std::declval< IterTy >()) &) { return true;}, std::enable_if_t< !std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< std::remove_reference_t< decltype(Begin)>>::iterator_category >::value, void > *=nullptr)
Return true if the sequence [Begin, End) has exactly N items.
Definition: STLExtras.h:2050
llvm::Function::getBasicBlockList
const BasicBlockListType & getBasicBlockList() const
Get the underlying elements of the Function...
Definition: Function.h:711
llvm::succ_end
Interval::succ_iterator succ_end(Interval *I)
Definition: Interval.h:102
llvm::Function
Definition: Function.h:62
llvm::BasicBlock::hasNPredecessorsOrMore
bool hasNPredecessorsOrMore(unsigned N) const
Return true if this block has N predecessors or more.
Definition: BasicBlock.cpp:294
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::BasicBlock::instructionsWithoutDebug
iterator_range< filter_iterator< BasicBlock::const_iterator, std::function< bool(const Instruction &)> > > instructionsWithoutDebug(bool SkipPseudoOp=true) const
Return a const iterator range over the instructions in the block, skipping any debug instructions.
Definition: BasicBlock.cpp:104
llvm::ReturnInst::getReturnValue
Value * getReturnValue() const
Convenience accessor. Returns null if there is no return value.
Definition: Instructions.h:3031
llvm::ilist_node_with_parent< BasicBlock, Function >::getNextNode
BasicBlock * getNextNode()
Get the next node, or nullptr for the list tail.
Definition: ilist_node.h:288
Statistic.h
llvm::BasicBlock::empty
bool empty() const
Definition: BasicBlock.h:307
llvm::LandingPadInst
The landingpad instruction holds all of the information necessary to generate correct exception handl...
Definition: Instructions.h:2885
llvm::BasicBlock::replaceSuccessorsPhiUsesWith
void replaceSuccessorsPhiUsesWith(BasicBlock *Old, BasicBlock *New)
Update all phi nodes in this basic block's successors to refer to basic block New instead of basic bl...
Definition: BasicBlock.cpp:461
llvm::BasicBlock::sizeWithoutDebug
filter_iterator< BasicBlock::const_iterator, std::function< bool(const Instruction &)> >::difference_type sizeWithoutDebug() const
Return the size of the basic block ignoring debug instructions.
Definition: BasicBlock.cpp:124
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::filter_iterator_impl
Specialization of filter_iterator_base for forward iteration only.
Definition: STLExtras.h:416
llvm::BasicBlock::eraseFromParent
SymbolTableList< BasicBlock >::iterator eraseFromParent()
Unlink 'this' from the containing function and delete it.
Definition: BasicBlock.cpp:133
llvm::tgtok::Bits
@ Bits
Definition: TGLexer.h:50
llvm::BasicBlock::getSingleSuccessor
const BasicBlock * getSingleSuccessor() const
Return the successor of this block if it has a single successor.
Definition: BasicBlock.cpp:298
llvm::Instruction::comesBefore
bool comesBefore(const Instruction *Other) const
Given an instruction Other in the same basic block as this instruction, return true if this instructi...
Definition: Instruction.cpp:111
llvm::BasicBlock::splitBasicBlock
BasicBlock * splitBasicBlock(iterator I, const Twine &BBName="", bool Before=false)
Split the basic block into two basic blocks at the specified instruction.
Definition: BasicBlock.cpp:385
llvm::Optional< uint64_t >
llvm::SmallPtrSet< const BasicBlock *, 8 >
llvm::BasicBlock::getSinglePredecessor
const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
Definition: BasicBlock.cpp:268
STLExtras.h
llvm::BasicBlock::hasNPredecessors
bool hasNPredecessors(unsigned N) const
Return true if this block has exactly N predecessors.
Definition: BasicBlock.cpp:290
llvm::successors
succ_range successors(Instruction *I)
Definition: CFG.h:262
llvm::BasicBlock::canSplitPredecessors
bool canSplitPredecessors() const
Definition: BasicBlock.cpp:354
llvm::BasicBlock::splitBasicBlockBefore
BasicBlock * splitBasicBlockBefore(iterator I, const Twine &BBName="")
Split the basic block into two basic blocks at the specified instruction and insert the new basic blo...
Definition: BasicBlock.cpp:416
llvm::Type::getInt32Ty
static IntegerType * getInt32Ty(LLVMContext &C)
Definition: Type.cpp:241
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::BasicBlock::getUniqueSuccessor
const BasicBlock * getUniqueSuccessor() const
Return the successor of this block if it has a unique successor.
Definition: BasicBlock.cpp:306
llvm::invalidateParentIListOrdering
void invalidateParentIListOrdering(ParentClass *Parent)
Notify basic blocks when an instruction is inserted.
Definition: SymbolTableListTraitsImpl.h:25
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
Constants.h
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::ConstantExpr::getIntToPtr
static Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:2219
llvm::BasicBlock::begin
iterator begin()
Instruction iterator methods.
Definition: BasicBlock.h:296
llvm::BasicBlock::isLandingPad
bool isLandingPad() const
Return true if this basic block is a landing pad.
Definition: BasicBlock.cpp:476
SymbolTableListTraitsImpl.h
llvm::BasicBlock::getFirstInsertionPt
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:253
llvm::PHINode::replaceIncomingBlockWith
void replaceIncomingBlockWith(const BasicBlock *Old, BasicBlock *New)
Replace every incoming basic block Old to basic block New.
Definition: Instructions.h:2774
llvm::skipDebugIntrinsics
BasicBlock::iterator skipDebugIntrinsics(BasicBlock::iterator It)
Advance It while it points to a debug instruction and return the result.
Definition: BasicBlock.cpp:497
llvm::BasicBlock::getValueSymbolTable
ValueSymbolTable * getValueSymbolTable()
Returns a pointer to the symbol table if one exists.
Definition: BasicBlock.cpp:30
llvm::Instruction
Definition: Instruction.h:45
llvm::BasicBlock::phis
iterator_range< const_phi_iterator > phis() const
Returns a range that iterates over the phis in the basic block.
Definition: BasicBlock.h:354
llvm::STATISTIC
STATISTIC(NumFunctions, "Total number of functions")
llvm::ConstantInt::get
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:925
llvm::hasNItemsOrMore
bool hasNItemsOrMore(IterTy &&Begin, IterTy &&End, unsigned N, Pred &&ShouldBeCounted=[](const decltype(*std::declval< IterTy >()) &) { return true;}, std::enable_if_t< !std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< std::remove_reference_t< decltype(Begin)>>::iterator_category >::value, void > *=nullptr)
Return true if the sequence [Begin, End) has N or more items.
Definition: STLExtras.h:2075
llvm::BasicBlock::getModule
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:148
llvm::BasicBlock::getFirstNonPHI
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
Definition: BasicBlock.cpp:216
llvm::Value::use_empty
bool use_empty() const
Definition: Value.h:345
Type.h
llvm::BasicBlock::getPostdominatingDeoptimizeCall
const CallInst * getPostdominatingDeoptimizeCall() const
Returns the call instruction calling @llvm.experimental.deoptimize that is present either in current ...
Definition: BasicBlock.cpp:204
llvm::BasicBlock::renumberInstructions
void renumberInstructions()
Renumber instructions and mark the ordering as valid.
Definition: BasicBlock.cpp:503
llvm::StringRef::equals
LLVM_NODISCARD bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
Definition: StringRef.h:187
llvm::Instruction::getMetadata
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
Definition: Instruction.h:282
CFG.h
llvm::ARM_PROC::IE
@ IE
Definition: ARMBaseInfo.h:27
llvm::BasicBlock::isEntryBlock
bool isEntryBlock() const
Return true if this is the entry block of the containing function.
Definition: BasicBlock.cpp:379
llvm::Value::user_back
User * user_back()
Definition: Value.h:408
llvm::BasicBlock::hasAddressTaken
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches,...
Definition: BasicBlock.h:448
BasicBlock.h
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::SymbolTableListTraits
Definition: GlobalAlias.h:25
llvm::BasicBlock::removeFromParent
void removeFromParent()
Unlink 'this' from the containing function, but do not delete it.
Definition: BasicBlock.cpp:129
llvm::GlobalValue::getParent
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:578
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
llvm::Value::hasNUsesOrMore
bool hasNUsesOrMore(unsigned N) const
Return true if this value has N uses or more.
Definition: Value.cpp:153
llvm::BasicBlock::isLegalToHoistInto
bool isLegalToHoistInto() const
Return true if it is legal to hoist instructions into this block.
Definition: BasicBlock.cpp:366
llvm::BranchInst::Create
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
Definition: Instructions.h:3124
llvm::BasicBlock::isInstrOrderValid
bool isInstrOrderValid() const
Returns true if the Order field of child Instructions is valid.
Definition: BasicBlock.h:490
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::succ_begin
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:99
llvm::make_early_inc_range
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
Definition: STLExtras.h:576
llvm::is_contained
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
Definition: STLExtras.h:1616
llvm::Instruction::setDebugLoc
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
Definition: Instruction.h:367
llvm::ilist_node_with_parent::getPrevNode
NodeTy * getPrevNode()
Definition: ilist_node.h:274
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SI
StandardInstrumentations SI(Debug, VerifyEach)
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:83
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::MDNode
Metadata node.
Definition: Metadata.h:906
llvm::BasicBlock::~BasicBlock
~BasicBlock()
Definition: BasicBlock.cpp:71
llvm::BlockAddress
The address of a basic block.
Definition: Constants.h:848
llvm::BasicBlock::moveAfter
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:142
this
Analysis the ScalarEvolution expression for r is this
Definition: README.txt:8
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:256
llvm::BasicBlock::getUniquePredecessor
const BasicBlock * getUniquePredecessor() const
Return the predecessor of this block if it has a unique predecessor block.
Definition: BasicBlock.cpp:276
llvm::Value::replaceAllUsesWith
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition: Value.cpp:532
llvm::BasicBlock::Create
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Definition: BasicBlock.h:100
llvm::ilist_node_impl::getIterator
self_iterator getIterator()
Definition: ilist_node.h:81
llvm::BasicBlock::validateInstrOrdering
void validateInstrOrdering() const
Asserts that instruction order numbers are marked invalid, or that they are in ascending order.
Definition: BasicBlock.cpp:519
llvm::PredIterator
Definition: CFG.h:43
llvm::BasicBlock::dropAllReferences
void dropAllReferences()
Cause all subinstructions to "let go" of all the references that said subinstructions are maintaining...
Definition: BasicBlock.cpp:263
llvm::Type::getContext
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition: Type.h:127
llvm::BasicBlock::getTerminator
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:152
llvm::make_filter_range
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:490
llvm::BasicBlock::front
const Instruction & front() const
Definition: BasicBlock.h:308
llvm::BasicBlock::getContext
LLVMContext & getContext() const
Get the context in which this basic block lives.
Definition: BasicBlock.cpp:36
llvm::BasicBlock::replacePhiUsesWith
void replacePhiUsesWith(BasicBlock *Old, BasicBlock *New)
Update all phi nodes in this basic block to refer to basic block New instead of basic block Old.
Definition: BasicBlock.cpp:450
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::ilist_iterator
Iterator for intrusive lists based on ilist_node.
Definition: ilist_iterator.h:57
llvm::pred_end
Interval::pred_iterator pred_end(Interval *I)
Definition: Interval.h:112
llvm::Instruction::isEHPad
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
Definition: Instruction.h:661
llvm::BasicBlock::getFirstNonPHIOrDbgOrLifetime
const Instruction * getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp=true) const
Returns a pointer to the first instruction in this block that is not a PHINode, a debug intrinsic,...
Definition: BasicBlock.cpp:237
llvm::pred_begin
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:109
Instructions.h
llvm::M68kBeads::Term
@ Term
Definition: M68kBaseInfo.h:71
llvm::BasicBlock::moveBefore
void moveBefore(BasicBlock *MovePos)
Unlink this basic block from its current function and insert it into the function that MovePos lives ...
Definition: BasicBlock.cpp:137
llvm::ValueSymbolTable
This class provides a symbol table of name/value pairs.
Definition: ValueSymbolTable.h:37
N
#define N
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition: iterator_range.h:30
llvm::BasicBlock::getFirstNonPHIOrDbg
const Instruction * getFirstNonPHIOrDbg(bool SkipPseudoOp=true) const
Returns a pointer to the first instruction in this block that is not a PHINode or a debug intrinsic,...
Definition: BasicBlock.cpp:223
llvm::PHINode
Definition: Instructions.h:2633
llvm::BasicBlock::removePredecessor
void removePredecessor(BasicBlock *Pred, bool KeepOneInputPHIs=false)
Update PHI nodes in this BasicBlock before removal of predecessor Pred.
Definition: BasicBlock.cpp:325
llvm::BasicBlock::getIrrLoopHeaderWeight
Optional< uint64_t > getIrrLoopHeaderWeight() const
Definition: BasicBlock.cpp:484
llvm::BasicBlock::getLandingPadInst
const LandingPadInst * getLandingPadInst() const
Return the landingpad instruction associated with the landing pad.
Definition: BasicBlock.cpp:480
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition: Instructions.h:1475
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
LLVMContext.h
llvm::DebugLoc
A debug info location.
Definition: DebugLoc.h:33
llvm::User::getOperand
Value * getOperand(unsigned i) const
Definition: User.h:169
llvm::BasicBlock::getTerminatingMustTailCall
const CallInst * getTerminatingMustTailCall() const
Returns the call instruction marked 'musttail' prior to the terminating return instruction of this ba...
Definition: BasicBlock.cpp:158
llvm::MDString::getString
StringRef getString() const
Definition: Metadata.cpp:483
llvm::BranchInst
Conditional or Unconditional Branch instruction.
Definition: Instructions.h:3068
llvm::MDString
A single uniqued string.
Definition: Metadata.h:611
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::Constant::destroyConstant
void destroyConstant()
Called if some element of this constant is no longer valid.
Definition: Constants.cpp:460
llvm::BasicBlock::const_iterator
InstListType::const_iterator const_iterator
Definition: BasicBlock.h:91
llvm::SmallPtrSetImpl::insert
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:364