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