LLVM  16.0.0git
BasicBlock.h
Go to the documentation of this file.
1 //===- llvm/BasicBlock.h - Represent a basic block in the VM ----*- 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 file contains the declaration of the BasicBlock class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_IR_BASICBLOCK_H
14 #define LLVM_IR_BASICBLOCK_H
15 
16 #include "llvm-c/Types.h"
17 #include "llvm/ADT/Twine.h"
18 #include "llvm/ADT/ilist.h"
19 #include "llvm/ADT/ilist_node.h"
20 #include "llvm/ADT/iterator.h"
22 #include "llvm/IR/Instruction.h"
24 #include "llvm/IR/Value.h"
25 #include <cassert>
26 #include <cstddef>
27 #include <iterator>
28 
29 namespace llvm {
30 
31 class AssemblyAnnotationWriter;
32 class CallInst;
33 class Function;
34 class LandingPadInst;
35 class LLVMContext;
36 class Module;
37 class PHINode;
38 class ValueSymbolTable;
39 
40 /// LLVM Basic Block Representation
41 ///
42 /// This represents a single basic block in LLVM. A basic block is simply a
43 /// container of instructions that execute sequentially. Basic blocks are Values
44 /// because they are referenced by instructions such as branches and switch
45 /// tables. The type of a BasicBlock is "Type::LabelTy" because the basic block
46 /// represents a label to which a branch can jump.
47 ///
48 /// A well formed basic block is formed of a list of non-terminating
49 /// instructions followed by a single terminator instruction. Terminator
50 /// instructions may not occur in the middle of basic blocks, and must terminate
51 /// the blocks. The BasicBlock class allows malformed basic blocks to occur
52 /// because it may be useful in the intermediate stage of constructing or
53 /// modifying a program. However, the verifier will ensure that basic blocks are
54 /// "well formed".
55 class BasicBlock final : public Value, // Basic blocks are data objects also
56  public ilist_node_with_parent<BasicBlock, Function> {
57 public:
59 
60 private:
61  friend class BlockAddress;
63 
64  InstListType InstList;
65  Function *Parent;
66 
67  void setParent(Function *parent);
68 
69  /// Constructor.
70  ///
71  /// If the function parameter is specified, the basic block is automatically
72  /// inserted at either the end of the function (if InsertBefore is null), or
73  /// before the specified basic block.
74  explicit BasicBlock(LLVMContext &C, const Twine &Name = "",
75  Function *Parent = nullptr,
76  BasicBlock *InsertBefore = nullptr);
77 
78 public:
79  BasicBlock(const BasicBlock &) = delete;
80  BasicBlock &operator=(const BasicBlock &) = delete;
81  ~BasicBlock();
82 
83  /// Get the context in which this basic block lives.
84  LLVMContext &getContext() const;
85 
86  /// Instruction iterators...
87  using iterator = InstListType::iterator;
88  using const_iterator = InstListType::const_iterator;
89  using reverse_iterator = InstListType::reverse_iterator;
90  using const_reverse_iterator = InstListType::const_reverse_iterator;
91 
92  /// Creates a new BasicBlock.
93  ///
94  /// If the Parent parameter is specified, the basic block is automatically
95  /// inserted at either the end of the function (if InsertBefore is 0), or
96  /// before the specified basic block.
97  static BasicBlock *Create(LLVMContext &Context, const Twine &Name = "",
98  Function *Parent = nullptr,
99  BasicBlock *InsertBefore = nullptr) {
100  return new BasicBlock(Context, Name, Parent, InsertBefore);
101  }
102 
103  /// Return the enclosing method, or null if none.
104  const Function *getParent() const { return Parent; }
105  Function *getParent() { return Parent; }
106 
107  /// Return the module owning the function this basic block belongs to, or
108  /// nullptr if the function does not have a module.
109  ///
110  /// Note: this is undefined behavior if the block does not have a parent.
111  const Module *getModule() const;
113  return const_cast<Module *>(
114  static_cast<const BasicBlock *>(this)->getModule());
115  }
116 
117  /// Returns the terminator instruction if the block is well formed or null
118  /// if the block is not well formed.
120  if (InstList.empty() || !InstList.back().isTerminator())
121  return nullptr;
122  return &InstList.back();
123  }
125  return const_cast<Instruction *>(
126  static_cast<const BasicBlock *>(this)->getTerminator());
127  }
128 
129  /// Returns the call instruction calling \@llvm.experimental.deoptimize
130  /// prior to the terminating return instruction of this basic block, if such
131  /// a call is present. Otherwise, returns null.
132  const CallInst *getTerminatingDeoptimizeCall() const;
134  return const_cast<CallInst *>(
135  static_cast<const BasicBlock *>(this)->getTerminatingDeoptimizeCall());
136  }
137 
138  /// Returns the call instruction calling \@llvm.experimental.deoptimize
139  /// that is present either in current basic block or in block that is a unique
140  /// successor to current block, if such call is present. Otherwise, returns null.
143  return const_cast<CallInst *>(
144  static_cast<const BasicBlock *>(this)->getPostdominatingDeoptimizeCall());
145  }
146 
147  /// Returns the call instruction marked 'musttail' prior to the terminating
148  /// return instruction of this basic block, if such a call is present.
149  /// Otherwise, returns null.
150  const CallInst *getTerminatingMustTailCall() const;
152  return const_cast<CallInst *>(
153  static_cast<const BasicBlock *>(this)->getTerminatingMustTailCall());
154  }
155 
156  /// Returns a pointer to the first instruction in this block that is not a
157  /// PHINode instruction.
158  ///
159  /// When adding instructions to the beginning of the basic block, they should
160  /// be added before the returned value, not before the first instruction,
161  /// which might be PHI. Returns 0 is there's no non-PHI instruction.
162  const Instruction* getFirstNonPHI() const;
164  return const_cast<Instruction *>(
165  static_cast<const BasicBlock *>(this)->getFirstNonPHI());
166  }
167 
168  /// Returns a pointer to the first instruction in this block that is not a
169  /// PHINode or a debug intrinsic, or any pseudo operation if \c SkipPseudoOp
170  /// is true.
171  const Instruction *getFirstNonPHIOrDbg(bool SkipPseudoOp = true) const;
172  Instruction *getFirstNonPHIOrDbg(bool SkipPseudoOp = true) {
173  return const_cast<Instruction *>(
174  static_cast<const BasicBlock *>(this)->getFirstNonPHIOrDbg(
175  SkipPseudoOp));
176  }
177 
178  /// Returns a pointer to the first instruction in this block that is not a
179  /// PHINode, a debug intrinsic, or a lifetime intrinsic, or any pseudo
180  /// operation if \c SkipPseudoOp is true.
181  const Instruction *
182  getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp = true) const;
183  Instruction *getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp = true) {
184  return const_cast<Instruction *>(
185  static_cast<const BasicBlock *>(this)->getFirstNonPHIOrDbgOrLifetime(
186  SkipPseudoOp));
187  }
188 
189  /// Returns an iterator to the first instruction in this block that is
190  /// suitable for inserting a non-PHI instruction.
191  ///
192  /// In particular, it skips all PHIs and LandingPad instructions.
195  return static_cast<const BasicBlock *>(this)
196  ->getFirstInsertionPt().getNonConst();
197  }
198 
199  /// Returns an iterator to the first instruction in this block that is
200  /// not a PHINode, a debug intrinsic, a static alloca or any pseudo operation.
203  return static_cast<const BasicBlock *>(this)
205  .getNonConst();
206  }
207 
208  /// Return a const iterator range over the instructions in the block, skipping
209  /// any debug instructions. Skip any pseudo operations as well if \c
210  /// SkipPseudoOp is true.
212  std::function<bool(const Instruction &)>>>
213  instructionsWithoutDebug(bool SkipPseudoOp = true) const;
214 
215  /// Return an iterator range over the instructions in the block, skipping any
216  /// debug instructions. Skip and any pseudo operations as well if \c
217  /// SkipPseudoOp is true.
220  instructionsWithoutDebug(bool SkipPseudoOp = true);
221 
222  /// Return the size of the basic block ignoring debug instructions
224  std::function<bool(const Instruction &)>>::difference_type
225  sizeWithoutDebug() const;
226 
227  /// Unlink 'this' from the containing function, but do not delete it.
228  void removeFromParent();
229 
230  /// Unlink 'this' from the containing function and delete it.
231  ///
232  // \returns an iterator pointing to the element after the erased one.
234 
235  /// Unlink this basic block from its current function and insert it into
236  /// the function that \p MovePos lives in, right before \p MovePos.
237  void moveBefore(BasicBlock *MovePos);
238 
239  /// Unlink this basic block from its current function and insert it
240  /// right after \p MovePos in the function \p MovePos lives in.
241  void moveAfter(BasicBlock *MovePos);
242 
243  /// Insert unlinked basic block into a function.
244  ///
245  /// Inserts an unlinked basic block into \c Parent. If \c InsertBefore is
246  /// provided, inserts before that basic block, otherwise inserts at the end.
247  ///
248  /// \pre \a getParent() is \c nullptr.
249  void insertInto(Function *Parent, BasicBlock *InsertBefore = nullptr);
250 
251  /// Return the predecessor of this block if it has a single predecessor
252  /// block. Otherwise return a null pointer.
253  const BasicBlock *getSinglePredecessor() const;
255  return const_cast<BasicBlock *>(
256  static_cast<const BasicBlock *>(this)->getSinglePredecessor());
257  }
258 
259  /// Return the predecessor of this block if it has a unique predecessor
260  /// block. Otherwise return a null pointer.
261  ///
262  /// Note that unique predecessor doesn't mean single edge, there can be
263  /// multiple edges from the unique predecessor to this block (for example a
264  /// switch statement with multiple cases having the same destination).
265  const BasicBlock *getUniquePredecessor() const;
267  return const_cast<BasicBlock *>(
268  static_cast<const BasicBlock *>(this)->getUniquePredecessor());
269  }
270 
271  /// Return true if this block has exactly N predecessors.
272  bool hasNPredecessors(unsigned N) const;
273 
274  /// Return true if this block has N predecessors or more.
275  bool hasNPredecessorsOrMore(unsigned N) const;
276 
277  /// Return the successor of this block if it has a single successor.
278  /// Otherwise return a null pointer.
279  ///
280  /// This method is analogous to getSinglePredecessor above.
281  const BasicBlock *getSingleSuccessor() const;
283  return const_cast<BasicBlock *>(
284  static_cast<const BasicBlock *>(this)->getSingleSuccessor());
285  }
286 
287  /// Return the successor of this block if it has a unique successor.
288  /// Otherwise return a null pointer.
289  ///
290  /// This method is analogous to getUniquePredecessor above.
291  const BasicBlock *getUniqueSuccessor() const;
293  return const_cast<BasicBlock *>(
294  static_cast<const BasicBlock *>(this)->getUniqueSuccessor());
295  }
296 
297  /// Print the basic block to an output stream with an optional
298  /// AssemblyAnnotationWriter.
299  void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW = nullptr,
300  bool ShouldPreserveUseListOrder = false,
301  bool IsForDebug = false) const;
302 
303  //===--------------------------------------------------------------------===//
304  /// Instruction iterator methods
305  ///
306  inline iterator begin() { return InstList.begin(); }
307  inline const_iterator begin() const { return InstList.begin(); }
308  inline iterator end () { return InstList.end(); }
309  inline const_iterator end () const { return InstList.end(); }
310 
311  inline reverse_iterator rbegin() { return InstList.rbegin(); }
312  inline const_reverse_iterator rbegin() const { return InstList.rbegin(); }
313  inline reverse_iterator rend () { return InstList.rend(); }
314  inline const_reverse_iterator rend () const { return InstList.rend(); }
315 
316  inline size_t size() const { return InstList.size(); }
317  inline bool empty() const { return InstList.empty(); }
318  inline const Instruction &front() const { return InstList.front(); }
319  inline Instruction &front() { return InstList.front(); }
320  inline const Instruction &back() const { return InstList.back(); }
321  inline Instruction &back() { return InstList.back(); }
322 
323  /// Iterator to walk just the phi nodes in the basic block.
324  template <typename PHINodeT = PHINode, typename BBIteratorT = iterator>
326  : public iterator_facade_base<phi_iterator_impl<PHINodeT, BBIteratorT>,
327  std::forward_iterator_tag, PHINodeT> {
328  friend BasicBlock;
329 
330  PHINodeT *PN;
331 
332  phi_iterator_impl(PHINodeT *PN) : PN(PN) {}
333 
334  public:
335  // Allow default construction to build variables, but this doesn't build
336  // a useful iterator.
337  phi_iterator_impl() = default;
338 
339  // Allow conversion between instantiations where valid.
340  template <typename PHINodeU, typename BBIteratorU,
341  typename = std::enable_if_t<
342  std::is_convertible<PHINodeU *, PHINodeT *>::value>>
344  : PN(Arg.PN) {}
345 
346  bool operator==(const phi_iterator_impl &Arg) const { return PN == Arg.PN; }
347 
348  PHINodeT &operator*() const { return *PN; }
349 
350  using phi_iterator_impl::iterator_facade_base::operator++;
352  assert(PN && "Cannot increment the end iterator!");
353  PN = dyn_cast<PHINodeT>(std::next(BBIteratorT(PN)));
354  return *this;
355  }
356  };
358  using const_phi_iterator =
360 
361  /// Returns a range that iterates over the phis in the basic block.
362  ///
363  /// Note that this cannot be used with basic blocks that have no terminator.
365  return const_cast<BasicBlock *>(this)->phis();
366  }
368 
369  /// Return the underlying instruction list container.
370  ///
371  /// Currently you need to access the underlying instruction list container
372  /// directly if you want to modify it.
373  const InstListType &getInstList() const { return InstList; }
374  InstListType &getInstList() { return InstList; }
375 
376  /// Returns a pointer to a member of the instruction list.
378  return &BasicBlock::InstList;
379  }
380 
381  /// Returns a pointer to the symbol table if one exists.
383 
384  /// Methods for support type inquiry through isa, cast, and dyn_cast.
385  static bool classof(const Value *V) {
386  return V->getValueID() == Value::BasicBlockVal;
387  }
388 
389  /// Cause all subinstructions to "let go" of all the references that said
390  /// subinstructions are maintaining.
391  ///
392  /// This allows one to 'delete' a whole class at a time, even though there may
393  /// be circular references... first all references are dropped, and all use
394  /// counts go to zero. Then everything is delete'd for real. Note that no
395  /// operations are valid on an object that has "dropped all references",
396  /// except operator delete.
397  void dropAllReferences();
398 
399  /// Update PHI nodes in this BasicBlock before removal of predecessor \p Pred.
400  /// Note that this function does not actually remove the predecessor.
401  ///
402  /// If \p KeepOneInputPHIs is true then don't remove PHIs that are left with
403  /// zero or one incoming values, and don't simplify PHIs with all incoming
404  /// values the same.
405  void removePredecessor(BasicBlock *Pred, bool KeepOneInputPHIs = false);
406 
407  bool canSplitPredecessors() const;
408 
409  /// Split the basic block into two basic blocks at the specified instruction.
410  ///
411  /// If \p Before is true, splitBasicBlockBefore handles the
412  /// block splitting. Otherwise, execution proceeds as described below.
413  ///
414  /// Note that all instructions BEFORE the specified iterator
415  /// stay as part of the original basic block, an unconditional branch is added
416  /// to the original BB, and the rest of the instructions in the BB are moved
417  /// to the new BB, including the old terminator. The newly formed basic block
418  /// is returned. This function invalidates the specified iterator.
419  ///
420  /// Note that this only works on well formed basic blocks (must have a
421  /// terminator), and \p 'I' must not be the end of instruction list (which
422  /// would cause a degenerate basic block to be formed, having a terminator
423  /// inside of the basic block).
424  ///
425  /// Also note that this doesn't preserve any passes. To split blocks while
426  /// keeping loop information consistent, use the SplitBlock utility function.
427  BasicBlock *splitBasicBlock(iterator I, const Twine &BBName = "",
428  bool Before = false);
430  bool Before = false) {
431  return splitBasicBlock(I->getIterator(), BBName, Before);
432  }
433 
434  /// Split the basic block into two basic blocks at the specified instruction
435  /// and insert the new basic blocks as the predecessor of the current block.
436  ///
437  /// This function ensures all instructions AFTER and including the specified
438  /// iterator \p I are part of the original basic block. All Instructions
439  /// BEFORE the iterator \p I are moved to the new BB and an unconditional
440  /// branch is added to the new BB. The new basic block is returned.
441  ///
442  /// Note that this only works on well formed basic blocks (must have a
443  /// terminator), and \p 'I' must not be the end of instruction list (which
444  /// would cause a degenerate basic block to be formed, having a terminator
445  /// inside of the basic block). \p 'I' cannot be a iterator for a PHINode
446  /// with multiple incoming blocks.
447  ///
448  /// Also note that this doesn't preserve any passes. To split blocks while
449  /// keeping loop information consistent, use the SplitBlockBefore utility
450  /// function.
451  BasicBlock *splitBasicBlockBefore(iterator I, const Twine &BBName = "");
453  return splitBasicBlockBefore(I->getIterator(), BBName);
454  }
455 
456  /// Returns true if there are any uses of this basic block other than
457  /// direct branches, switches, etc. to it.
458  bool hasAddressTaken() const {
459  return getBasicBlockBits().BlockAddressRefCount != 0;
460  }
461 
462  /// Update all phi nodes in this basic block to refer to basic block \p New
463  /// instead of basic block \p Old.
464  void replacePhiUsesWith(BasicBlock *Old, BasicBlock *New);
465 
466  /// Update all phi nodes in this basic block's successors to refer to basic
467  /// block \p New instead of basic block \p Old.
469 
470  /// Update all phi nodes in this basic block's successors to refer to basic
471  /// block \p New instead of to it.
473 
474  /// Return true if this basic block is an exception handling block.
475  bool isEHPad() const { return getFirstNonPHI()->isEHPad(); }
476 
477  /// Return true if this basic block is a landing pad.
478  ///
479  /// Being a ``landing pad'' means that the basic block is the destination of
480  /// the 'unwind' edge of an invoke instruction.
481  bool isLandingPad() const;
482 
483  /// Return the landingpad instruction associated with the landing pad.
484  const LandingPadInst *getLandingPadInst() const;
486  return const_cast<LandingPadInst *>(
487  static_cast<const BasicBlock *>(this)->getLandingPadInst());
488  }
489 
490  /// Return true if it is legal to hoist instructions into this block.
491  bool isLegalToHoistInto() const;
492 
493  /// Return true if this is the entry block of the containing function.
494  /// This method can only be used on blocks that have a parent function.
495  bool isEntryBlock() const;
496 
498 
499  /// Returns true if the Order field of child Instructions is valid.
500  bool isInstrOrderValid() const {
501  return getBasicBlockBits().InstrOrderValid;
502  }
503 
504  /// Mark instruction ordering invalid. Done on every instruction insert.
507  BasicBlockBits Bits = getBasicBlockBits();
508  Bits.InstrOrderValid = false;
509  setBasicBlockBits(Bits);
510  }
511 
512  /// Renumber instructions and mark the ordering as valid.
513  void renumberInstructions();
514 
515  /// Asserts that instruction order numbers are marked invalid, or that they
516  /// are in ascending order. This is constant time if the ordering is invalid,
517  /// and linear in the number of instructions if the ordering is valid. Callers
518  /// should be careful not to call this in ways that make common operations
519  /// O(n^2). For example, it takes O(n) time to assign order numbers to
520  /// instructions, so the order should be validated no more than once after
521  /// each ordering to ensure that transforms have the same algorithmic
522  /// complexity when asserts are enabled as when they are disabled.
523  void validateInstrOrdering() const;
524 
525 private:
526 #if defined(_AIX) && (!defined(__GNUC__) || defined(__clang__))
527 // Except for GCC; by default, AIX compilers store bit-fields in 4-byte words
528 // and give the `pack` pragma push semantics.
529 #define BEGIN_TWO_BYTE_PACK() _Pragma("pack(2)")
530 #define END_TWO_BYTE_PACK() _Pragma("pack(pop)")
531 #else
532 #define BEGIN_TWO_BYTE_PACK()
533 #define END_TWO_BYTE_PACK()
534 #endif
535 
537  /// Bitfield to help interpret the bits in Value::SubclassData.
538  struct BasicBlockBits {
539  unsigned short BlockAddressRefCount : 15;
540  unsigned short InstrOrderValid : 1;
541  };
543 
544 #undef BEGIN_TWO_BYTE_PACK
545 #undef END_TWO_BYTE_PACK
546 
547  /// Safely reinterpret the subclass data bits to a more useful form.
548  BasicBlockBits getBasicBlockBits() const {
549  static_assert(sizeof(BasicBlockBits) == sizeof(unsigned short),
550  "too many bits for Value::SubclassData");
551  unsigned short ValueData = getSubclassDataFromValue();
552  BasicBlockBits AsBits;
553  memcpy(&AsBits, &ValueData, sizeof(AsBits));
554  return AsBits;
555  }
556 
557  /// Reinterpret our subclass bits and store them back into Value.
558  void setBasicBlockBits(BasicBlockBits AsBits) {
559  unsigned short D;
560  memcpy(&D, &AsBits, sizeof(D));
562  }
563 
564  /// Increment the internal refcount of the number of BlockAddresses
565  /// referencing this BasicBlock by \p Amt.
566  ///
567  /// This is almost always 0, sometimes one possibly, but almost never 2, and
568  /// inconceivably 3 or more.
569  void AdjustBlockAddressRefCount(int Amt) {
570  BasicBlockBits Bits = getBasicBlockBits();
571  Bits.BlockAddressRefCount += Amt;
572  setBasicBlockBits(Bits);
573  assert(Bits.BlockAddressRefCount < 255 && "Refcount wrap-around");
574  }
575 
576  /// Shadow Value::setValueSubclassData with a private forwarding method so
577  /// that any future subclasses cannot accidentally use it.
578  void setValueSubclassData(unsigned short D) {
580  }
581 };
582 
583 // Create wrappers for C Binding types (see CBindingWrapping.h).
585 
586 /// Advance \p It while it points to a debug instruction and return the result.
587 /// This assumes that \p It is not at the end of a block.
589 
590 #ifdef NDEBUG
591 /// In release builds, this is a no-op. For !NDEBUG builds, the checks are
592 /// implemented in the .cpp file to avoid circular header deps.
593 inline void BasicBlock::validateInstrOrdering() const {}
594 #endif
595 
596 } // end namespace llvm
597 
598 #endif // LLVM_IR_BASICBLOCK_H
llvm::BasicBlock::getTerminatingDeoptimizeCall
const CallInst * getTerminatingDeoptimizeCall() const
Returns the call instruction calling @llvm.experimental.deoptimize prior to the terminating return in...
Definition: BasicBlock.cpp:182
llvm::BasicBlock::getSublistAccess
static InstListType BasicBlock::* getSublistAccess(Instruction *)
Returns a pointer to a member of the instruction list.
Definition: BasicBlock.h:377
const_iterator
llvm::BasicBlock::end
iterator end()
Definition: BasicBlock.h:308
llvm::BasicBlock::print
void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW=nullptr, bool ShouldPreserveUseListOrder=false, bool IsForDebug=false) const
Print the basic block to an output stream with an optional AssemblyAnnotationWriter.
Definition: AsmWriter.cpp:4500
LLVM_READONLY
#define LLVM_READONLY
Definition: Compiler.h:196
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::BasicBlock::begin
const_iterator begin() const
Definition: BasicBlock.h:307
llvm::BasicBlock::getSingleSuccessor
BasicBlock * getSingleSuccessor()
Definition: BasicBlock.h:282
llvm::BasicBlock::iterator
InstListType::iterator iterator
Instruction iterators...
Definition: BasicBlock.h:87
llvm::BasicBlock::getParent
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:104
llvm::Function
Definition: Function.h:60
llvm::BasicBlock::getFirstNonPHIOrDbgOrLifetime
Instruction * getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp=true)
Definition: BasicBlock.h:183
llvm::Value::getSubclassDataFromValue
unsigned short getSubclassDataFromValue() const
Definition: Value.h:852
llvm::BasicBlock::hasNPredecessorsOrMore
bool hasNPredecessorsOrMore(unsigned N) const
Return true if this block has N predecessors or more.
Definition: BasicBlock.cpp:311
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:103
ilist.h
llvm::BasicBlock::empty
bool empty() const
Definition: BasicBlock.h:317
Types.h
llvm::LandingPadInst
The landingpad instruction holds all of the information necessary to generate correct exception handl...
Definition: Instructions.h:2951
llvm::BasicBlock::getFirstNonPHIOrDbg
Instruction * getFirstNonPHIOrDbg(bool SkipPseudoOp=true)
Definition: BasicBlock.h:172
llvm::ilist_node_with_parent
An ilist node that can access its parent list.
Definition: ilist_node.h:257
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:478
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:123
llvm::BasicBlock::getFirstNonPHIOrDbgOrAlloca
iterator getFirstNonPHIOrDbgOrAlloca()
Definition: BasicBlock.h:202
llvm::filter_iterator_impl
Specialization of filter_iterator_base for forward iteration only.
Definition: STLExtras.h:440
llvm::BasicBlock::eraseFromParent
SymbolTableList< BasicBlock >::iterator eraseFromParent()
Unlink 'this' from the containing function and delete it.
Definition: BasicBlock.cpp:132
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:315
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:402
llvm::Optional< uint64_t >
llvm::BasicBlock::getSinglePredecessor
const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
Definition: BasicBlock.cpp:285
llvm::BasicBlock::hasNPredecessors
bool hasNPredecessors(unsigned N) const
Return true if this block has exactly N predecessors.
Definition: BasicBlock.cpp:307
llvm::Value::setValueSubclassData
void setValueSubclassData(unsigned short D)
Definition: Value.h:853
llvm::BasicBlock::canSplitPredecessors
bool canSplitPredecessors() const
Definition: BasicBlock.cpp:371
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:433
llvm::BasicBlock::getPostdominatingDeoptimizeCall
CallInst * getPostdominatingDeoptimizeCall()
Definition: BasicBlock.h:142
llvm::BasicBlock::rend
reverse_iterator rend()
Definition: BasicBlock.h:313
llvm::BasicBlock::getUniqueSuccessor
BasicBlock * getUniqueSuccessor()
Definition: BasicBlock.h:292
llvm::BasicBlock::getUniqueSuccessor
const BasicBlock * getUniqueSuccessor() const
Return the successor of this block if it has a unique successor.
Definition: BasicBlock.cpp:323
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:55
DEFINE_SIMPLE_CONVERSION_FUNCTIONS
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
Definition: CBindingWrapping.h:19
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::BasicBlock::invalidateOrders
void invalidateOrders()
Mark instruction ordering invalid. Done on every instruction insert.
Definition: BasicBlock.h:505
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:187
Instruction.h
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
Twine.h
llvm::BasicBlock::begin
iterator begin()
Instruction iterator methods.
Definition: BasicBlock.h:306
llvm::BasicBlock::isLandingPad
bool isLandingPad() const
Return true if this basic block is a landing pad.
Definition: BasicBlock.cpp:493
LLVMBasicBlockRef
struct LLVMOpaqueBasicBlock * LLVMBasicBlockRef
Represents a basic block of instructions in LLVM IR.
Definition: Types.h:82
llvm::BasicBlock::back
Instruction & back()
Definition: BasicBlock.h:321
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:246
llvm::Value::getValueID
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition: Value.h:532
END_TWO_BYTE_PACK
#define END_TWO_BYTE_PACK()
Definition: BasicBlock.h:533
llvm::skipDebugIntrinsics
BasicBlock::iterator skipDebugIntrinsics(BasicBlock::iterator It)
Advance It while it points to a debug instruction and return the result.
Definition: BasicBlock.cpp:514
llvm::BasicBlock::getValueSymbolTable
ValueSymbolTable * getValueSymbolTable()
Returns a pointer to the symbol table if one exists.
Definition: BasicBlock.cpp:29
llvm::Instruction
Definition: Instruction.h:42
llvm::BasicBlock::phi_iterator_impl::operator*
PHINodeT & operator*() const
Definition: BasicBlock.h:348
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:364
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
llvm::BasicBlock::getLandingPadInst
LandingPadInst * getLandingPadInst()
Definition: BasicBlock.h:485
llvm::BasicBlock::rbegin
reverse_iterator rbegin()
Definition: BasicBlock.h:311
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:147
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:209
llvm::BasicBlock::getPostdominatingDeoptimizeCall
const CallInst * getPostdominatingDeoptimizeCall() const
Returns the call instruction calling @llvm.experimental.deoptimize that is present either in current ...
Definition: BasicBlock.cpp:197
llvm::BasicBlock::renumberInstructions
void renumberInstructions()
Renumber instructions and mark the ordering as valid.
Definition: BasicBlock.cpp:520
llvm::BasicBlock::isEntryBlock
bool isEntryBlock() const
Return true if this is the entry block of the containing function.
Definition: BasicBlock.cpp:396
llvm::BasicBlock::hasAddressTaken
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches,...
Definition: BasicBlock.h:458
llvm::SymbolTableListTraits
Definition: GlobalAlias.h:26
llvm::BasicBlock::removeFromParent
void removeFromParent()
Unlink 'this' from the containing function, but do not delete it.
Definition: BasicBlock.cpp:128
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
llvm::BasicBlock::front
Instruction & front()
Definition: BasicBlock.h:319
const
aarch64 promote const
Definition: AArch64PromoteConstant.cpp:232
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
llvm::BasicBlock::isLegalToHoistInto
bool isLegalToHoistInto() const
Return true if it is legal to hoist instructions into this block.
Definition: BasicBlock.cpp:383
llvm::BasicBlock::rend
const_reverse_iterator rend() const
Definition: BasicBlock.h:314
llvm::BasicBlock::isInstrOrderValid
bool isInstrOrderValid() const
Returns true if the Order field of child Instructions is valid.
Definition: BasicBlock.h:500
iterator.h
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::iterator_facade_base
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition: iterator.h:80
llvm::BasicBlock::phi_iterator_impl::phi_iterator_impl
phi_iterator_impl(const phi_iterator_impl< PHINodeU, BBIteratorU > &Arg)
Definition: BasicBlock.h:343
llvm::BasicBlock::operator=
BasicBlock & operator=(const BasicBlock &)=delete
llvm::BasicBlock::phi_iterator_impl::operator++
phi_iterator_impl & operator++()
Definition: BasicBlock.h:351
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
memcpy
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
iterator_range.h
llvm::ISD::BasicBlock
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:82
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::BasicBlock::~BasicBlock
~BasicBlock()
Definition: BasicBlock.cpp:70
llvm::BasicBlock::classof
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast.
Definition: BasicBlock.h:385
llvm::BasicBlock::rbegin
const_reverse_iterator rbegin() const
Definition: BasicBlock.h:312
llvm::BasicBlock::getTerminatingMustTailCall
CallInst * getTerminatingMustTailCall()
Definition: BasicBlock.h:151
llvm::BlockAddress
The address of a basic block.
Definition: Constants.h:849
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:141
llvm::BasicBlock::getUniquePredecessor
BasicBlock * getUniquePredecessor()
Definition: BasicBlock.h:266
llvm::SymbolTableList< Instruction >
llvm::BasicBlock::getUniquePredecessor
const BasicBlock * getUniquePredecessor() const
Return the predecessor of this block if it has a unique predecessor block.
Definition: BasicBlock.cpp:293
llvm::BasicBlock::Create
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Definition: BasicBlock.h:97
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::BasicBlock::validateInstrOrdering
void validateInstrOrdering() const
Asserts that instruction order numbers are marked invalid, or that they are in ascending order.
Definition: BasicBlock.cpp:536
llvm::BasicBlock::dropAllReferences
void dropAllReferences()
Cause all subinstructions to "let go" of all the references that said subinstructions are maintaining...
Definition: BasicBlock.cpp:280
llvm::BasicBlock::const_reverse_iterator
InstListType::const_reverse_iterator const_reverse_iterator
Definition: BasicBlock.h:90
llvm::BasicBlock::front
const Instruction & front() const
Definition: BasicBlock.h:318
llvm::BasicBlock::phi_iterator_impl::phi_iterator_impl
phi_iterator_impl()=default
llvm::BasicBlock::getContext
LLVMContext & getContext() const
Get the context in which this basic block lives.
Definition: BasicBlock.cpp:35
llvm::BasicBlock::getTerminator
Instruction * getTerminator()
Definition: BasicBlock.h:124
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:467
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
llvm::BasicBlock::getSinglePredecessor
BasicBlock * getSinglePredecessor()
Definition: BasicBlock.h:254
llvm::BasicBlock::phi_iterator_impl
Iterator to walk just the phi nodes in the basic block.
Definition: BasicBlock.h:325
llvm::BasicBlock::getFirstNonPHI
Instruction * getFirstNonPHI()
Definition: BasicBlock.h:163
llvm::AssemblyAnnotationWriter
Definition: AssemblyAnnotationWriter.h:27
llvm::BasicBlock::getInstList
InstListType & getInstList()
Definition: BasicBlock.h:374
llvm::Instruction::isEHPad
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
Definition: Instruction.h:649
llvm::BasicBlock::insertInto
void insertInto(Function *Parent, BasicBlock *InsertBefore=nullptr)
Insert unlinked basic block into a function.
Definition: BasicBlock.cpp:60
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:230
llvm::BasicBlock::back
const Instruction & back() const
Definition: BasicBlock.h:320
llvm::BasicBlock::getInstList
const InstListType & getInstList() const
Return the underlying instruction list container.
Definition: BasicBlock.h:373
llvm::BasicBlock::reverse_iterator
InstListType::reverse_iterator reverse_iterator
Definition: BasicBlock.h:89
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:136
llvm::ValueSymbolTable
This class provides a symbol table of name/value pairs.
Definition: ValueSymbolTable.h:37
N
#define N
llvm::BasicBlock::getModule
Module * getModule()
Definition: BasicBlock.h:112
llvm::BasicBlock::size
size_t size() const
Definition: BasicBlock.h:316
llvm::BasicBlock::phi_iterator_impl::operator==
bool operator==(const phi_iterator_impl &Arg) const
Definition: BasicBlock.h:346
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:216
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.h:119
llvm::BasicBlock::removePredecessor
void removePredecessor(BasicBlock *Pred, bool KeepOneInputPHIs=false)
Update PHI nodes in this BasicBlock before removal of predecessor Pred.
Definition: BasicBlock.cpp:342
ilist_node.h
llvm::BasicBlock::splitBasicBlock
BasicBlock * splitBasicBlock(Instruction *I, const Twine &BBName="", bool Before=false)
Definition: BasicBlock.h:429
BEGIN_TWO_BYTE_PACK
#define BEGIN_TWO_BYTE_PACK()
Definition: BasicBlock.h:532
llvm::BasicBlock::getIrrLoopHeaderWeight
Optional< uint64_t > getIrrLoopHeaderWeight() const
Definition: BasicBlock.cpp:501
llvm::BasicBlock::getLandingPadInst
const LandingPadInst * getLandingPadInst() const
Return the landingpad instruction associated with the landing pad.
Definition: BasicBlock.cpp:497
llvm::BasicBlock::splitBasicBlockBefore
BasicBlock * splitBasicBlockBefore(Instruction *I, const Twine &BBName="")
Definition: BasicBlock.h:452
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition: Instructions.h:1474
llvm::BasicBlock::getFirstInsertionPt
iterator getFirstInsertionPt()
Definition: BasicBlock.h:194
llvm::BasicBlock::getTerminatingDeoptimizeCall
CallInst * getTerminatingDeoptimizeCall()
Definition: BasicBlock.h:133
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:151
SymbolTableListTraits.h
Value.h
llvm::BasicBlock::getFirstNonPHIOrDbgOrAlloca
const_iterator getFirstNonPHIOrDbgOrAlloca() const
Returns an iterator to the first instruction in this block that is not a PHINode, a debug intrinsic,...
Definition: BasicBlock.cpp:256
llvm::BasicBlock::isEHPad
bool isEHPad() const
Return true if this basic block is an exception handling block.
Definition: BasicBlock.h:475
llvm::BasicBlock::end
const_iterator end() const
Definition: BasicBlock.h:309
llvm::BasicBlock::getParent
Function * getParent()
Definition: BasicBlock.h:105
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::codeview::PublicSymFlags::Function
@ Function
llvm::BasicBlock::const_iterator
InstListType::const_iterator const_iterator
Definition: BasicBlock.h:88