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