Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.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/DenseMap.h"
18#include "llvm/ADT/Twine.h"
19#include "llvm/ADT/ilist.h"
20#include "llvm/ADT/ilist_node.h"
21#include "llvm/ADT/iterator.h"
22#include "llvm/ADT/iterator_range.h"
23#include "llvm/IR/DebugProgramInstruction.h"
24#include "llvm/IR/Instruction.h"
25#include "llvm/IR/SymbolTableListTraits.h"
26#include "llvm/IR/Value.h"
27#include <cassert>
28#include <cstddef>
29#include <iterator>
30
31namespacellvm {
32
33classAssemblyAnnotationWriter;
34classCallInst;
35classDataLayout;
36classFunction;
37classLandingPadInst;
38classLLVMContext;
39classModule;
40classPHINode;
41classValueSymbolTable;
42classDbgVariableRecord;
43classDbgMarker;
44
45/// LLVM Basic Block Representation
46///
47/// This represents a single basic block in LLVM. A basic block is simply a
48/// container of instructions that execute sequentially. Basic blocks are Values
49/// because they are referenced by instructions such as branches and switch
50/// tables. The type of a BasicBlock is "Type::LabelTy" because the basic block
51/// represents a label to which a branch can jump.
52///
53/// A well formed basic block is formed of a list of non-terminating
54/// instructions followed by a single terminator instruction. Terminator
55/// instructions may not occur in the middle of basic blocks, and must terminate
56/// the blocks. The BasicBlock class allows malformed basic blocks to occur
57/// because it may be useful in the intermediate stage of constructing or
58/// modifying a program. However, the verifier will ensure that basic blocks are
59/// "well formed".
60classBasicBlock final :publicValue,// Basic blocks are data objects also
61publicilist_node_with_parent<BasicBlock, Function> {
62public:
63usingInstListType =SymbolTableList<Instruction, ilist_iterator_bits<true>,
64ilist_parent<BasicBlock>>;
65 /// Flag recording whether or not this block stores debug-info in the form
66 /// of intrinsic instructions (false) or non-instruction records (true).
67boolIsNewDbgInfoFormat;
68
69private:
70// Allow Function to renumber blocks.
71friendclassFunction;
72 /// Per-function unique number.
73unsignedNumber = -1u;
74
75friendclassBlockAddress;
76friendclassSymbolTableListTraits<BasicBlock>;
77
78InstListType InstList;
79Function *Parent;
80
81public:
82 /// Attach a DbgMarker to the given instruction. Enables the storage of any
83 /// debug-info at this position in the program.
84DbgMarker *createMarker(Instruction *I);
85DbgMarker *createMarker(InstListType::iterator It);
86
87 /// Convert variable location debugging information stored in dbg.value
88 /// intrinsics into DbgMarkers / DbgRecords. Deletes all dbg.values in
89 /// the process and sets IsNewDbgInfoFormat = true. Only takes effect if
90 /// the UseNewDbgInfoFormat LLVM command line option is given.
91voidconvertToNewDbgValues();
92
93 /// Convert variable location debugging information stored in DbgMarkers and
94 /// DbgRecords into the dbg.value intrinsic representation. Sets
95 /// IsNewDbgInfoFormat = false.
96voidconvertFromNewDbgValues();
97
98 /// Ensure the block is in "old" dbg.value format (\p NewFlag == false) or
99 /// in the new format (\p NewFlag == true), converting to the desired format
100 /// if necessary.
101voidsetIsNewDbgInfoFormat(bool NewFlag);
102voidsetNewDbgInfoFormatFlag(bool NewFlag);
103
104unsignedgetNumber() const{
105assert(getParent() &&"only basic blocks in functions have valid numbers");
106returnNumber;
107 }
108
109 /// Record that the collection of DbgRecords in \p M "trails" after the last
110 /// instruction of this block. These are equivalent to dbg.value intrinsics
111 /// that exist at the end of a basic block with no terminator (a transient
112 /// state that occurs regularly).
113voidsetTrailingDbgRecords(DbgMarker *M);
114
115 /// Fetch the collection of DbgRecords that "trail" after the last instruction
116 /// of this block, see \ref setTrailingDbgRecords. If there are none, returns
117 /// nullptr.
118DbgMarker *getTrailingDbgRecords();
119
120 /// Delete any trailing DbgRecords at the end of this block, see
121 /// \ref setTrailingDbgRecords.
122voiddeleteTrailingDbgRecords();
123
124voiddumpDbgValues()const;
125
126 /// Return the DbgMarker for the position given by \p It, so that DbgRecords
127 /// can be inserted there. This will either be nullptr if not present, a
128 /// DbgMarker, or TrailingDbgRecords if It is end().
129DbgMarker *getMarker(InstListType::iterator It);
130
131 /// Return the DbgMarker for the position that comes after \p I. \see
132 /// BasicBlock::getMarker, this can be nullptr, a DbgMarker, or
133 /// TrailingDbgRecords if there is no next instruction.
134DbgMarker *getNextMarker(Instruction *I);
135
136 /// Insert a DbgRecord into a block at the position given by \p I.
137voidinsertDbgRecordAfter(DbgRecord *DR,Instruction *I);
138
139 /// Insert a DbgRecord into a block at the position given by \p Here.
140voidinsertDbgRecordBefore(DbgRecord *DR,InstListType::iterator Here);
141
142 /// Eject any debug-info trailing at the end of a block. DbgRecords can
143 /// transiently be located "off the end" of a block if the blocks terminator
144 /// is temporarily removed. Once a terminator is re-inserted this method will
145 /// move such DbgRecords back to the right place (ahead of the terminator).
146voidflushTerminatorDbgRecords();
147
148 /// In rare circumstances instructions can be speculatively removed from
149 /// blocks, and then be re-inserted back into that position later. When this
150 /// happens in RemoveDIs debug-info mode, some special patching-up needs to
151 /// occur: inserting into the middle of a sequence of dbg.value intrinsics
152 /// does not have an equivalent with DbgRecords.
153voidreinsertInstInDbgRecords(Instruction *I,
154 std::optional<DbgRecord::self_iterator> Pos);
155
156private:
157void setParent(Function *parent);
158
159 /// Constructor.
160 ///
161 /// If the function parameter is specified, the basic block is automatically
162 /// inserted at either the end of the function (if InsertBefore is null), or
163 /// before the specified basic block.
164explicitBasicBlock(LLVMContext &C,constTwine &Name ="",
165Function *Parent =nullptr,
166BasicBlock *InsertBefore =nullptr);
167
168public:
169BasicBlock(constBasicBlock &) =delete;
170BasicBlock &operator=(constBasicBlock &) =delete;
171~BasicBlock();
172
173 /// Get the context in which this basic block lives.
174LLVMContext &getContext()const;
175
176 /// Instruction iterators...
177usingiterator =InstListType::iterator;
178usingconst_iterator =InstListType::const_iterator;
179usingreverse_iterator =InstListType::reverse_iterator;
180usingconst_reverse_iterator =InstListType::const_reverse_iterator;
181
182// These functions and classes need access to the instruction list.
183friendvoidInstruction::removeFromParent();
184friendBasicBlock::iteratorInstruction::eraseFromParent();
185friendBasicBlock::iteratorInstruction::insertInto(BasicBlock *BB,
186BasicBlock::iterator It);
187friendclassllvm::SymbolTableListTraits<
188llvm::Instruction,ilist_iterator_bits<true>,ilist_parent<BasicBlock>>;
189 friend classllvm::ilist_node_with_parent<llvm::Instruction, llvm::BasicBlock,
190 ilist_iterator_bits<true>,
191 ilist_parent<BasicBlock>>;
192
193// Friendly methods that need to access us for the maintenence of
194// debug-info attachments.
195 friend voidInstruction::insertBefore(BasicBlock::iterator InsertPos);
196 friend voidInstruction::insertAfter(Instruction *InsertPos);
197 friend voidInstruction::insertAfter(BasicBlock::iterator InsertPos);
198 friend voidInstruction::insertBefore(BasicBlock &BB,
199 InstListType::iterator InsertPos);
200 friend voidInstruction::moveBeforeImpl(BasicBlock &BB,
201 InstListType::iterator I,
202 bool Preserve);
203 frienditerator_range<DbgRecord::self_iterator>
204Instruction::cloneDebugInfoFrom(
205 const Instruction *From, std::optional<DbgRecord::self_iterator> FromHere,
206 bool InsertAtHead);
207
208 /// Creates a new BasicBlock.
209 ///
210 /// If the Parent parameter is specified, the basic block is automatically
211 /// inserted at either the end of the function (if InsertBefore is 0), or
212 /// before the specified basic block.
213 staticBasicBlock *Create(LLVMContext &Context, const Twine &Name = "",
214 Function *Parent = nullptr,
215 BasicBlock *InsertBefore = nullptr) {
216returnnewBasicBlock(Context,Name, Parent, InsertBefore);
217 }
218
219 /// Return the enclosing method, or null if none.
220constFunction *getParent() const{return Parent; }
221Function *getParent() {return Parent; }
222
223 /// Return the module owning the function this basic block belongs to, or
224 /// nullptr if the function does not have a module.
225 ///
226 /// Note: this is undefined behavior if the block does not have a parent.
227constModule *getModule()const;
228Module *getModule() {
229returnconst_cast<Module *>(
230static_cast<constBasicBlock *>(this)->getModule());
231 }
232
233 /// Get the data layout of the module this basic block belongs to.
234 ///
235 /// Requires the basic block to have a parent module.
236constDataLayout &getDataLayout()const;
237
238 /// Returns the terminator instruction if the block is well formed or null
239 /// if the block is not well formed.
240constInstruction *getTerminator()constLLVM_READONLY {
241if (InstList.empty() || !InstList.back().isTerminator())
242returnnullptr;
243return &InstList.back();
244 }
245Instruction *getTerminator() {
246returnconst_cast<Instruction *>(
247static_cast<constBasicBlock *>(this)->getTerminator());
248 }
249
250 /// Returns the call instruction calling \@llvm.experimental.deoptimize
251 /// prior to the terminating return instruction of this basic block, if such
252 /// a call is present. Otherwise, returns null.
253constCallInst *getTerminatingDeoptimizeCall()const;
254CallInst *getTerminatingDeoptimizeCall() {
255returnconst_cast<CallInst *>(
256static_cast<constBasicBlock *>(this)->getTerminatingDeoptimizeCall());
257 }
258
259 /// Returns the call instruction calling \@llvm.experimental.deoptimize
260 /// that is present either in current basic block or in block that is a unique
261 /// successor to current block, if such call is present. Otherwise, returns null.
262constCallInst *getPostdominatingDeoptimizeCall()const;
263CallInst *getPostdominatingDeoptimizeCall() {
264returnconst_cast<CallInst *>(
265static_cast<constBasicBlock *>(this)->getPostdominatingDeoptimizeCall());
266 }
267
268 /// Returns the call instruction marked 'musttail' prior to the terminating
269 /// return instruction of this basic block, if such a call is present.
270 /// Otherwise, returns null.
271constCallInst *getTerminatingMustTailCall()const;
272CallInst *getTerminatingMustTailCall() {
273returnconst_cast<CallInst *>(
274static_cast<constBasicBlock *>(this)->getTerminatingMustTailCall());
275 }
276
277 /// Returns a pointer to the first instruction in this block that is not a
278 /// PHINode instruction.
279 ///
280 /// When adding instructions to the beginning of the basic block, they should
281 /// be added before the returned value, not before the first instruction,
282 /// which might be PHI. Returns 0 is there's no non-PHI instruction.
283constInstruction*getFirstNonPHI()const;
284Instruction*getFirstNonPHI() {
285returnconst_cast<Instruction *>(
286static_cast<constBasicBlock *>(this)->getFirstNonPHI());
287 }
288
289 /// Iterator returning form of getFirstNonPHI. Installed as a placeholder for
290 /// the RemoveDIs project that will eventually remove debug intrinsics.
291InstListType::const_iteratorgetFirstNonPHIIt()const;
292InstListType::iteratorgetFirstNonPHIIt() {
293BasicBlock::iterator It =
294static_cast<constBasicBlock *>(this)->getFirstNonPHIIt().getNonConst();
295 It.setHeadBit(true);
296return It;
297 }
298
299 /// Returns a pointer to the first instruction in this block that is not a
300 /// PHINode or a debug intrinsic, or any pseudo operation if \c SkipPseudoOp
301 /// is true.
302InstListType::const_iterator
303getFirstNonPHIOrDbg(bool SkipPseudoOp =true)const;
304InstListType::iteratorgetFirstNonPHIOrDbg(bool SkipPseudoOp =true) {
305returnstatic_cast<constBasicBlock *>(this)
306 ->getFirstNonPHIOrDbg(SkipPseudoOp)
307 .getNonConst();
308 }
309
310 /// Returns a pointer to the first instruction in this block that is not a
311 /// PHINode, a debug intrinsic, or a lifetime intrinsic, or any pseudo
312 /// operation if \c SkipPseudoOp is true.
313InstListType::const_iterator
314getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp =true)const;
315InstListType::iterator
316getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp =true) {
317returnstatic_cast<constBasicBlock *>(this)
318 ->getFirstNonPHIOrDbgOrLifetime(SkipPseudoOp)
319 .getNonConst();
320 }
321
322 /// Returns an iterator to the first instruction in this block that is
323 /// suitable for inserting a non-PHI instruction.
324 ///
325 /// In particular, it skips all PHIs and LandingPad instructions.
326const_iteratorgetFirstInsertionPt()const;
327iteratorgetFirstInsertionPt() {
328returnstatic_cast<constBasicBlock *>(this)
329 ->getFirstInsertionPt().getNonConst();
330 }
331
332 /// Returns an iterator to the first instruction in this block that is
333 /// not a PHINode, a debug intrinsic, a static alloca or any pseudo operation.
334const_iteratorgetFirstNonPHIOrDbgOrAlloca()const;
335iteratorgetFirstNonPHIOrDbgOrAlloca() {
336returnstatic_cast<constBasicBlock *>(this)
337 ->getFirstNonPHIOrDbgOrAlloca()
338 .getNonConst();
339 }
340
341 /// Returns the first potential AsynchEH faulty instruction
342 /// currently it checks for loads/stores (which may dereference a null
343 /// pointer) and calls/invokes (which may propagate exceptions)
344constInstruction*getFirstMayFaultInst()const;
345Instruction*getFirstMayFaultInst() {
346returnconst_cast<Instruction*>(
347static_cast<constBasicBlock*>(this)->getFirstMayFaultInst());
348 }
349
350 /// Return a const iterator range over the instructions in the block, skipping
351 /// any debug instructions. Skip any pseudo operations as well if \c
352 /// SkipPseudoOp is true.
353iterator_range<filter_iterator<BasicBlock::const_iterator,
354 std::function<bool(constInstruction &)>>>
355instructionsWithoutDebug(bool SkipPseudoOp =true)const;
356
357 /// Return an iterator range over the instructions in the block, skipping any
358 /// debug instructions. Skip and any pseudo operations as well if \c
359 /// SkipPseudoOp is true.
360iterator_range<
361filter_iterator<BasicBlock::iterator, std::function<bool(Instruction &)>>>
362instructionsWithoutDebug(bool SkipPseudoOp =true);
363
364 /// Return the size of the basic block ignoring debug instructions
365filter_iterator<BasicBlock::const_iterator,
366 std::function<bool(constInstruction &)>>::difference_type
367sizeWithoutDebug()const;
368
369 /// Unlink 'this' from the containing function, but do not delete it.
370voidremoveFromParent();
371
372 /// Unlink 'this' from the containing function and delete it.
373 ///
374// \returns an iterator pointing to the element after the erased one.
375SymbolTableList<BasicBlock>::iteratoreraseFromParent();
376
377 /// Unlink this basic block from its current function and insert it into
378 /// the function that \p MovePos lives in, right before \p MovePos.
379inlinevoidmoveBefore(BasicBlock *MovePos) {
380moveBefore(MovePos->getIterator());
381 }
382voidmoveBefore(SymbolTableList<BasicBlock>::iterator MovePos);
383
384 /// Unlink this basic block from its current function and insert it
385 /// right after \p MovePos in the function \p MovePos lives in.
386voidmoveAfter(BasicBlock *MovePos);
387
388 /// Insert unlinked basic block into a function.
389 ///
390 /// Inserts an unlinked basic block into \c Parent. If \c InsertBefore is
391 /// provided, inserts before that basic block, otherwise inserts at the end.
392 ///
393 /// \pre \a getParent() is \c nullptr.
394voidinsertInto(Function *Parent,BasicBlock *InsertBefore =nullptr);
395
396 /// Return the predecessor of this block if it has a single predecessor
397 /// block. Otherwise return a null pointer.
398constBasicBlock *getSinglePredecessor()const;
399BasicBlock *getSinglePredecessor() {
400returnconst_cast<BasicBlock *>(
401static_cast<constBasicBlock *>(this)->getSinglePredecessor());
402 }
403
404 /// Return the predecessor of this block if it has a unique predecessor
405 /// block. Otherwise return a null pointer.
406 ///
407 /// Note that unique predecessor doesn't mean single edge, there can be
408 /// multiple edges from the unique predecessor to this block (for example a
409 /// switch statement with multiple cases having the same destination).
410constBasicBlock *getUniquePredecessor()const;
411BasicBlock *getUniquePredecessor() {
412returnconst_cast<BasicBlock *>(
413static_cast<constBasicBlock *>(this)->getUniquePredecessor());
414 }
415
416 /// Return true if this block has exactly N predecessors.
417boolhasNPredecessors(unsignedN)const;
418
419 /// Return true if this block has N predecessors or more.
420boolhasNPredecessorsOrMore(unsignedN)const;
421
422 /// Return the successor of this block if it has a single successor.
423 /// Otherwise return a null pointer.
424 ///
425 /// This method is analogous to getSinglePredecessor above.
426constBasicBlock *getSingleSuccessor()const;
427BasicBlock *getSingleSuccessor() {
428returnconst_cast<BasicBlock *>(
429static_cast<constBasicBlock *>(this)->getSingleSuccessor());
430 }
431
432 /// Return the successor of this block if it has a unique successor.
433 /// Otherwise return a null pointer.
434 ///
435 /// This method is analogous to getUniquePredecessor above.
436constBasicBlock *getUniqueSuccessor()const;
437BasicBlock *getUniqueSuccessor() {
438returnconst_cast<BasicBlock *>(
439static_cast<constBasicBlock *>(this)->getUniqueSuccessor());
440 }
441
442 /// Print the basic block to an output stream with an optional
443 /// AssemblyAnnotationWriter.
444voidprint(raw_ostream &OS,AssemblyAnnotationWriter *AAW =nullptr,
445bool ShouldPreserveUseListOrder =false,
446bool IsForDebug =false)const;
447
448//===--------------------------------------------------------------------===//
449 /// Instruction iterator methods
450 ///
451inlineiteratorbegin() {
452iterator It = InstList.begin();
453// Set the head-inclusive bit to indicate that this iterator includes
454// any debug-info at the start of the block. This is a no-op unless the
455// appropriate CMake flag is set.
456 It.setHeadBit(true);
457return It;
458 }
459inlineconst_iteratorbegin() const{
460const_iterator It = InstList.begin();
461 It.setHeadBit(true);
462return It;
463 }
464inlineiteratorend () {return InstList.end(); }
465inlineconst_iteratorend () const{return InstList.end(); }
466
467inlinereverse_iteratorrbegin() {return InstList.rbegin(); }
468inlineconst_reverse_iteratorrbegin() const{return InstList.rbegin(); }
469inlinereverse_iteratorrend () {return InstList.rend(); }
470inlineconst_reverse_iteratorrend () const{return InstList.rend(); }
471
472inlinesize_tsize() const{return InstList.size(); }
473inlineboolempty() const{return InstList.empty(); }
474inlineconstInstruction &front() const{return InstList.front(); }
475inlineInstruction &front() {return InstList.front(); }
476inlineconstInstruction &back() const{return InstList.back(); }
477inlineInstruction &back() {return InstList.back(); }
478
479 /// Iterator to walk just the phi nodes in the basic block.
480template <typename PHINodeT = PHINode,typename BBIteratorT = iterator>
481classphi_iterator_impl
482 :publiciterator_facade_base<phi_iterator_impl<PHINodeT, BBIteratorT>,
483 std::forward_iterator_tag, PHINodeT> {
484friendBasicBlock;
485
486 PHINodeT *PN;
487
488phi_iterator_impl(PHINodeT *PN) : PN(PN) {}
489
490public:
491// Allow default construction to build variables, but this doesn't build
492// a useful iterator.
493phi_iterator_impl() =default;
494
495// Allow conversion between instantiations where valid.
496template <typename PHINodeU,typename BBIteratorU,
497typename = std::enable_if_t<
498 std::is_convertible<PHINodeU *, PHINodeT *>::value>>
499phi_iterator_impl(constphi_iterator_impl<PHINodeU, BBIteratorU> &Arg)
500 : PN(Arg.PN) {}
501
502booloperator==(constphi_iterator_impl &Arg) const{return PN == Arg.PN; }
503
504 PHINodeT &operator*() const{return *PN; }
505
506usingphi_iterator_impl::iterator_facade_base::operator++;
507phi_iterator_impl &operator++() {
508assert(PN &&"Cannot increment the end iterator!");
509 PN = dyn_cast<PHINodeT>(std::next(BBIteratorT(PN)));
510return *this;
511 }
512 };
513usingphi_iterator =phi_iterator_impl<>;
514usingconst_phi_iterator =
515phi_iterator_impl<const PHINode, BasicBlock::const_iterator>;
516
517 /// Returns a range that iterates over the phis in the basic block.
518 ///
519 /// Note that this cannot be used with basic blocks that have no terminator.
520iterator_range<const_phi_iterator>phis() const{
521returnconst_cast<BasicBlock *>(this)->phis();
522 }
523iterator_range<phi_iterator>phis();
524
525private:
526 /// Return the underlying instruction list container.
527 /// This is deliberately private because we have implemented an adequate set
528 /// of functions to modify the list, including BasicBlock::splice(),
529 /// BasicBlock::erase(), Instruction::insertInto() etc.
530constInstListType &getInstList() const{return InstList; }
531InstListType &getInstList() {return InstList; }
532
533 /// Returns a pointer to a member of the instruction list.
534 /// This is private on purpose, just like `getInstList()`.
535staticInstListType BasicBlock::*getSublistAccess(Instruction *) {
536return &BasicBlock::InstList;
537 }
538
539 /// Dedicated function for splicing debug-info: when we have an empty
540 /// splice (i.e. zero instructions), the caller may still intend any
541 /// debug-info in between the two "positions" to be spliced.
542void spliceDebugInfoEmptyBlock(BasicBlock::iterator ToIt, BasicBlock *FromBB,
543BasicBlock::iterator FromBeginIt,
544BasicBlock::iterator FromEndIt);
545
546 /// Perform any debug-info specific maintenence for the given splice
547 /// activity. In the DbgRecord debug-info representation, debug-info is not
548 /// in instructions, and so it does not automatically move from one block
549 /// to another.
550void spliceDebugInfo(BasicBlock::iterator ToIt, BasicBlock *FromBB,
551BasicBlock::iterator FromBeginIt,
552BasicBlock::iterator FromEndIt);
553void spliceDebugInfoImpl(BasicBlock::iterator ToIt, BasicBlock *FromBB,
554BasicBlock::iterator FromBeginIt,
555BasicBlock::iterator FromEndIt);
556
557public:
558 /// Returns a pointer to the symbol table if one exists.
559 ValueSymbolTable *getValueSymbolTable();
560
561 /// Methods for support type inquiry through isa, cast, and dyn_cast.
562staticboolclassof(constValue *V) {
563return V->getValueID() == Value::BasicBlockVal;
564 }
565
566 /// Cause all subinstructions to "let go" of all the references that said
567 /// subinstructions are maintaining.
568 ///
569 /// This allows one to 'delete' a whole class at a time, even though there may
570 /// be circular references... first all references are dropped, and all use
571 /// counts go to zero. Then everything is delete'd for real. Note that no
572 /// operations are valid on an object that has "dropped all references",
573 /// except operator delete.
574voiddropAllReferences();
575
576 /// Update PHI nodes in this BasicBlock before removal of predecessor \p Pred.
577 /// Note that this function does not actually remove the predecessor.
578 ///
579 /// If \p KeepOneInputPHIs is true then don't remove PHIs that are left with
580 /// zero or one incoming values, and don't simplify PHIs with all incoming
581 /// values the same.
582voidremovePredecessor(BasicBlock *Pred,bool KeepOneInputPHIs =false);
583
584boolcanSplitPredecessors()const;
585
586 /// Split the basic block into two basic blocks at the specified instruction.
587 ///
588 /// If \p Before is true, splitBasicBlockBefore handles the
589 /// block splitting. Otherwise, execution proceeds as described below.
590 ///
591 /// Note that all instructions BEFORE the specified iterator
592 /// stay as part of the original basic block, an unconditional branch is added
593 /// to the original BB, and the rest of the instructions in the BB are moved
594 /// to the new BB, including the old terminator. The newly formed basic block
595 /// is returned. This function invalidates the specified iterator.
596 ///
597 /// Note that this only works on well formed basic blocks (must have a
598 /// terminator), and \p 'I' must not be the end of instruction list (which
599 /// would cause a degenerate basic block to be formed, having a terminator
600 /// inside of the basic block).
601 ///
602 /// Also note that this doesn't preserve any passes. To split blocks while
603 /// keeping loop information consistent, use the SplitBlock utility function.
604BasicBlock *splitBasicBlock(iteratorI,constTwine &BBName ="",
605boolBefore =false);
606BasicBlock *splitBasicBlock(Instruction *I,constTwine &BBName ="",
607boolBefore =false) {
608returnsplitBasicBlock(I->getIterator(), BBName,Before);
609 }
610
611 /// Split the basic block into two basic blocks at the specified instruction
612 /// and insert the new basic blocks as the predecessor of the current block.
613 ///
614 /// This function ensures all instructions AFTER and including the specified
615 /// iterator \p I are part of the original basic block. All Instructions
616 /// BEFORE the iterator \p I are moved to the new BB and an unconditional
617 /// branch is added to the new BB. The new basic block is returned.
618 ///
619 /// Note that this only works on well formed basic blocks (must have a
620 /// terminator), and \p 'I' must not be the end of instruction list (which
621 /// would cause a degenerate basic block to be formed, having a terminator
622 /// inside of the basic block). \p 'I' cannot be a iterator for a PHINode
623 /// with multiple incoming blocks.
624 ///
625 /// Also note that this doesn't preserve any passes. To split blocks while
626 /// keeping loop information consistent, use the SplitBlockBefore utility
627 /// function.
628BasicBlock *splitBasicBlockBefore(iteratorI,constTwine &BBName ="");
629BasicBlock *splitBasicBlockBefore(Instruction *I,constTwine &BBName ="") {
630returnsplitBasicBlockBefore(I->getIterator(), BBName);
631 }
632
633 /// Transfer all instructions from \p FromBB to this basic block at \p ToIt.
634voidsplice(BasicBlock::iterator ToIt,BasicBlock *FromBB) {
635splice(ToIt, FromBB, FromBB->begin(), FromBB->end());
636 }
637
638 /// Transfer one instruction from \p FromBB at \p FromIt to this basic block
639 /// at \p ToIt.
640voidsplice(BasicBlock::iterator ToIt,BasicBlock *FromBB,
641BasicBlock::iterator FromIt) {
642auto FromItNext = std::next(FromIt);
643// Single-element splice is a noop if destination == source.
644if (ToIt == FromIt || ToIt == FromItNext)
645return;
646splice(ToIt, FromBB, FromIt, FromItNext);
647 }
648
649 /// Transfer a range of instructions that belong to \p FromBB from \p
650 /// FromBeginIt to \p FromEndIt, to this basic block at \p ToIt.
651voidsplice(BasicBlock::iterator ToIt,BasicBlock *FromBB,
652BasicBlock::iterator FromBeginIt,
653BasicBlock::iterator FromEndIt);
654
655 /// Erases a range of instructions from \p FromIt to (not including) \p ToIt.
656 /// \Returns \p ToIt.
657BasicBlock::iteratorerase(BasicBlock::iterator FromIt,BasicBlock::iterator ToIt);
658
659 /// Returns true if there are any uses of this basic block other than
660 /// direct branches, switches, etc. to it.
661boolhasAddressTaken() const{
662return getBasicBlockBits().BlockAddressRefCount != 0;
663 }
664
665 /// Update all phi nodes in this basic block to refer to basic block \p New
666 /// instead of basic block \p Old.
667voidreplacePhiUsesWith(BasicBlock *Old,BasicBlock *New);
668
669 /// Update all phi nodes in this basic block's successors to refer to basic
670 /// block \p New instead of basic block \p Old.
671voidreplaceSuccessorsPhiUsesWith(BasicBlock *Old,BasicBlock *New);
672
673 /// Update all phi nodes in this basic block's successors to refer to basic
674 /// block \p New instead of to it.
675voidreplaceSuccessorsPhiUsesWith(BasicBlock *New);
676
677 /// Return true if this basic block is an exception handling block.
678boolisEHPad() const{returngetFirstNonPHIIt()->isEHPad(); }
679
680 /// Return true if this basic block is a landing pad.
681 ///
682 /// Being a ``landing pad'' means that the basic block is the destination of
683 /// the 'unwind' edge of an invoke instruction.
684boolisLandingPad()const;
685
686 /// Return the landingpad instruction associated with the landing pad.
687constLandingPadInst *getLandingPadInst()const;
688LandingPadInst *getLandingPadInst() {
689returnconst_cast<LandingPadInst *>(
690static_cast<constBasicBlock *>(this)->getLandingPadInst());
691 }
692
693 /// Return true if it is legal to hoist instructions into this block.
694boolisLegalToHoistInto()const;
695
696 /// Return true if this is the entry block of the containing function.
697 /// This method can only be used on blocks that have a parent function.
698boolisEntryBlock()const;
699
700 std::optional<uint64_t>getIrrLoopHeaderWeight()const;
701
702 /// Returns true if the Order field of child Instructions is valid.
703boolisInstrOrderValid() const{
704return getBasicBlockBits().InstrOrderValid;
705 }
706
707 /// Mark instruction ordering invalid. Done on every instruction insert.
708voidinvalidateOrders() {
709validateInstrOrdering();
710 BasicBlockBits Bits = getBasicBlockBits();
711 Bits.InstrOrderValid =false;
712 setBasicBlockBits(Bits);
713 }
714
715 /// Renumber instructions and mark the ordering as valid.
716voidrenumberInstructions();
717
718 /// Asserts that instruction order numbers are marked invalid, or that they
719 /// are in ascending order. This is constant time if the ordering is invalid,
720 /// and linear in the number of instructions if the ordering is valid. Callers
721 /// should be careful not to call this in ways that make common operations
722 /// O(n^2). For example, it takes O(n) time to assign order numbers to
723 /// instructions, so the order should be validated no more than once after
724 /// each ordering to ensure that transforms have the same algorithmic
725 /// complexity when asserts are enabled as when they are disabled.
726voidvalidateInstrOrdering()const;
727
728private:
729#if defined(_AIX) && (!defined(__GNUC__) || defined(__clang__))
730// Except for GCC; by default, AIX compilers store bit-fields in 4-byte words
731// and give the `pack` pragma push semantics.
732#define BEGIN_TWO_BYTE_PACK() _Pragma("pack(2)")
733#define END_TWO_BYTE_PACK() _Pragma("pack(pop)")
734#else
735#define BEGIN_TWO_BYTE_PACK()
736#define END_TWO_BYTE_PACK()
737#endif
738
739BEGIN_TWO_BYTE_PACK()
740 /// Bitfield to help interpret the bits in Value::SubclassData.
741 struct BasicBlockBits {
742unsignedshort BlockAddressRefCount : 15;
743unsignedshort InstrOrderValid : 1;
744 };
745END_TWO_BYTE_PACK()
746
747#undef BEGIN_TWO_BYTE_PACK
748#undef END_TWO_BYTE_PACK
749
750 /// Safely reinterpret the subclass data bits to a more useful form.
751 BasicBlockBits getBasicBlockBits() const{
752static_assert(sizeof(BasicBlockBits) ==sizeof(unsignedshort),
753"too many bits for Value::SubclassData");
754unsignedshort ValueData =getSubclassDataFromValue();
755 BasicBlockBits AsBits;
756 memcpy(&AsBits, &ValueData,sizeof(AsBits));
757return AsBits;
758 }
759
760 /// Reinterpret our subclass bits and store them back into Value.
761void setBasicBlockBits(BasicBlockBits AsBits) {
762unsignedshortD;
763 memcpy(&D, &AsBits,sizeof(D));
764Value::setValueSubclassData(D);
765 }
766
767 /// Increment the internal refcount of the number of BlockAddresses
768 /// referencing this BasicBlock by \p Amt.
769 ///
770 /// This is almost always 0, sometimes one possibly, but almost never 2, and
771 /// inconceivably 3 or more.
772void AdjustBlockAddressRefCount(int Amt) {
773 BasicBlockBitsBits = getBasicBlockBits();
774Bits.BlockAddressRefCount += Amt;
775 setBasicBlockBits(Bits);
776assert(Bits.BlockAddressRefCount < 255 &&"Refcount wrap-around");
777 }
778
779 /// Shadow Value::setValueSubclassData with a private forwarding method so
780 /// that any future subclasses cannot accidentally use it.
781void setValueSubclassData(unsignedshortD) {
782Value::setValueSubclassData(D);
783 }
784};
785
786// Create wrappers for C Binding types (see CBindingWrapping.h).
787DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock,LLVMBasicBlockRef)
788
789/// Advance \p It while it points to a debug instruction and return the result.
790/// This assumes that \p It is not at the end of a block.
791BasicBlock::iteratorskipDebugIntrinsics(BasicBlock::iterator It);
792
793#ifdef NDEBUG
794/// In release builds, this is a no-op. For !NDEBUG builds, the checks are
795/// implemented in the .cpp file to avoid circular header deps.
796inlinevoidBasicBlock::validateInstrOrdering() const{}
797#endif
798
799// Specialize DenseMapInfo for iterators, so that ththey can be installed into
800// maps and sets. The iterator is made up of its node pointer, and the
801// debug-info "head" bit.
802template <>structDenseMapInfo<BasicBlock::iterator> {
803staticinlineBasicBlock::iteratorgetEmptyKey() {
804returnBasicBlock::iterator(nullptr);
805 }
806
807staticinlineBasicBlock::iteratorgetTombstoneKey() {
808BasicBlock::iterator It(nullptr);
809 It.setHeadBit(true);
810return It;
811 }
812
813staticunsignedgetHashValue(constBasicBlock::iterator &It) {
814returnDenseMapInfo<void *>::getHashValue(
815reinterpret_cast<void *>(It.getNodePtr())) ^
816 (unsigned)It.getHeadBit();
817 }
818
819staticboolisEqual(constBasicBlock::iterator &LHS,
820constBasicBlock::iterator &RHS) {
821returnLHS ==RHS &&LHS.getHeadBit() ==RHS.getHeadBit();
822 }
823};
824
825}// end namespace llvm
826
827#endif// LLVM_IR_BASICBLOCK_H
const
aarch64 promote const
Definition:AArch64PromoteConstant.cpp:230
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
DEFINE_SIMPLE_CONVERSION_FUNCTIONS
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
Definition:CBindingWrapping.h:19
LLVM_READONLY
#define LLVM_READONLY
Definition:Compiler.h:306
DebugProgramInstruction.h
DenseMap.h
This file defines the DenseMap class.
Name
std::string Name
Definition:ELFObjHandler.cpp:77
Instruction.h
Value.h
I
#define I(x, y, z)
Definition:MD5.cpp:58
Module
Machine Check Debug Module
Definition:MachineCheckDebugify.cpp:124
Number
uint32_t Number
Definition:Profile.cpp:47
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OS
raw_pwrite_stream & OS
Definition:SampleProfWriter.cpp:51
END_TWO_BYTE_PACK
#define END_TWO_BYTE_PACK()
Definition:SelectionDAGNodes.h:515
BEGIN_TWO_BYTE_PACK
#define BEGIN_TWO_BYTE_PACK()
Definition:SelectionDAGNodes.h:514
IRDumpFileSuffixType::Before
@ Before
SymbolTableListTraits.h
Twine.h
Types.h
RHS
Value * RHS
Definition:X86PartialReduction.cpp:74
LHS
Value * LHS
Definition:X86PartialReduction.cpp:73
const_iterator
bool
llvm::AssemblyAnnotationWriter
Definition:AssemblyAnnotationWriter.h:27
llvm::BasicBlock::phi_iterator_impl
Iterator to walk just the phi nodes in the basic block.
Definition:BasicBlock.h:483
llvm::BasicBlock::phi_iterator_impl::operator==
bool operator==(const phi_iterator_impl &Arg) const
Definition:BasicBlock.h:502
llvm::BasicBlock::phi_iterator_impl::phi_iterator_impl
phi_iterator_impl(const phi_iterator_impl< PHINodeU, BBIteratorU > &Arg)
Definition:BasicBlock.h:499
llvm::BasicBlock::phi_iterator_impl::operator*
PHINodeT & operator*() const
Definition:BasicBlock.h:504
llvm::BasicBlock::phi_iterator_impl::phi_iterator_impl
phi_iterator_impl()=default
llvm::BasicBlock::phi_iterator_impl::operator++
phi_iterator_impl & operator++()
Definition:BasicBlock.h:507
llvm::BasicBlock
LLVM Basic Block Representation.
Definition:BasicBlock.h:61
llvm::BasicBlock::erase
BasicBlock::iterator erase(BasicBlock::iterator FromIt, BasicBlock::iterator ToIt)
Erases a range of instructions from FromIt to (not including) ToIt.
Definition:BasicBlock.cpp:656
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:674
llvm::BasicBlock::BasicBlock
BasicBlock(const BasicBlock &)=delete
llvm::BasicBlock::end
iterator end()
Definition:BasicBlock.h:464
llvm::BasicBlock::getNumber
unsigned getNumber() const
Definition:BasicBlock.h:104
llvm::BasicBlock::getFirstMayFaultInst
Instruction * getFirstMayFaultInst()
Definition:BasicBlock.h:345
llvm::BasicBlock::begin
iterator begin()
Instruction iterator methods.
Definition:BasicBlock.h:451
llvm::BasicBlock::deleteTrailingDbgRecords
void deleteTrailingDbgRecords()
Delete any trailing DbgRecords at the end of this block, see setTrailingDbgRecords.
Definition:BasicBlock.cpp:1175
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:520
llvm::BasicBlock::begin
const_iterator begin() const
Definition:BasicBlock.h:459
llvm::BasicBlock::getLandingPadInst
const LandingPadInst * getLandingPadInst() const
Return the landingpad instruction associated with the landing pad.
Definition:BasicBlock.cpp:693
llvm::BasicBlock::setTrailingDbgRecords
void setTrailingDbgRecords(DbgMarker *M)
Record that the collection of DbgRecords in M "trails" after the last instruction of this block.
Definition:BasicBlock.cpp:1167
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:426
llvm::BasicBlock::rbegin
reverse_iterator rbegin()
Definition:BasicBlock.h:467
llvm::BasicBlock::classof
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast.
Definition:BasicBlock.h:562
llvm::BasicBlock::getFirstNonPHIOrDbgOrLifetime
InstListType::iterator getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp=true)
Definition:BasicBlock.h:316
llvm::BasicBlock::renumberInstructions
void renumberInstructions()
Renumber instructions and mark the ordering as valid.
Definition:BasicBlock.cpp:716
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:250
llvm::BasicBlock::getFirstNonPHIIt
InstListType::iterator getFirstNonPHIIt()
Definition:BasicBlock.h:292
llvm::BasicBlock::empty
bool empty() const
Definition:BasicBlock.h:473
llvm::BasicBlock::createMarker
DbgMarker * createMarker(Instruction *I)
Attach a DbgMarker to the given instruction.
Definition:BasicBlock.cpp:52
llvm::BasicBlock::splitBasicBlock
BasicBlock * splitBasicBlock(Instruction *I, const Twine &BBName="", bool Before=false)
Definition:BasicBlock.h:606
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:620
llvm::BasicBlock::hasAddressTaken
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches,...
Definition:BasicBlock.h:661
llvm::BasicBlock::getFirstNonPHIIt
InstListType::const_iterator getFirstNonPHIIt() const
Iterator returning form of getFirstNonPHI.
Definition:BasicBlock.cpp:374
llvm::BasicBlock::insertDbgRecordBefore
void insertDbgRecordBefore(DbgRecord *DR, InstListType::iterator Here)
Insert a DbgRecord into a block at the position given by Here.
Definition:BasicBlock.cpp:1078
llvm::BasicBlock::splitBasicBlockBefore
BasicBlock * splitBasicBlockBefore(Instruction *I, const Twine &BBName="")
Definition:BasicBlock.h:629
llvm::BasicBlock::invalidateOrders
void invalidateOrders()
Mark instruction ordering invalid. Done on every instruction insert.
Definition:BasicBlock.h:708
llvm::BasicBlock::removeFromParent
friend void Instruction::removeFromParent()
llvm::BasicBlock::convertToNewDbgValues
void convertToNewDbgValues()
Convert variable location debugging information stored in dbg.value intrinsics into DbgMarkers / DbgR...
Definition:BasicBlock.cpp:76
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:4901
llvm::BasicBlock::const_iterator
InstListType::const_iterator const_iterator
Definition:BasicBlock.h:178
llvm::BasicBlock::setIsNewDbgInfoFormat
void setIsNewDbgInfoFormat(bool NewFlag)
Ensure the block is in "old" dbg.value format (NewFlag == false) or in the new format (NewFlag == tru...
Definition:BasicBlock.cpp:152
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:367
llvm::BasicBlock::getUniqueSuccessor
BasicBlock * getUniqueSuccessor()
Definition:BasicBlock.h:437
llvm::BasicBlock::front
const Instruction & front() const
Definition:BasicBlock.h:474
llvm::BasicBlock::getModule
Module * getModule()
Definition:BasicBlock.h:228
llvm::BasicBlock::front
Instruction & front()
Definition:BasicBlock.h:475
llvm::BasicBlock::Create
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Definition:BasicBlock.h:213
llvm::BasicBlock::getSingleSuccessor
BasicBlock * getSingleSuccessor()
Definition:BasicBlock.h:427
llvm::BasicBlock::eraseFromParent
friend BasicBlock::iterator Instruction::eraseFromParent()
llvm::BasicBlock::setNewDbgInfoFormatFlag
void setNewDbgInfoFormatFlag(bool NewFlag)
Definition:BasicBlock.cpp:158
llvm::BasicBlock::isEntryBlock
bool isEntryBlock() const
Return true if this is the entry block of the containing function.
Definition:BasicBlock.cpp:583
llvm::BasicBlock::getValueSymbolTable
ValueSymbolTable * getValueSymbolTable()
Returns a pointer to the symbol table if one exists.
Definition:BasicBlock.cpp:162
llvm::BasicBlock::getUniquePredecessor
BasicBlock * getUniquePredecessor()
Definition:BasicBlock.h:411
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:287
llvm::BasicBlock::getFirstNonPHIOrDbg
InstListType::const_iterator 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:387
llvm::BasicBlock::hasNPredecessors
bool hasNPredecessors(unsigned N) const
Return true if this block has exactly N predecessors.
Definition:BasicBlock.cpp:493
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:589
llvm::BasicBlock::getSinglePredecessor
BasicBlock * getSinglePredecessor()
Definition:BasicBlock.h:399
llvm::BasicBlock::convertFromNewDbgValues
void convertFromNewDbgValues()
Convert variable location debugging information stored in DbgMarkers and DbgRecords into the dbg....
Definition:BasicBlock.cpp:115
llvm::BasicBlock::getUniqueSuccessor
const BasicBlock * getUniqueSuccessor() const
Return the successor of this block if it has a unique successor.
Definition:BasicBlock.cpp:509
llvm::BasicBlock::getSinglePredecessor
const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
Definition:BasicBlock.cpp:471
llvm::BasicBlock::getIrrLoopHeaderWeight
std::optional< uint64_t > getIrrLoopHeaderWeight() const
Definition:BasicBlock.cpp:697
llvm::BasicBlock::dumpDbgValues
void dumpDbgValues() const
Definition:BasicBlock.cpp:141
llvm::BasicBlock::getTerminatingDeoptimizeCall
const CallInst * getTerminatingDeoptimizeCall() const
Returns the call instruction calling @llvm.experimental.deoptimize prior to the terminating return in...
Definition:BasicBlock.cpp:331
llvm::BasicBlock::back
Instruction & back()
Definition:BasicBlock.h:477
llvm::BasicBlock::reverse_iterator
InstListType::reverse_iterator reverse_iterator
Definition:BasicBlock.h:179
llvm::BasicBlock::moveBeforeImpl
friend void Instruction::moveBeforeImpl(BasicBlock &BB, InstListType::iterator I, bool Preserve)
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:663
llvm::BasicBlock::getUniquePredecessor
const BasicBlock * getUniquePredecessor() const
Return the predecessor of this block if it has a unique predecessor block.
Definition:BasicBlock.cpp:479
llvm::BasicBlock::getSingleSuccessor
const BasicBlock * getSingleSuccessor() const
Return the successor of this block if it has a single successor.
Definition:BasicBlock.cpp:501
llvm::BasicBlock::flushTerminatorDbgRecords
void flushTerminatorDbgRecords()
Eject any debug-info trailing at the end of a block.
Definition:BasicBlock.cpp:729
llvm::BasicBlock::splice
void splice(BasicBlock::iterator ToIt, BasicBlock *FromBB, BasicBlock::iterator FromIt)
Transfer one instruction from FromBB at FromIt to this basic block at ToIt.
Definition:BasicBlock.h:640
llvm::BasicBlock::getParent
const Function * getParent() const
Return the enclosing method, or null if none.
Definition:BasicBlock.h:220
llvm::BasicBlock::getParent
Function * getParent()
Definition:BasicBlock.h:221
llvm::BasicBlock::getFirstNonPHIOrDbg
InstListType::iterator getFirstNonPHIOrDbg(bool SkipPseudoOp=true)
Definition:BasicBlock.h:304
llvm::BasicBlock::getDataLayout
const DataLayout & getDataLayout() const
Get the data layout of the module this basic block belongs to.
Definition:BasicBlock.cpp:296
llvm::BasicBlock::rend
const_reverse_iterator rend() const
Definition:BasicBlock.h:470
llvm::BasicBlock::rend
reverse_iterator rend()
Definition:BasicBlock.h:469
llvm::BasicBlock::insertDbgRecordAfter
void insertDbgRecordAfter(DbgRecord *DR, Instruction *I)
Insert a DbgRecord into a block at the position given by I.
Definition:BasicBlock.cpp:1069
llvm::BasicBlock::validateInstrOrdering
void validateInstrOrdering() const
Asserts that instruction order numbers are marked invalid, or that they are in ascending order.
Definition:BasicBlock.cpp:1155
llvm::BasicBlock::getMarker
DbgMarker * getMarker(InstListType::iterator It)
Return the DbgMarker for the position given by It, so that DbgRecords can be inserted there.
Definition:BasicBlock.cpp:1090
llvm::BasicBlock::sizeWithoutDebug
filter_iterator< BasicBlock::const_iterator, std::function< bool(constInstruction &)> >::difference_type sizeWithoutDebug() const
Return the size of the basic block ignoring debug instructions.
Definition:BasicBlock.cpp:270
llvm::BasicBlock::~BasicBlock
~BasicBlock()
Definition:BasicBlock.cpp:210
llvm::BasicBlock::iterator
InstListType::iterator iterator
Instruction iterators...
Definition:BasicBlock.h:177
llvm::BasicBlock::getFirstNonPHI
Instruction * getFirstNonPHI()
Definition:BasicBlock.h:284
llvm::BasicBlock::getContext
LLVMContext & getContext() const
Get the context in which this basic block lives.
Definition:BasicBlock.cpp:168
llvm::BasicBlock::getPostdominatingDeoptimizeCall
CallInst * getPostdominatingDeoptimizeCall()
Definition:BasicBlock.h:263
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:440
llvm::BasicBlock::InstListType
SymbolTableList< Instruction, ilist_iterator_bits< true >, ilist_parent< BasicBlock > > InstListType
Definition:BasicBlock.h:64
llvm::BasicBlock::getTerminator
Instruction * getTerminator()
Definition:BasicBlock.h:245
llvm::BasicBlock::operator=
BasicBlock & operator=(const BasicBlock &)=delete
llvm::BasicBlock::getFirstNonPHIOrDbgOrAlloca
iterator getFirstNonPHIOrDbgOrAlloca()
Definition:BasicBlock.h:335
llvm::BasicBlock::IsNewDbgInfoFormat
bool IsNewDbgInfoFormat
Flag recording whether or not this block stores debug-info in the form of intrinsic instructions (fal...
Definition:BasicBlock.h:67
llvm::BasicBlock::getTerminatingDeoptimizeCall
CallInst * getTerminatingDeoptimizeCall()
Definition:BasicBlock.h:254
llvm::BasicBlock::dropAllReferences
void dropAllReferences()
Cause all subinstructions to "let go" of all the references that said subinstructions are maintaining...
Definition:BasicBlock.cpp:466
llvm::BasicBlock::size
size_t size() const
Definition:BasicBlock.h:472
llvm::BasicBlock::reinsertInstInDbgRecords
void reinsertInstInDbgRecords(Instruction *I, std::optional< DbgRecord::self_iterator > Pos)
In rare circumstances instructions can be speculatively removed from blocks, and then be re-inserted ...
Definition:BasicBlock.cpp:1098
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.h:379
llvm::BasicBlock::getFirstNonPHIOrDbgOrLifetime
InstListType::const_iterator 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:405
llvm::BasicBlock::isLandingPad
bool isLandingPad() const
Return true if this basic block is a landing pad.
Definition:BasicBlock.cpp:689
llvm::BasicBlock::const_reverse_iterator
InstListType::const_reverse_iterator const_reverse_iterator
Definition:BasicBlock.h:180
llvm::BasicBlock::isEHPad
bool isEHPad() const
Return true if this basic block is an exception handling block.
Definition:BasicBlock.h:678
llvm::BasicBlock::getTrailingDbgRecords
DbgMarker * getTrailingDbgRecords()
Fetch the collection of DbgRecords that "trail" after the last instruction of this block,...
Definition:BasicBlock.cpp:1171
llvm::BasicBlock::getTerminatingMustTailCall
CallInst * getTerminatingMustTailCall()
Definition:BasicBlock.h:272
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:240
llvm::BasicBlock::canSplitPredecessors
bool canSplitPredecessors() const
Definition:BasicBlock.cpp:557
llvm::BasicBlock::end
const_iterator end() const
Definition:BasicBlock.h:465
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:300
llvm::BasicBlock::insertInto
friend BasicBlock::iterator Instruction::insertInto(BasicBlock *BB, BasicBlock::iterator It)
llvm::BasicBlock::isLegalToHoistInto
bool isLegalToHoistInto() const
Return true if it is legal to hoist instructions into this block.
Definition:BasicBlock.cpp:569
llvm::BasicBlock::hasNPredecessorsOrMore
bool hasNPredecessorsOrMore(unsigned N) const
Return true if this block has N predecessors or more.
Definition:BasicBlock.cpp:497
llvm::BasicBlock::isInstrOrderValid
bool isInstrOrderValid() const
Returns true if the Order field of child Instructions is valid.
Definition:BasicBlock.h:703
llvm::BasicBlock::getPostdominatingDeoptimizeCall
const CallInst * getPostdominatingDeoptimizeCall() const
Returns the call instruction calling @llvm.experimental.deoptimize that is present either in current ...
Definition:BasicBlock.cpp:346
llvm::BasicBlock::getNextMarker
DbgMarker * getNextMarker(Instruction *I)
Return the DbgMarker for the position that comes after I.
Definition:BasicBlock.cpp:1086
llvm::BasicBlock::getFirstMayFaultInst
const Instruction * getFirstMayFaultInst() const
Returns the first potential AsynchEH faulty instruction currently it checks for loads/stores (which m...
Definition:BasicBlock.cpp:358
llvm::BasicBlock::splice
void splice(BasicBlock::iterator ToIt, BasicBlock *FromBB)
Transfer all instructions from FromBB to this basic block at ToIt.
Definition:BasicBlock.h:634
llvm::BasicBlock::rbegin
const_reverse_iterator rbegin() const
Definition:BasicBlock.h:468
llvm::BasicBlock::getLandingPadInst
LandingPadInst * getLandingPadInst()
Definition:BasicBlock.h:688
llvm::BasicBlock::back
const Instruction & back() const
Definition:BasicBlock.h:476
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:292
llvm::BasicBlock::getFirstInsertionPt
iterator getFirstInsertionPt()
Definition:BasicBlock.h:327
llvm::BasicBlock::removePredecessor
void removePredecessor(BasicBlock *Pred, bool KeepOneInputPHIs=false)
Update PHI nodes in this BasicBlock before removal of predecessor Pred.
Definition:BasicBlock.cpp:528
llvm::BlockAddress
The address of a basic block.
Definition:Constants.h:893
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition:Instructions.h:1479
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition:DataLayout.h:63
llvm::DbgMarker
Per-instruction record of debug-info.
Definition:DebugProgramInstruction.h:583
llvm::DbgRecord
Base class for non-instruction debug metadata records that have positions within IR.
Definition:DebugProgramInstruction.h:134
llvm::Function
Definition:Function.h:63
llvm::Instruction
Definition:Instruction.h:68
llvm::Instruction::removeFromParent
void removeFromParent()
This method unlinks 'this' from the containing basic block, but does not delete it.
Definition:Instruction.cpp:80
llvm::Instruction::cloneDebugInfoFrom
iterator_range< simple_ilist< DbgRecord >::iterator > cloneDebugInfoFrom(const Instruction *From, std::optional< simple_ilist< DbgRecord >::iterator > FromHere=std::nullopt, bool InsertAtHead=false)
Clone any debug-info attached to From onto this instruction.
Definition:Instruction.cpp:249
llvm::Instruction::insertBefore
void insertBefore(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified instruction.
Definition:Instruction.cpp:99
llvm::Instruction::eraseFromParent
InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
Definition:Instruction.cpp:94
llvm::Instruction::insertAfter
void insertAfter(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately after the specified instruction.
Definition:Instruction.cpp:111
llvm::Instruction::insertInto
InstListType::iterator insertInto(BasicBlock *ParentBB, InstListType::iterator It)
Inserts an unlinked instruction into ParentBB at position It and returns the iterator of the inserted...
Definition:Instruction.cpp:123
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition:LLVMContext.h:67
llvm::LandingPadInst
The landingpad instruction holds all of the information necessary to generate correct exception handl...
Definition:Instructions.h:2840
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition:Module.h:65
llvm::SymbolTableListTraits
Definition:SymbolTableListTraits.h:67
llvm::SymbolTableList< Instruction, ilist_iterator_bits< true >, ilist_parent< BasicBlock > >
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition:Twine.h:81
llvm::Value
LLVM Value Representation.
Definition:Value.h:74
llvm::Value::getSubclassDataFromValue
unsigned short getSubclassDataFromValue() const
Definition:Value.h:870
llvm::Value::setValueSubclassData
void setValueSubclassData(unsigned short D)
Definition:Value.h:871
llvm::filter_iterator_impl
Specialization of filter_iterator_base for forward iteration only.
Definition:STLExtras.h:498
llvm::ilist_node_impl::getIterator
self_iterator getIterator()
Definition:ilist_node.h:132
llvm::ilist_node_with_parent
An ilist node that can access its parent list.
Definition:ilist_node.h:321
llvm::iplist_impl::const_reverse_iterator
base_list_type::const_reverse_iterator const_reverse_iterator
Definition:ilist.h:125
llvm::iplist_impl::reverse_iterator
base_list_type::reverse_iterator reverse_iterator
Definition:ilist.h:123
llvm::iplist_impl::const_iterator
base_list_type::const_iterator const_iterator
Definition:ilist.h:122
llvm::iplist_impl::iterator
base_list_type::iterator iterator
Definition:ilist.h:121
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::iterator_range
A range adaptor for a pair of iterators.
Definition:iterator_range.h:42
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition:raw_ostream.h:52
unsigned
LLVMBasicBlockRef
struct LLVMOpaqueBasicBlock * LLVMBasicBlockRef
Represents a basic block of instructions in LLVM IR.
Definition:Types.h:82
ilist.h
This file defines classes to implement an intrusive doubly linked list class (i.e.
ilist_node.h
This file defines the ilist_node class template, which is a convenient base class for creating classe...
iterator.h
iterator_range.h
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
llvm::CallingConv::C
@ C
The default llvm calling convention, compatible with C.
Definition:CallingConv.h:34
llvm::codeview::PublicSymFlags::Function
@ Function
llvm::tgtok::Bits
@ Bits
Definition:TGLexer.h:79
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::skipDebugIntrinsics
BasicBlock::iterator skipDebugIntrinsics(BasicBlock::iterator It)
Advance It while it points to a debug instruction and return the result.
Definition:BasicBlock.cpp:710
N
#define N
llvm::DenseMapInfo< BasicBlock::iterator >::getEmptyKey
static BasicBlock::iterator getEmptyKey()
Definition:BasicBlock.h:803
llvm::DenseMapInfo< BasicBlock::iterator >::getHashValue
static unsigned getHashValue(const BasicBlock::iterator &It)
Definition:BasicBlock.h:813
llvm::DenseMapInfo< BasicBlock::iterator >::isEqual
static bool isEqual(const BasicBlock::iterator &LHS, const BasicBlock::iterator &RHS)
Definition:BasicBlock.h:819
llvm::DenseMapInfo< BasicBlock::iterator >::getTombstoneKey
static BasicBlock::iterator getTombstoneKey()
Definition:BasicBlock.h:807
llvm::DenseMapInfo
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition:DenseMapInfo.h:52
llvm::ilist_iterator_bits
Option to add extra bits to the ilist_iterator.
Definition:ilist_node_options.h:40
llvm::ilist_parent
Option to add a pointer to this list's owner in every node.
Definition:ilist_node_options.h:53

Generated on Thu Jul 17 2025 10:03:12 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp