LLVM 24.0.0git
BasicBlock.cpp
Go to the documentation of this file.
1//===-- BasicBlock.cpp - Implement BasicBlock related methods -------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the BasicBlock class for the IR library.
10//
11//===----------------------------------------------------------------------===//
12
13#include "llvm/IR/BasicBlock.h"
15#include "llvm/ADT/STLExtras.h"
16#include "llvm/ADT/Statistic.h"
17#include "llvm/IR/CFG.h"
18#include "llvm/IR/Constants.h"
22#include "llvm/IR/LLVMContext.h"
23#include "llvm/IR/Type.h"
25
26#include "LLVMContextImpl.h"
27
28using namespace llvm;
29
30#define DEBUG_TYPE "ir"
31STATISTIC(NumInstrRenumberings, "Number of renumberings across all blocks");
32
34 if (I->DebugMarker)
35 return I->DebugMarker;
36 DbgMarker *Marker = new DbgMarker();
37 Marker->MarkedInstr = I;
38 I->DebugMarker = Marker;
39 return Marker;
40}
41
42DbgMarker *BasicBlock::createMarker(InstListType::iterator It) {
43 if (It != end())
44 return createMarker(&*It);
45 DbgMarker *DM = getTrailingDbgRecords();
46 if (DM)
47 return DM;
48 DM = new DbgMarker();
49 setTrailingDbgRecords(DM);
50 return DM;
51}
52
54 // Iterate over all instructions in the instruction list, collecting debug
55 // info intrinsics and converting them to DbgRecords. Once we find a "real"
56 // instruction, attach all those DbgRecords to a DbgMarker in that
57 // instruction.
59 for (Instruction &I : make_early_inc_range(InstList)) {
61 // Convert this dbg.value to a DbgVariableRecord.
62 DbgVariableRecord *Value = new DbgVariableRecord(DVI);
63 DbgVarRecs.push_back(Value);
64 DVI->eraseFromParent();
65 continue;
66 }
67
69 DbgVarRecs.push_back(
70 new DbgLabelRecord(DLI->getLabel(), DLI->getDebugLoc()));
71 DLI->eraseFromParent();
72 continue;
73 }
74
75 if (DbgVarRecs.empty())
76 continue;
77
78 // Create a marker to store DbgRecords in.
79 createMarker(&I);
80 DbgMarker *Marker = I.DebugMarker;
81
82 for (DbgRecord *DVR : DbgVarRecs)
83 Marker->insertDbgRecord(DVR, false);
84
85 DbgVarRecs.clear();
86 }
87}
88
90 bool Modified = false;
91 invalidateOrders();
92
93 // Iterate over the block, finding instructions annotated with DbgMarkers.
94 // Convert any attached DbgRecords to debug intrinsics and insert ahead of
95 // the instruction.
96 for (auto &Inst : *this) {
97 if (!Inst.DebugMarker)
98 continue;
99
100 DbgMarker &Marker = *Inst.DebugMarker;
101 for (DbgRecord &DR : Marker.getDbgRecordRange())
102 InstList.insert(Inst.getIterator(),
103 DR.createDebugIntrinsic(getModule(), nullptr));
104
105 Marker.eraseFromParent();
106 Modified = true;
107 }
108
109 // Assume no trailing DbgRecords: we could technically create them at the end
110 // of the block, after a terminator, but this would be non-cannonical and
111 // indicates that something else is broken somewhere.
112 assert(!getTrailingDbgRecords());
113 return Modified;
114}
115
116#ifndef NDEBUG
117void BasicBlock::dumpDbgValues() const {
118 for (auto &Inst : *this) {
119 if (!Inst.DebugMarker)
120 continue;
121
122 dbgs() << "@ " << Inst.DebugMarker << " ";
123 Inst.DebugMarker->dump();
124 };
125}
126#endif
127
129 if (Function *F = getParent())
130 return F->getValueSymbolTable();
131 return nullptr;
132}
133
135 return getType()->getContext();
136}
137
139 BB->invalidateOrders();
140}
141
142// Explicit instantiation of SymbolTableListTraits since some of the methods
143// are not in the public header file...
144template class llvm::SymbolTableListTraits<
146
147BasicBlock::BasicBlock(LLVMContext &C, const Twine &Name, Function *NewParent,
148 BasicBlock *InsertBefore)
149 : Value(Type::getLabelTy(C), Value::BasicBlockVal), Parent(nullptr) {
150
151 if (NewParent)
152 insertInto(NewParent, InsertBefore);
153 else
154 assert(!InsertBefore &&
155 "Cannot insert block before another block with no function!");
156
157 end().getNodePtr()->setParent(this);
158 setName(Name);
159}
160
161void BasicBlock::insertInto(Function *NewParent, BasicBlock *InsertBefore) {
162 assert(NewParent && "Expected a parent");
163 assert(!Parent && "Already has a parent");
164
165 if (InsertBefore)
166 NewParent->insert(InsertBefore->getIterator(), this);
167 else
168 NewParent->insert(NewParent->end(), this);
169}
170
172 validateInstrOrdering();
173
174 // If the address of the block is taken and it is being deleted (e.g. because
175 // it is dead), this means that there is either a dangling constant expr
176 // hanging off the block, or an undefined use of the block (source code
177 // expecting the address of a label to keep the block alive even though there
178 // is no indirect branch). Handle these cases by zapping the BlockAddress
179 // nodes. There are no other possible uses at this point.
180 if (hasAddressTaken()) {
182
183 Constant *Replacement = ConstantInt::get(Type::getInt32Ty(getContext()), 1);
185 ConstantExpr::getIntToPtr(Replacement, BA->getType()));
186 BA->destroyConstant();
187 }
188
189 assert(getParent() == nullptr && "BasicBlock still linked into the program!");
190 dropAllReferences();
191 for (auto &Inst : *this) {
192 if (!Inst.DebugMarker)
193 continue;
194 Inst.DebugMarker->eraseFromParent();
195 }
196 InstList.clear();
197}
198
199void BasicBlock::setParent(Function *parent) {
200 // Set Parent=parent, updating instruction symtab entries as appropriate.
201 if (Parent != parent)
202 Number = parent ? parent->NextBlockNum++ : -1u;
203 InstList.setSymTabObject(&Parent, parent);
204}
205
207 getParent()->getBasicBlockList().remove(getIterator());
208}
209
211 return getParent()->getBasicBlockList().erase(getIterator());
212}
213
215 getParent()->splice(MovePos, getParent(), getIterator());
216}
217
218void BasicBlock::moveAfter(BasicBlock *MovePos) {
219 MovePos->getParent()->splice(++MovePos->getIterator(), getParent(),
220 getIterator());
221}
222
223const Module *BasicBlock::getModule() const {
224 return getParent()->getParent();
225}
226
228 return getModule()->getDataLayout();
229}
230
232 if (InstList.empty())
233 return nullptr;
234 const ReturnInst *RI = dyn_cast<ReturnInst>(&InstList.back());
235 if (!RI || RI == &InstList.front())
236 return nullptr;
237
238 const Instruction *Prev = RI->getPrevNode();
239 if (!Prev)
240 return nullptr;
241
242 if (Value *RV = RI->getReturnValue()) {
243 if (RV != Prev)
244 return nullptr;
245 }
246
247 if (auto *CI = dyn_cast<CallInst>(Prev)) {
248 if (CI->isMustTailCall())
249 return CI;
250 }
251 return nullptr;
252}
253
255 if (InstList.empty())
256 return nullptr;
257 auto *RI = dyn_cast<ReturnInst>(&InstList.back());
258 if (!RI || RI == &InstList.front())
259 return nullptr;
260
261 if (auto *CI = dyn_cast_or_null<CallInst>(RI->getPrevNode()))
262 if (Function *F = CI->getCalledFunction())
263 if (F->getIntrinsicID() == Intrinsic::experimental_deoptimize)
264 return CI;
265
266 return nullptr;
267}
268
270 const BasicBlock* BB = this;
272 Visited.insert(BB);
273 while (auto *Succ = BB->getUniqueSuccessor()) {
274 if (!Visited.insert(Succ).second)
275 return nullptr;
276 BB = Succ;
277 }
278 return BB->getTerminatingDeoptimizeCall();
279}
280
282 if (InstList.empty())
283 return nullptr;
284 for (const Instruction &I : *this)
286 return &I;
287 return nullptr;
288}
289
291 for (const Instruction &I : *this) {
292 if (isa<PHINode>(I))
293 continue;
294
295 BasicBlock::const_iterator It = I.getIterator();
296 // Set the head-inclusive bit to indicate that this iterator includes
297 // any debug-info at the start of the block. This is a no-op unless the
298 // appropriate CMake flag is set.
299 It.setHeadBit(true);
300 return It;
301 }
302
303 return end();
304}
305
307BasicBlock::getFirstNonPHIOrDbg(bool SkipPseudoOp) const {
308 for (const Instruction &I : *this) {
310 continue;
311
312 if (SkipPseudoOp && isa<PseudoProbeInst>(I))
313 continue;
314
315 BasicBlock::const_iterator It = I.getIterator();
316 // This position comes after any debug records, the head bit should remain
317 // unset.
318 assert(!It.getHeadBit());
319 return It;
320 }
321 return end();
322}
323
325BasicBlock::getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp) const {
326 for (const Instruction &I : *this) {
328 continue;
329
330 if (I.isLifetimeStartOrEnd())
331 continue;
332
333 if (SkipPseudoOp && isa<PseudoProbeInst>(I))
334 continue;
335
336 BasicBlock::const_iterator It = I.getIterator();
337 // This position comes after any debug records, the head bit should remain
338 // unset.
339 assert(!It.getHeadBit());
340
341 return It;
342 }
343 return end();
344}
345
347 const_iterator InsertPt = getFirstNonPHIIt();
348 if (InsertPt == end())
349 return end();
350
351 if (InsertPt->isEHPad()) ++InsertPt;
352 // Set the head-inclusive bit to indicate that this iterator includes
353 // any debug-info at the start of the block. This is a no-op unless the
354 // appropriate CMake flag is set.
355 InsertPt.setHeadBit(true);
356 return InsertPt;
357}
358
360 const_iterator InsertPt = getFirstNonPHIIt();
361 if (InsertPt == end())
362 return end();
363
364 if (InsertPt->isEHPad())
365 ++InsertPt;
366
367 if (isEntryBlock()) {
368 const_iterator End = end();
369 while (InsertPt != End &&
370 (isa<AllocaInst>(*InsertPt) || isa<DbgInfoIntrinsic>(*InsertPt) ||
371 isa<PseudoProbeInst>(*InsertPt))) {
372 if (const AllocaInst *AI = dyn_cast<AllocaInst>(&*InsertPt)) {
373 if (!AI->isStaticAlloca())
374 break;
375 }
376 ++InsertPt;
377 }
378 }
379
380 // Signal that this comes after any debug records.
381 InsertPt.setHeadBit(false);
382 return InsertPt;
383}
384
386 for (Instruction &I : *this)
387 I.dropAllReferences();
388}
389
391 const_pred_iterator PI = pred_begin(this), E = pred_end(this);
392 if (PI == E) return nullptr; // No preds.
393 const BasicBlock *ThePred = *PI;
394 ++PI;
395 return (PI == E) ? ThePred : nullptr /*multiple preds*/;
396}
397
399 const_pred_iterator PI = pred_begin(this), E = pred_end(this);
400 if (PI == E) return nullptr; // No preds.
401 const BasicBlock *PredBB = *PI;
402 ++PI;
403 for (;PI != E; ++PI) {
404 if (*PI != PredBB)
405 return nullptr;
406 // The same predecessor appears multiple times in the predecessor list.
407 // This is OK.
408 }
409 return PredBB;
410}
411
412bool BasicBlock::hasNPredecessors(unsigned N) const {
413 return hasNItems(pred_begin(this), pred_end(this), N);
414}
415
416bool BasicBlock::hasNPredecessorsOrMore(unsigned N) const {
417 return hasNItemsOrMore(pred_begin(this), pred_end(this), N);
418}
419
421 const_succ_iterator SI = succ_begin(this), E = succ_end(this);
422 if (SI == E) return nullptr; // no successors
423 const BasicBlock *TheSucc = *SI;
424 ++SI;
425 return (SI == E) ? TheSucc : nullptr /* multiple successors */;
426}
427
429 const_succ_iterator SI = succ_begin(this), E = succ_end(this);
430 if (SI == E) return nullptr; // No successors
431 const BasicBlock *SuccBB = *SI;
432 ++SI;
433 for (;SI != E; ++SI) {
434 if (*SI != SuccBB)
435 return nullptr;
436 // The same successor appears multiple times in the successor list.
437 // This is OK.
438 }
439 return SuccBB;
440}
441
443 PHINode *P = empty() ? nullptr : dyn_cast<PHINode>(&*begin());
444 return make_range<phi_iterator>(P, nullptr);
445}
446
448 bool KeepOneInputPHIs) {
449 // Use hasNUsesOrMore to bound the cost of this assertion for complex CFGs.
450 assert((hasNUsesOrMore(16) || llvm::is_contained(predecessors(this), Pred)) &&
451 "Pred is not a predecessor!");
452
453 // Return early if there are no PHI nodes to update.
454 if (empty() || !isa<PHINode>(begin()))
455 return;
456
457 unsigned NumPreds = cast<PHINode>(front()).getNumIncomingValues();
458 for (PHINode &Phi : make_early_inc_range(phis())) {
459 Phi.removeIncomingValue(Pred, !KeepOneInputPHIs);
460 if (KeepOneInputPHIs)
461 continue;
462
463 // If we have a single predecessor, removeIncomingValue may have erased the
464 // PHI node itself.
465 if (NumPreds == 1)
466 continue;
467
468 // Try to replace the PHI node with a constant value.
469 if (Value *PhiConstant = Phi.hasConstantValue()) {
470 Phi.replaceAllUsesWith(PhiConstant);
471 Phi.eraseFromParent();
472 }
473 }
474}
475
477 const_iterator FirstNonPHI = getFirstNonPHIIt();
478 if (isa<LandingPadInst>(FirstNonPHI))
479 return true;
480 // This is perhaps a little conservative because constructs like
481 // CleanupBlockInst are pretty easy to split. However, SplitBlockPredecessors
482 // cannot handle such things just yet.
483 if (FirstNonPHI->isEHPad())
484 return false;
485 return true;
486}
487
489 auto *Term = getTerminator();
490 // No terminator means the block is under construction.
491 if (!Term)
492 return true;
493
494 // If the block has no successors, there can be no instructions to hoist.
495 assert(Term->getNumSuccessors() > 0);
496
497 // Instructions should not be hoisted across special terminators, which may
498 // have side effects or return values.
499 return !Term->isSpecialTerminator();
500}
501
502bool BasicBlock::isEntryBlock() const {
503 const Function *F = getParent();
504 assert(F && "Block must have a parent function to use this API");
505 return this == &F->getEntryBlock();
506}
507
508BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName) {
509 assert(getTerminator() && "Can't use splitBasicBlock on degenerate BB!");
510 assert(I != InstList.end() &&
511 "Trying to get me to create degenerate basic block!");
512
514 this->getNextNode());
515
516 // Save DebugLoc of split point before invalidating iterator.
517 DebugLoc Loc = I->getStableDebugLoc();
518 if (Loc)
519 Loc = Loc->getWithoutAtom();
520
521 // Move all of the specified instructions from the original basic block into
522 // the new basic block.
523 New->splice(New->end(), this, I, end());
524
525 // Add a branch instruction to the newly formed basic block.
526 UncondBrInst *BI = UncondBrInst::Create(New, this);
527 BI->setDebugLoc(Loc);
528
529 // Now we must loop through all of the successors of the New block (which
530 // _were_ the successors of the 'this' block), and update any PHI nodes in
531 // successors. If there were PHI nodes in the successors, then they need to
532 // know that incoming branches will be from New, not from Old (this).
533 //
534 New->replaceSuccessorsPhiUsesWith(this, New);
535 return New;
536}
537
538BasicBlock *BasicBlock::splitBasicBlockBefore(iterator I, const Twine &BBName) {
540 "Can't use splitBasicBlockBefore on degenerate BB!");
541 assert(I != InstList.end() &&
542 "Trying to get me to create degenerate basic block!");
543
544 assert((!isa<PHINode>(*I) || getSinglePredecessor()) &&
545 "cannot split on multi incoming phis");
546
548 // Save DebugLoc of split point before invalidating iterator.
549 DebugLoc Loc = I->getDebugLoc();
550 if (Loc)
551 Loc = Loc->getWithoutAtom();
552
553 // Move all of the specified instructions from the original basic block into
554 // the new basic block.
555 New->splice(New->end(), this, begin(), I);
556
557 // Loop through all of the predecessors of the 'this' block (which will be the
558 // predecessors of the New block), replace the specified successor 'this'
559 // block to point at the New block and update any PHI nodes in 'this' block.
560 // If there were PHI nodes in 'this' block, the PHI nodes are updated
561 // to reflect that the incoming branches will be from the New block and not
562 // from predecessors of the 'this' block.
563 // Save predecessors to separate vector before modifying them.
564 SmallVector<BasicBlock *, 4> Predecessors(predecessors(this));
565 for (BasicBlock *Pred : Predecessors) {
566 Instruction *TI = Pred->getTerminator();
567 TI->replaceSuccessorWith(this, New);
568 this->replacePhiUsesWith(Pred, New);
569 }
570 // Add a branch instruction from "New" to "this" Block.
571 UncondBrInst *BI = UncondBrInst::Create(this, New);
572 BI->setDebugLoc(Loc);
573
574 return New;
575}
576
579 for (Instruction &I : make_early_inc_range(make_range(FromIt, ToIt)))
580 I.eraseFromParent();
581 return ToIt;
582}
583
585 // N.B. This might not be a complete BasicBlock, so don't assume
586 // that it ends with a non-phi instruction.
587 for (Instruction &I : *this) {
589 if (!PN)
590 break;
591 PN->replaceIncomingBlockWith(Old, New);
592 }
593}
594
596 BasicBlock *New) {
597 Instruction *TI = getTerminatorOrNull();
598 if (!TI)
599 // Cope with being called on a BasicBlock that doesn't have a terminator
600 // yet. Clang's CodeGenFunction::EmitReturnBlock() likes to do this.
601 return;
602 for (BasicBlock *Succ : successors(TI))
603 Succ->replacePhiUsesWith(Old, New);
604}
605
607 this->replaceSuccessorsPhiUsesWith(this, New);
608}
609
610bool BasicBlock::isLandingPad() const {
611 return isa<LandingPadInst>(getFirstNonPHIIt());
612}
613
615 return dyn_cast<LandingPadInst>(getFirstNonPHIIt());
616}
617
618std::optional<uint64_t> BasicBlock::getIrrLoopHeaderWeight() const {
619 const Instruction *TI = getTerminator();
620 if (MDNode *MDIrrLoopHeader =
621 TI->getMetadata(LLVMContext::MD_irr_loop)) {
622 MDString *MDName = cast<MDString>(MDIrrLoopHeader->getOperand(0));
623 if (MDName->getString() == "loop_header_weight") {
624 auto *CI = mdconst::extract<ConstantInt>(MDIrrLoopHeader->getOperand(1));
625 return std::optional<uint64_t>(CI->getValue().getZExtValue());
626 }
627 }
628 return std::nullopt;
629}
630
632 while (isa<DbgInfoIntrinsic>(It))
633 ++It;
634 return It;
635}
636
638 unsigned Order = 0;
639 for (Instruction &I : *this)
640 I.Order = Order++;
641
642 // Set the bit to indicate that the instruction order valid and cached.
643 SubclassOptionalData |= InstrOrderValid;
644
645 NumInstrRenumberings++;
646}
647
649 // If we erase the terminator in a block, any DbgRecords will sink and "fall
650 // off the end", existing after any terminator that gets inserted. With
651 // dbg.value intrinsics we would just insert the terminator at end() and
652 // the dbg.values would come before the terminator. With DbgRecords, we must
653 // do this manually.
654 // To get out of this unfortunate form, whenever we insert a terminator,
655 // check whether there's anything trailing at the end and move those
656 // DbgRecords in front of the terminator.
657
658 // If there's no terminator, there's nothing to do.
659 Instruction *Term = getTerminatorOrNull();
660 if (!Term)
661 return;
662
663 // Are there any dangling DbgRecords?
664 DbgMarker *TrailingDbgRecords = getTrailingDbgRecords();
665 if (!TrailingDbgRecords)
666 return;
667
668 // Transfer DbgRecords from the trailing position onto the terminator.
669 createMarker(Term);
670 Term->DebugMarker->absorbDebugValues(*TrailingDbgRecords, false);
671 TrailingDbgRecords->eraseFromParent();
672 deleteTrailingDbgRecords();
673}
674
675void BasicBlock::spliceDebugInfoEmptyBlock(BasicBlock::iterator Dest,
676 BasicBlock *Src,
679 // Imagine the folowing:
680 //
681 // bb1:
682 // dbg.value(...
683 // ret i32 0
684 //
685 // If an optimisation pass attempts to splice the contents of the block from
686 // BB1->begin() to BB1->getTerminator(), then the dbg.value will be
687 // transferred to the destination.
688 // However, in the "new" DbgRecord format for debug-info, that range is empty:
689 // begin() returns an iterator to the terminator, as there will only be a
690 // single instruction in the block. We must piece together from the bits set
691 // in the iterators whether there was the intention to transfer any debug
692 // info.
693
694 assert(First == Last);
695 bool InsertAtHead = Dest.getHeadBit();
696 bool ReadFromHead = First.getHeadBit();
697
698 // If the source block is completely empty, including no terminator, then
699 // transfer any trailing DbgRecords that are still hanging around. This can
700 // occur when a block is optimised away and the terminator has been moved
701 // somewhere else.
702 if (Src->empty()) {
703 DbgMarker *SrcTrailingDbgRecords = Src->getTrailingDbgRecords();
704 if (!SrcTrailingDbgRecords)
705 return;
706
707 Dest->adoptDbgRecords(Src, Src->end(), InsertAtHead);
708 // adoptDbgRecords should have released the trailing DbgRecords.
709 assert(!Src->getTrailingDbgRecords());
710 return;
711 }
712
713 // There are instructions in this block; if the First iterator was
714 // with begin() / getFirstInsertionPt() then the caller intended debug-info
715 // at the start of the block to be transferred. Return otherwise.
716 if (Src->empty() || First != Src->begin() || !ReadFromHead)
717 return;
718
719 // Is there actually anything to transfer?
720 if (!First->hasDbgRecords())
721 return;
722
723 createMarker(Dest)->absorbDebugValues(*First->DebugMarker, InsertAtHead);
724}
725
726void BasicBlock::spliceDebugInfo(BasicBlock::iterator Dest, BasicBlock *Src,
729 /* Do a quick normalisation before calling the real splice implementation. We
730 might be operating on a degenerate basic block that has no instructions
731 in it, a legitimate transient state. In that case, Dest will be end() and
732 any DbgRecords temporarily stored in the TrailingDbgRecords map in
733 LLVMContext. We might illustrate it thus:
734
735 Dest
736 |
737 this-block: ~~~~~~~~
738 Src-block: ++++B---B---B---B:::C
739 | |
740 First Last
741
742 However: does the caller expect the "~" DbgRecords to end up before or
743 after the spliced segment? This is communciated in the "Head" bit of Dest,
744 which signals whether the caller called begin() or end() on this block.
745
746 If the head bit is set, then all is well, we leave DbgRecords trailing just
747 like how dbg.value instructions would trail after instructions spliced to
748 the beginning of this block.
749
750 If the head bit isn't set, then try to jam the "~" DbgRecords onto the
751 front of the First instruction, then splice like normal, which joins the
752 "~" DbgRecords with the "+" DbgRecords. However if the "+" DbgRecords are
753 supposed to be left behind in Src, then:
754 * detach the "+" DbgRecords,
755 * move the "~" DbgRecords onto First,
756 * splice like normal,
757 * replace the "+" DbgRecords onto the Last position.
758 Complicated, but gets the job done. */
759
760 // If we're inserting at end(), and not in front of dangling DbgRecords, then
761 // move the DbgRecords onto "First". They'll then be moved naturally in the
762 // splice process.
763 DbgMarker *MoreDanglingDbgRecords = nullptr;
764 DbgMarker *OurTrailingDbgRecords = getTrailingDbgRecords();
765 if (Dest == end() && !Dest.getHeadBit() && OurTrailingDbgRecords) {
766 // Are the "+" DbgRecords not supposed to move? If so, detach them
767 // temporarily.
768 if (!First.getHeadBit() && First->hasDbgRecords()) {
769 MoreDanglingDbgRecords = Src->getMarker(First);
770 MoreDanglingDbgRecords->removeFromParent();
771 }
772
773 if (First->hasDbgRecords()) {
774 // Place them at the front, it would look like this:
775 // Dest
776 // |
777 // this-block:
778 // Src-block: ~~~~~~~~++++B---B---B---B:::C
779 // | |
780 // First Last
781 First->adoptDbgRecords(this, end(), true);
782 } else {
783 // No current marker, create one and absorb in. (FIXME: we can avoid an
784 // allocation in the future).
785 DbgMarker *CurMarker = Src->createMarker(&*First);
786 CurMarker->absorbDebugValues(*OurTrailingDbgRecords, false);
787 OurTrailingDbgRecords->eraseFromParent();
788 }
789 deleteTrailingDbgRecords();
790 First.setHeadBit(true);
791 }
792
793 // Call the main debug-info-splicing implementation.
794 spliceDebugInfoImpl(Dest, Src, First, Last);
795
796 // Do we have some "+" DbgRecords hanging around that weren't supposed to
797 // move, and we detached to make things easier?
798 if (!MoreDanglingDbgRecords)
799 return;
800
801 // FIXME: we could avoid an allocation here sometimes. (adoptDbgRecords
802 // requires an iterator).
803 DbgMarker *LastMarker = Src->createMarker(Last);
804 LastMarker->absorbDebugValues(*MoreDanglingDbgRecords, true);
805 MoreDanglingDbgRecords->eraseFromParent();
806}
807
808void BasicBlock::spliceDebugInfoImpl(BasicBlock::iterator Dest, BasicBlock *Src,
811 // Find out where to _place_ these dbg.values; if InsertAtHead is specified,
812 // this will be at the start of Dest's debug value range, otherwise this is
813 // just Dest's marker.
814 bool InsertAtHead = Dest.getHeadBit();
815 bool ReadFromHead = First.getHeadBit();
816 // Use this flag to signal the abnormal case, where we don't want to copy the
817 // DbgRecords ahead of the "Last" position.
818 bool ReadFromTail = !Last.getTailBit();
819 bool LastIsEnd = (Last == Src->end());
820
821 /*
822 Here's an illustration of what we're about to do. We have two blocks, this
823 and Src, and two segments of list. Each instruction is marked by a capital
824 while potential DbgRecord debug-info is marked out by "-" characters and a
825 few other special characters (+:=) where I want to highlight what's going
826 on.
827
828 Dest
829 |
830 this-block: A----A----A ====A----A----A----A---A---A
831 Src-block ++++B---B---B---B:::C
832 | |
833 First Last
834
835 The splice method is going to take all the instructions from First up to
836 (but not including) Last and insert them in _front_ of Dest, forming one
837 long list. All the DbgRecords attached to instructions _between_ First and
838 Last need no maintenence. However, we have to do special things with the
839 DbgRecords marked with the +:= characters. We only have three positions:
840 should the "+" DbgRecords be transferred, and if so to where? Do we move the
841 ":" DbgRecords? Would they go in front of the "=" DbgRecords, or should the
842 "=" DbgRecords go before "+" DbgRecords?
843
844 We're told which way it should be by the bits carried in the iterators. The
845 "Head" bit indicates whether the specified position is supposed to be at the
846 front of the attached DbgRecords (true) or not (false). The Tail bit is true
847 on the other end of a range: is the range intended to include DbgRecords up
848 to the end (false) or not (true).
849
850 FIXME: the tail bit doesn't need to be distinct from the head bit, we could
851 combine them.
852
853 Here are some examples of different configurations:
854
855 Dest.Head = true, First.Head = true, Last.Tail = false
856
857 this-block: A----A----A++++B---B---B---B:::====A----A----A----A---A---A
858 | |
859 First Dest
860
861 Wheras if we didn't want to read from the Src list,
862
863 Dest.Head = true, First.Head = false, Last.Tail = false
864
865 this-block: A----A----AB---B---B---B:::====A----A----A----A---A---A
866 | |
867 First Dest
868
869 Or if we didn't want to insert at the head of Dest:
870
871 Dest.Head = false, First.Head = false, Last.Tail = false
872
873 this-block: A----A----A====B---B---B---B:::A----A----A----A---A---A
874 | |
875 First Dest
876
877 Tests for these various configurations can be found in the unit test file
878 BasicBlockDbgInfoTest.cpp.
879
880 */
881
882 // Detach the marker at Dest -- this lets us move the "====" DbgRecords
883 // around.
884 DbgMarker *DestMarker = nullptr;
885 if ((DestMarker = getMarker(Dest))) {
886 if (Dest == end()) {
887 assert(DestMarker == getTrailingDbgRecords());
888 deleteTrailingDbgRecords();
889 } else {
890 DestMarker->removeFromParent();
891 }
892 }
893
894 // If we're moving the tail range of DbgRecords (":::"), absorb them into the
895 // front of the DbgRecords at Dest.
896 if (ReadFromTail && Src->getMarker(Last)) {
897 DbgMarker *FromLast = Src->getMarker(Last);
898 if (LastIsEnd) {
899 if (Dest == end()) {
900 // Abosrb the trailing markers from Src.
901 assert(FromLast == Src->getTrailingDbgRecords());
902 createMarker(Dest)->absorbDebugValues(*FromLast, true);
903 FromLast->eraseFromParent();
904 Src->deleteTrailingDbgRecords();
905 } else {
906 // adoptDbgRecords will release any trailers.
907 Dest->adoptDbgRecords(Src, Last, true);
908 }
909 assert(!Src->getTrailingDbgRecords());
910 } else {
911 // FIXME: can we use adoptDbgRecords here to reduce allocations?
912 DbgMarker *OntoDest = createMarker(Dest);
913 OntoDest->absorbDebugValues(*FromLast, true);
914 }
915 }
916
917 // If we're _not_ reading from the head of First, i.e. the "++++" DbgRecords,
918 // move their markers onto Last. They remain in the Src block. No action
919 // needed.
920 if (!ReadFromHead && First->hasDbgRecords()) {
921 if (Last != Src->end()) {
922 Last->adoptDbgRecords(Src, First, true);
923 } else {
924 DbgMarker *OntoLast = Src->createMarker(Last);
925 DbgMarker *FromFirst = Src->createMarker(First);
926 // Always insert at front of Last.
927 OntoLast->absorbDebugValues(*FromFirst, true);
928 }
929 }
930
931 // Finally, do something with the "====" DbgRecords we detached.
932 if (DestMarker) {
933 if (InsertAtHead) {
934 // Insert them at the end of the DbgRecords at Dest. The "::::" DbgRecords
935 // might be in front of them.
936 DbgMarker *NewDestMarker = createMarker(Dest);
937 NewDestMarker->absorbDebugValues(*DestMarker, false);
938 } else {
939 // Insert them right at the start of the range we moved, ahead of First
940 // and the "++++" DbgRecords.
941 // This also covers the rare circumstance where we insert at end(), and we
942 // did not generate the iterator with begin() / getFirstInsertionPt(),
943 // meaning any trailing debug-info at the end of the block would
944 // "normally" have been pushed in front of "First". We move it there now.
945 DbgMarker *FirstMarker = createMarker(First);
946 FirstMarker->absorbDebugValues(*DestMarker, true);
947 }
948 DestMarker->eraseFromParent();
949 }
950}
951
952void BasicBlock::splice(iterator Dest, BasicBlock *Src, iterator First,
953 iterator Last) {
954#ifdef EXPENSIVE_CHECKS
955 // Check that First is before Last.
956 auto FromBBEnd = Src->end();
957 for (auto It = First; It != Last; ++It)
958 assert(It != FromBBEnd && "FromBeginIt not before FromEndIt!");
959#endif // EXPENSIVE_CHECKS
960
961 // Lots of horrible special casing for empty transfers: the dbg.values between
962 // two positions could be spliced in dbg.value mode.
963 if (First == Last) {
964 spliceDebugInfoEmptyBlock(Dest, Src, First, Last);
965 return;
966 }
967
968 spliceDebugInfo(Dest, Src, First, Last);
969
970 // And move the instructions.
971 getInstList().splice(Dest, Src->getInstList(), First, Last);
972
973 flushTerminatorDbgRecords();
974}
975
977 assert(I->getParent() == this);
978
979 iterator NextIt = std::next(I->getIterator());
980 DbgMarker *NextMarker = createMarker(NextIt);
981 NextMarker->insertDbgRecord(DR, true);
982}
983
985 InstListType::iterator Where) {
986 assert(Where == end() || Where->getParent() == this);
987 bool InsertAtHead = Where.getHeadBit();
988 DbgMarker *M = createMarker(Where);
989 M->insertDbgRecord(DR, InsertAtHead);
990}
991
993 return getMarker(std::next(I->getIterator()));
994}
995
996DbgMarker *BasicBlock::getMarker(InstListType::iterator It) {
997 if (It == end()) {
998 DbgMarker *DM = getTrailingDbgRecords();
999 return DM;
1000 }
1001 return It->DebugMarker;
1002}
1003
1005 Instruction *I, std::optional<DbgRecord::self_iterator> Pos) {
1006 // "I" was originally removed from a position where it was
1007 // immediately in front of Pos. Any DbgRecords on that position then "fell
1008 // down" onto Pos. "I" has been re-inserted at the front of that wedge of
1009 // DbgRecords, shuffle them around to represent the original positioning. To
1010 // illustrate:
1011 //
1012 // Instructions: I1---I---I0
1013 // DbgRecords: DDD DDD
1014 //
1015 // Instruction "I" removed,
1016 //
1017 // Instructions: I1------I0
1018 // DbgRecords: DDDDDD
1019 // ^Pos
1020 //
1021 // Instruction "I" re-inserted (now):
1022 //
1023 // Instructions: I1---I------I0
1024 // DbgRecords: DDDDDD
1025 // ^Pos
1026 //
1027 // After this method completes:
1028 //
1029 // Instructions: I1---I---I0
1030 // DbgRecords: DDD DDD
1031
1032 // This happens if there were no DbgRecords on I0. Are there now DbgRecords
1033 // there?
1034 if (!Pos) {
1035 DbgMarker *NextMarker = getNextMarker(I);
1036 if (!NextMarker)
1037 return;
1038 if (NextMarker->StoredDbgRecords.empty())
1039 return;
1040 // There are DbgMarkers there now -- they fell down from "I".
1041 DbgMarker *ThisMarker = createMarker(I);
1042 ThisMarker->absorbDebugValues(*NextMarker, false);
1043 return;
1044 }
1045
1046 // Is there even a range of DbgRecords to move?
1047 DbgMarker *DM = (*Pos)->getMarker();
1048 auto Range = make_range(DM->StoredDbgRecords.begin(), (*Pos));
1049 if (Range.begin() == Range.end())
1050 return;
1051
1052 // Otherwise: splice.
1053 DbgMarker *ThisMarker = createMarker(I);
1054 assert(ThisMarker->StoredDbgRecords.empty());
1055 ThisMarker->absorbDebugValues(Range, *DM, true);
1056}
1057
1058#ifndef NDEBUG
1059/// In asserts builds, this checks the numbering. In non-asserts builds, it
1060/// is defined as a no-op inline function in BasicBlock.h.
1062 if (!isInstrOrderValid())
1063 return;
1064 const Instruction *Prev = nullptr;
1065 for (const Instruction &I : *this) {
1066 assert((!Prev || Prev->comesBefore(&I)) &&
1067 "cached instruction ordering is incorrect");
1068 Prev = &I;
1069 }
1070}
1071#endif
1072
1074 getContext().pImpl->setTrailingDbgRecords(this, foo);
1075}
1076
1078 return getContext().pImpl->getTrailingDbgRecords(this);
1079}
1080
1082 getContext().pImpl->deleteTrailingDbgRecords(this);
1083}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
VarLocInsertPt getNextNode(const DbgRecord *DVR)
static const Function * getParent(const Value *V)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static RegisterPass< DebugifyModulePass > DM("debugify", "Attach debug info to everything")
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
Machine Check Debug Module
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
#define P(N)
StandardInstrumentations SI(Mod->getContext(), Debug, VerifyEach)
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
This file contains some templates that are useful if you are working with the STL at all.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Definition Statistic.h:171
static SymbolRef::Type getType(const Symbol *Sym)
Definition TapiFile.cpp:39
an instruction to allocate memory on the stack
LLVM Basic Block Representation.
Definition BasicBlock.h:62
LLVM_ABI BasicBlock::iterator erase(BasicBlock::iterator FromIt, BasicBlock::iterator ToIt)
Erases a range of instructions from FromIt to (not including) ToIt.
LLVM_ABI 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...
LLVM_ABI void deleteTrailingDbgRecords()
Delete any trailing DbgRecords at the end of this block, see setTrailingDbgRecords.
iterator_range< const_phi_iterator > phis() const
Returns a range that iterates over the phis in the basic block.
Definition BasicBlock.h:515
LLVM_ABI const LandingPadInst * getLandingPadInst() const
Return the landingpad instruction associated with the landing pad.
LLVM_ABI void setTrailingDbgRecords(DbgMarker *M)
Record that the collection of DbgRecords in M "trails" after the last instruction of this block.
LLVM_ABI const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
LLVM_ABI BasicBlock * splitBasicBlock(iterator I, const Twine &BBName="")
Split the basic block into two basic blocks at the specified instruction.
const Function * getParent() const
Return the enclosing method, or null if none.
Definition BasicBlock.h:213
LLVM_ABI void renumberInstructions()
Renumber instructions and mark the ordering as valid.
LLVM_ABI DbgMarker * createMarker(Instruction *I)
Attach a DbgMarker to the given instruction.
LLVM_ABI 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...
LLVM_ABI InstListType::const_iterator getFirstNonPHIIt() const
Returns an iterator to the first instruction in this block that is not a PHINode instruction.
LLVM_ABI void insertDbgRecordBefore(DbgRecord *DR, InstListType::iterator Here)
Insert a DbgRecord into a block at the position given by Here.
void invalidateOrders()
Mark instruction ordering invalid. Done on every instruction insert.
Definition BasicBlock.h:719
friend void Instruction::removeFromParent()
LLVM_ABI void convertToNewDbgValues()
Convert variable location debugging information stored in dbg.value intrinsics into DbgMarkers / DbgR...
InstListType::const_iterator const_iterator
Definition BasicBlock.h:171
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Definition BasicBlock.h:206
friend BasicBlock::iterator Instruction::eraseFromParent()
LLVM_ABI bool isEntryBlock() const
Return true if this is the entry block of the containing function.
LLVM_ABI ValueSymbolTable * getValueSymbolTable()
Returns a pointer to the symbol table if one exists.
LLVM_ABI void moveAfter(BasicBlock *MovePos)
Unlink this basic block from its current function and insert it right after MovePos in the function M...
LLVM_ABI 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,...
LLVM_ABI bool hasNPredecessors(unsigned N) const
Return true if this block has exactly N predecessors.
LLVM_ABI bool convertFromNewDbgValues()
Convert variable location debugging information stored in DbgMarkers and DbgRecords into the dbg....
LLVM_ABI const BasicBlock * getUniqueSuccessor() const
Return the successor of this block if it has a unique successor.
LLVM_ABI const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
LLVM_ABI std::optional< uint64_t > getIrrLoopHeaderWeight() const
LLVM_ABI void dumpDbgValues() const
LLVM_ABI const CallInst * getTerminatingDeoptimizeCall() const
Returns the call instruction calling @llvm.experimental.deoptimize prior to the terminating return in...
LLVM_ABI 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.
LLVM_ABI const BasicBlock * getUniquePredecessor() const
Return the predecessor of this block if it has a unique predecessor block.
LLVM_ABI const BasicBlock * getSingleSuccessor() const
Return the successor of this block if it has a single successor.
LLVM_ABI void flushTerminatorDbgRecords()
Eject any debug-info trailing at the end of a block.
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this basic block belongs to.
LLVM_ABI void insertDbgRecordAfter(DbgRecord *DR, Instruction *I)
Insert a DbgRecord into a block at the position given by I.
LLVM_ABI void validateInstrOrdering() const
Asserts that instruction order numbers are marked invalid, or that they are in ascending order.
LLVM_ABI DbgMarker * getMarker(InstListType::iterator It)
Return the DbgMarker for the position given by It, so that DbgRecords can be inserted there.
LLVM_ABI ~BasicBlock()
InstListType::iterator iterator
Instruction iterators...
Definition BasicBlock.h:170
LLVM_ABI LLVMContext & getContext() const
Get the context in which this basic block lives.
LLVM_ABI const_iterator getFirstNonPHIOrDbgOrAlloca() const
Returns an iterator to the first instruction in this block that is not a PHINode, a debug intrinsic,...
LLVM_ABI void dropAllReferences()
Cause all subinstructions to "let go" of all the references that said subinstructions are maintaining...
LLVM_ABI 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 ...
void moveBefore(BasicBlock *MovePos)
Unlink this basic block from its current function and insert it into the function that MovePos lives ...
Definition BasicBlock.h:373
LLVM_ABI 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,...
LLVM_ABI bool isLandingPad() const
Return true if this basic block is a landing pad.
LLVM_ABI DbgMarker * getTrailingDbgRecords()
Fetch the collection of DbgRecords that "trail" after the last instruction of this block,...
LLVM_ABI bool canSplitPredecessors() const
LLVM_ABI const CallInst * getTerminatingMustTailCall() const
Returns the call instruction marked 'musttail' prior to the terminating return instruction of this ba...
friend BasicBlock::iterator Instruction::insertInto(BasicBlock *BB, BasicBlock::iterator It)
LLVM_ABI bool isLegalToHoistInto() const
Return true if it is legal to hoist instructions into this block.
LLVM_ABI bool hasNPredecessorsOrMore(unsigned N) const
Return true if this block has N predecessors or more.
LLVM_ABI const CallInst * getPostdominatingDeoptimizeCall() const
Returns the call instruction calling @llvm.experimental.deoptimize that is present either in current ...
LLVM_ABI DbgMarker * getNextMarker(Instruction *I)
Return the DbgMarker for the position that comes after I.
LLVM_ABI const Instruction * getFirstMayFaultInst() const
Returns the first potential AsynchEH faulty instruction currently it checks for loads/stores (which m...
void splice(BasicBlock::iterator ToIt, BasicBlock *FromBB)
Transfer all instructions from FromBB to this basic block at ToIt.
Definition BasicBlock.h:644
LLVM_ABI const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr if the function does no...
LLVM_ABI void removePredecessor(BasicBlock *Pred, bool KeepOneInputPHIs=false)
Update PHI nodes in this BasicBlock before removal of predecessor Pred.
The address of a basic block.
Definition Constants.h:1088
static LLVM_ABI BlockAddress * lookup(const BasicBlock *BB)
Lookup an existing BlockAddress constant for the given BasicBlock.
This class represents a function call, abstracting a target machine's calling convention.
static LLVM_ABI Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
LLVM_ABI void destroyConstant()
Called if some element of this constant is no longer valid.
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
This represents the llvm.dbg.label instruction.
Records a position in IR for a source label (DILabel).
Per-instruction record of debug-info.
LLVM_ABI void removeFromParent()
Instruction * MarkedInstr
Link back to the Instruction that owns this marker.
LLVM_ABI void eraseFromParent()
LLVM_ABI iterator_range< simple_ilist< DbgRecord >::iterator > getDbgRecordRange()
Produce a range over all the DbgRecords in this Marker.
LLVM_ABI void insertDbgRecord(DbgRecord *New, bool InsertAtHead)
Insert a DbgRecord into this DbgMarker, at the end of the list.
simple_ilist< DbgRecord > StoredDbgRecords
List of DbgRecords, the non-instruction equivalent of llvm.dbg.
LLVM_ABI void absorbDebugValues(DbgMarker &Src, bool InsertAtHead)
Transfer any DbgRecords from Src into this DbgMarker.
Base class for non-instruction debug metadata records that have positions within IR.
This is the common base class for debug info intrinsics for variables.
Record of a variable value-assignment, aka a non instruction representation of the dbg....
A debug info location.
Definition DebugLoc.h:126
void splice(Function::iterator ToIt, Function *FromF)
Transfer all blocks from FromF to this function at ToIt.
Definition Function.h:746
Function::iterator insert(Function::iterator Position, BasicBlock *BB)
Insert BB in the basic block list at Position.
Definition Function.h:740
iterator end()
Definition Function.h:840
LLVM_ABI void replaceSuccessorWith(BasicBlock *OldBB, BasicBlock *NewBB)
Replace specified successor OldBB to point at the provided block.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
LLVM_ABI bool comesBefore(const Instruction *Other) const
Given an instruction Other in the same basic block as this instruction, return true if this instructi...
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
The landingpad instruction holds all of the information necessary to generate correct exception handl...
Metadata node.
Definition Metadata.h:1069
A single uniqued string.
Definition Metadata.h:722
LLVM_ABI StringRef getString() const
Definition Metadata.cpp:633
void replaceIncomingBlockWith(const BasicBlock *Old, BasicBlock *New)
Replace every incoming basic block Old to basic block New.
Return a value (possibly void), from a function.
Value * getReturnValue() const
Convenience accessor. Returns null if there is no return value.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
Definition Type.cpp:309
Unconditional Branch instruction.
static UncondBrInst * Create(BasicBlock *Target, InsertPosition InsertBefore=nullptr)
This class provides a symbol table of name/value pairs.
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:255
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition Value.cpp:553
self_iterator getIterator()
Definition ilist_node.h:123
A range adaptor for a pair of iterators.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
Definition Metadata.h:668
NodeAddr< PhiNode * > Phi
Definition RDFGraph.h:390
bool empty() const
Definition BasicBlock.h:101
iterator end() const
Definition BasicBlock.h:89
LLVM_ABI iterator begin() const
LLVM_ABI Instruction * getTerminator() const
LLVM_ABI Instruction & front() const
This is an optimization pass for GlobalISel generic memory operations.
auto pred_end(const MachineBasicBlock *BB)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
auto successors(const MachineBasicBlock *BB)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
Definition STLExtras.h:633
PredIterator< const BasicBlock, Value::const_user_iterator > const_pred_iterator
Definition CFG.h:94
bool hasNItemsOrMore(IterTy &&Begin, IterTy &&End, unsigned N, Pred &&ShouldBeCounted=[](const decltype(*std::declval< IterTy >()) &) { return true;}, std::enable_if_t< !std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< std::remove_reference_t< decltype(Begin)> >::iterator_category >::value, void > *=nullptr)
Return true if the sequence [Begin, End) has N or more items.
Definition STLExtras.h:2638
auto dyn_cast_or_null(const Y &Val)
Definition Casting.h:753
LLVM_ABI BasicBlock::iterator skipDebugIntrinsics(BasicBlock::iterator It)
Advance It while it points to a debug instruction and return the result.
bool hasNItems(IterTy &&Begin, IterTy &&End, unsigned N, Pred &&ShouldBeCounted=[](const decltype(*std::declval< IterTy >()) &) { return true;}, std::enable_if_t< !std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< std::remove_reference_t< decltype(Begin)> >::iterator_category >::value, void > *=nullptr)
Return true if the sequence [Begin, End) has exactly N items.
Definition STLExtras.h:2613
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
RNSuccIterator< NodeRef, BlockT, RegionT > succ_begin(NodeRef Node)
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
Definition ModRef.h:74
RNSuccIterator< NodeRef, BlockT, RegionT > succ_end(NodeRef Node)
void invalidateParentIListOrdering(ParentClass *Parent)
Notify basic blocks when an instruction is inserted.
auto pred_begin(const MachineBasicBlock *BB)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
auto predecessors(const MachineBasicBlock *BB)
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition STLExtras.h:1947
Instruction::const_succ_iterator const_succ_iterator
Definition CFG.h:127
#define N
Option to add extra bits to the ilist_iterator.
Option to add a pointer to this list's owner in every node.