Lines Matching +full:front +full:- +full:end
1 //===-- BasicBlock.cpp - Implement BasicBlock related methods -------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
34 "experimental-debuginfo-iterators",
37 "--preserve-input-debuginfo-format=true."),
40 "preserve-input-debuginfo-format", cl::Hidden,
44 "contain debug records or intrinsics. Ignored in llvm-link, "
45 "llvm-lto, and llvm-lto2."));
49 "write-experimental-debuginfo-iterators-to-bitcode", cl::Hidden,
54 "Tried to create a marker in a non new debug-info block!"); in createMarker()
55 if (I->DebugMarker) in createMarker()
56 return I->DebugMarker; in createMarker()
58 Marker->MarkedInstr = I; in createMarker()
59 I->DebugMarker = Marker; in createMarker()
65 "Tried to create a marker in a non new debug-info block!"); in createMarker()
66 if (It != end()) in createMarker()
85 assert(!I.DebugMarker && "DebugMarker already set on old-format instrs?"); in convertToNewDbgValues()
90 DVI->eraseFromParent(); in convertToNewDbgValues()
96 new DbgLabelRecord(DLI->getLabel(), DLI->getDebugLoc())); in convertToNewDbgValues()
97 DLI->eraseFromParent(); in convertToNewDbgValues()
109 Marker->insertDbgRecord(DVR, false); in convertToNewDbgValues()
134 // Assume no trailing DbgRecords: we could technically create them at the end in convertFromNewDbgValues()
135 // of the block, after a terminator, but this would be non-cannonical and in convertFromNewDbgValues()
147 Inst.DebugMarker->dump(); in dumpDbgValues()
164 return F->getValueSymbolTable(); in getValueSymbolTable()
169 return getType()->getContext(); in getContext()
173 BB->invalidateOrders(); in invalidateParentIListOrdering()
192 end().getNodePtr()->setParent(this); in BasicBlock()
195 setIsNewDbgInfoFormat(NewParent->IsNewDbgInfoFormat); in BasicBlock()
203 NewParent->insert(InsertBefore->getIterator(), this); in insertInto()
205 NewParent->insert(NewParent->end(), this); in insertInto()
207 setIsNewDbgInfoFormat(NewParent->IsNewDbgInfoFormat); in insertInto()
225 BA->replaceAllUsesWith(ConstantExpr::getIntToPtr(Replacement, in ~BasicBlock()
226 BA->getType())); in ~BasicBlock()
227 BA->destroyConstant(); in ~BasicBlock()
236 Inst.DebugMarker->eraseFromParent(); in ~BasicBlock()
270 instructionsWithoutDebug().end()); in sizeWithoutDebug()
274 getParent()->getBasicBlockList().remove(getIterator()); in removeFromParent()
278 return getParent()->getBasicBlockList().erase(getIterator()); in eraseFromParent()
282 getParent()->splice(MovePos, getParent(), getIterator()); in moveBefore()
286 MovePos->getParent()->splice(++MovePos->getIterator(), getParent(), in moveAfter()
291 return getParent()->getParent(); in getModule()
295 return getModule()->getDataLayout(); in getDataLayout()
302 if (!RI || RI == &InstList.front()) in getTerminatingMustTailCall()
305 const Instruction *Prev = RI->getPrevNode(); in getTerminatingMustTailCall()
309 if (Value *RV = RI->getReturnValue()) { in getTerminatingMustTailCall()
315 RV = BI->getOperand(0); in getTerminatingMustTailCall()
316 Prev = BI->getPrevNode(); in getTerminatingMustTailCall()
323 if (CI->isMustTailCall()) in getTerminatingMustTailCall()
333 if (!RI || RI == &InstList.front()) in getTerminatingDeoptimizeCall()
336 if (auto *CI = dyn_cast_or_null<CallInst>(RI->getPrevNode())) in getTerminatingDeoptimizeCall()
337 if (Function *F = CI->getCalledFunction()) in getTerminatingDeoptimizeCall()
338 if (F->getIntrinsicID() == Intrinsic::experimental_deoptimize) in getTerminatingDeoptimizeCall()
348 while (auto *Succ = BB->getUniqueSuccessor()) { in getPostdominatingDeoptimizeCall()
353 return BB->getTerminatingDeoptimizeCall(); in getPostdominatingDeoptimizeCall()
375 return end(); in getFirstNonPHIIt()
376 BasicBlock::const_iterator It = I->getIterator(); in getFirstNonPHIIt()
377 // Set the head-inclusive bit to indicate that this iterator includes in getFirstNonPHIIt()
378 // any debug-info at the start of the block. This is a no-op unless the in getFirstNonPHIIt()
417 return end(); in getFirstInsertionPt()
419 const_iterator InsertPt = FirstNonPHI->getIterator(); in getFirstInsertionPt()
420 if (InsertPt->isEHPad()) ++InsertPt; in getFirstInsertionPt()
421 // Set the head-inclusive bit to indicate that this iterator includes in getFirstInsertionPt()
422 // any debug-info at the start of the block. This is a no-op unless the in getFirstInsertionPt()
431 return end(); in getFirstNonPHIOrDbgOrAlloca()
433 const_iterator InsertPt = FirstNonPHI->getIterator(); in getFirstNonPHIOrDbgOrAlloca()
434 if (InsertPt->isEHPad()) in getFirstNonPHIOrDbgOrAlloca()
438 const_iterator End = end(); in getFirstNonPHIOrDbgOrAlloca() local
439 while (InsertPt != End && in getFirstNonPHIOrDbgOrAlloca()
443 if (!AI->isStaticAlloca()) in getFirstNonPHIOrDbgOrAlloca()
524 unsigned NumPreds = cast<PHINode>(front()).getNumIncomingValues(); in removePredecessor()
550 if (FirstNonPHI->isEHPad()) in canSplitPredecessors()
562 assert(Term->getNumSuccessors() > 0); in isLegalToHoistInto()
566 return !Term->isSpecialTerminator(); in isLegalToHoistInto()
572 return this == &F->getEntryBlock(); in isEntryBlock()
581 assert(I != InstList.end() && in splitBasicBlock()
585 this->getNextNode()); in splitBasicBlock()
588 DebugLoc Loc = I->getStableDebugLoc(); in splitBasicBlock()
591 New->splice(New->end(), this, I, end()); in splitBasicBlock()
595 BI->setDebugLoc(Loc); in splitBasicBlock()
602 New->replaceSuccessorsPhiUsesWith(this, New); in splitBasicBlock()
609 assert(I != InstList.end() && in splitBasicBlockBefore()
617 DebugLoc Loc = I->getDebugLoc(); in splitBasicBlockBefore()
620 New->splice(New->end(), this, begin(), I); in splitBasicBlockBefore()
633 Instruction *TI = Pred->getTerminator(); in splitBasicBlockBefore()
634 TI->replaceSuccessorWith(this, New); in splitBasicBlockBefore()
635 this->replacePhiUsesWith(Pred, New); in splitBasicBlockBefore()
639 BI->setDebugLoc(Loc); in splitBasicBlockBefore()
653 // that it ends with a non-phi instruction. in replacePhiUsesWith()
658 PN->replaceIncomingBlockWith(Old, New); in replacePhiUsesWith()
670 Succ->replacePhiUsesWith(Old, New); in replaceSuccessorsPhiUsesWith()
674 this->replaceSuccessorsPhiUsesWith(this, New); in replaceSuccessorsPhiUsesWith()
688 TI->getMetadata(LLVMContext::MD_irr_loop)) { in getIrrLoopHeaderWeight()
689 MDString *MDName = cast<MDString>(MDIrrLoopHeader->getOperand(0)); in getIrrLoopHeaderWeight()
690 if (MDName->getString() == "loop_header_weight") { in getIrrLoopHeaderWeight()
691 auto *CI = mdconst::extract<ConstantInt>(MDIrrLoopHeader->getOperand(1)); in getIrrLoopHeaderWeight()
692 return std::optional<uint64_t>(CI->getValue().getZExtValue()); in getIrrLoopHeaderWeight()
719 // off the end", existing after any terminator that gets inserted. With in flushTerminatorDbgRecords()
720 // dbg.value intrinsics we would just insert the terminator at end() and in flushTerminatorDbgRecords()
724 // check whether there's anything trailing at the end and move those in flushTerminatorDbgRecords()
725 // DbgRecords in front of the terminator. in flushTerminatorDbgRecords()
727 // Do nothing if we're not in new debug-info format. in flushTerminatorDbgRecords()
743 Term->DebugMarker->absorbDebugValues(*TrailingDbgRecords, false); in flushTerminatorDbgRecords()
744 TrailingDbgRecords->eraseFromParent(); in flushTerminatorDbgRecords()
759 // BB1->begin() to BB1->getTerminator(), then the dbg.value will be in spliceDebugInfoEmptyBlock()
761 // However, in the "new" DbgRecord format for debug-info, that range is empty: in spliceDebugInfoEmptyBlock()
767 // If we're not in "new" debug-info format, do nothing. in spliceDebugInfoEmptyBlock()
779 if (Src->empty()) { in spliceDebugInfoEmptyBlock()
780 DbgMarker *SrcTrailingDbgRecords = Src->getTrailingDbgRecords(); in spliceDebugInfoEmptyBlock()
784 Dest->adoptDbgRecords(Src, Src->end(), InsertAtHead); in spliceDebugInfoEmptyBlock()
786 assert(!Src->getTrailingDbgRecords()); in spliceDebugInfoEmptyBlock()
791 // with begin() / getFirstInsertionPt() then the caller intended debug-info in spliceDebugInfoEmptyBlock()
793 if (Src->empty() || First != Src->begin() || !ReadFromHead) in spliceDebugInfoEmptyBlock()
797 if (!First->hasDbgRecords()) in spliceDebugInfoEmptyBlock()
800 createMarker(Dest)->absorbDebugValues(*First->DebugMarker, InsertAtHead); in spliceDebugInfoEmptyBlock()
810 in it, a legitimate transient state. In that case, Dest will be end() and in spliceDebugInfo()
816 this-block: ~~~~~~~~ in spliceDebugInfo()
817 Src-block: ++++B---B---B---B:::C in spliceDebugInfo()
821 However: does the caller expect the "~" DbgRecords to end up before or in spliceDebugInfo()
823 which signals whether the caller called begin() or end() on this block. in spliceDebugInfo()
830 front of the First instruction, then splice like normal, which joins the in spliceDebugInfo()
839 // If we're inserting at end(), and not in front of dangling DbgRecords, then in spliceDebugInfo()
844 if (Dest == end() && !Dest.getHeadBit() && OurTrailingDbgRecords) { in spliceDebugInfo()
847 if (!First.getHeadBit() && First->hasDbgRecords()) { in spliceDebugInfo()
848 MoreDanglingDbgRecords = Src->getMarker(First); in spliceDebugInfo()
849 MoreDanglingDbgRecords->removeFromParent(); in spliceDebugInfo()
852 if (First->hasDbgRecords()) { in spliceDebugInfo()
853 // Place them at the front, it would look like this: in spliceDebugInfo()
856 // this-block: in spliceDebugInfo()
857 // Src-block: ~~~~~~~~++++B---B---B---B:::C in spliceDebugInfo()
860 First->adoptDbgRecords(this, end(), true); in spliceDebugInfo()
864 DbgMarker *CurMarker = Src->createMarker(&*First); in spliceDebugInfo()
865 CurMarker->absorbDebugValues(*OurTrailingDbgRecords, false); in spliceDebugInfo()
866 OurTrailingDbgRecords->eraseFromParent(); in spliceDebugInfo()
872 // Call the main debug-info-splicing implementation. in spliceDebugInfo()
882 DbgMarker *LastMarker = Src->createMarker(Last); in spliceDebugInfo()
883 LastMarker->absorbDebugValues(*MoreDanglingDbgRecords, true); in spliceDebugInfo()
884 MoreDanglingDbgRecords->eraseFromParent(); in spliceDebugInfo()
898 bool LastIsEnd = (Last == Src->end()); in spliceDebugInfoImpl()
903 while potential DbgRecord debug-info is marked out by "-" characters and a in spliceDebugInfoImpl()
909 this-block: A----A----A ====A----A----A----A---A---A in spliceDebugInfoImpl()
910 Src-block ++++B---B---B---B:::C in spliceDebugInfoImpl()
920 ":" DbgRecords? Would they go in front of the "=" DbgRecords, or should the in spliceDebugInfoImpl()
925 front of the attached DbgRecords (true) or not (false). The Tail bit is true in spliceDebugInfoImpl()
926 on the other end of a range: is the range intended to include DbgRecords up in spliceDebugInfoImpl()
927 to the end (false) or not (true). in spliceDebugInfoImpl()
936 this-block: A----A----A++++B---B---B---B:::====A----A----A----A---A---A in spliceDebugInfoImpl()
944 this-block: A----A----AB---B---B---B:::====A----A----A----A---A---A in spliceDebugInfoImpl()
952 this-block: A----A----A====B---B---B---B:::A----A----A----A---A---A in spliceDebugInfoImpl()
961 // Detach the marker at Dest -- this lets us move the "====" DbgRecords in spliceDebugInfoImpl()
965 if (Dest == end()) { in spliceDebugInfoImpl()
969 DestMarker->removeFromParent(); in spliceDebugInfoImpl()
974 // front of the DbgRecords at Dest. in spliceDebugInfoImpl()
975 if (ReadFromTail && Src->getMarker(Last)) { in spliceDebugInfoImpl()
976 DbgMarker *FromLast = Src->getMarker(Last); in spliceDebugInfoImpl()
978 if (Dest == end()) { in spliceDebugInfoImpl()
980 assert(FromLast == Src->getTrailingDbgRecords()); in spliceDebugInfoImpl()
981 createMarker(Dest)->absorbDebugValues(*FromLast, true); in spliceDebugInfoImpl()
982 FromLast->eraseFromParent(); in spliceDebugInfoImpl()
983 Src->deleteTrailingDbgRecords(); in spliceDebugInfoImpl()
986 Dest->adoptDbgRecords(Src, Last, true); in spliceDebugInfoImpl()
988 assert(!Src->getTrailingDbgRecords()); in spliceDebugInfoImpl()
992 OntoDest->absorbDebugValues(*FromLast, true); in spliceDebugInfoImpl()
999 if (!ReadFromHead && First->hasDbgRecords()) { in spliceDebugInfoImpl()
1000 if (Last != Src->end()) { in spliceDebugInfoImpl()
1001 Last->adoptDbgRecords(Src, First, true); in spliceDebugInfoImpl()
1003 DbgMarker *OntoLast = Src->createMarker(Last); in spliceDebugInfoImpl()
1004 DbgMarker *FromFirst = Src->createMarker(First); in spliceDebugInfoImpl()
1005 // Always insert at front of Last. in spliceDebugInfoImpl()
1006 OntoLast->absorbDebugValues(*FromFirst, true); in spliceDebugInfoImpl()
1013 // Insert them at the end of the DbgRecords at Dest. The "::::" DbgRecords in spliceDebugInfoImpl()
1014 // might be in front of them. in spliceDebugInfoImpl()
1016 NewDestMarker->absorbDebugValues(*DestMarker, false); in spliceDebugInfoImpl()
1020 // This also covers the rare circumstance where we insert at end(), and we in spliceDebugInfoImpl()
1022 // meaning any trailing debug-info at the end of the block would in spliceDebugInfoImpl()
1023 // "normally" have been pushed in front of "First". We move it there now. in spliceDebugInfoImpl()
1025 FirstMarker->absorbDebugValues(*DestMarker, true); in spliceDebugInfoImpl()
1027 DestMarker->eraseFromParent(); in spliceDebugInfoImpl()
1033 assert(Src->IsNewDbgInfoFormat == IsNewDbgInfoFormat); in splice()
1037 auto FromBBEnd = Src->end(); in splice()
1049 // Handle non-instr debug-info specific juggling. in splice()
1054 getInstList().splice(Dest, Src->getInstList(), First, Last); in splice()
1061 assert(I->getParent() == this); in insertDbgRecordAfter()
1063 iterator NextIt = std::next(I->getIterator()); in insertDbgRecordAfter()
1065 NextMarker->insertDbgRecord(DR, true); in insertDbgRecordAfter()
1070 assert(Where == end() || Where->getParent() == this); in insertDbgRecordBefore()
1073 M->insertDbgRecord(DR, InsertAtHead); in insertDbgRecordBefore()
1077 return getMarker(std::next(I->getIterator())); in getNextMarker()
1081 if (It == end()) { in getMarker()
1085 return It->DebugMarker; in getMarker()
1091 // immediately in front of Pos. Any DbgRecords on that position then "fell in reinsertInstInDbgRecords()
1092 // down" onto Pos. "I" has been re-inserted at the front of that wedge of in reinsertInstInDbgRecords()
1096 // Instructions: I1---I---I0 in reinsertInstInDbgRecords()
1101 // Instructions: I1------I0 in reinsertInstInDbgRecords()
1105 // Instruction "I" re-inserted (now): in reinsertInstInDbgRecords()
1107 // Instructions: I1---I------I0 in reinsertInstInDbgRecords()
1113 // Instructions: I1---I---I0 in reinsertInstInDbgRecords()
1122 if (NextMarker->StoredDbgRecords.empty()) in reinsertInstInDbgRecords()
1124 // There are DbgMarkers there now -- they fell down from "I". in reinsertInstInDbgRecords()
1126 ThisMarker->absorbDebugValues(*NextMarker, false); in reinsertInstInDbgRecords()
1131 DbgMarker *DM = (*Pos)->getMarker(); in reinsertInstInDbgRecords()
1132 auto Range = make_range(DM->StoredDbgRecords.begin(), (*Pos)); in reinsertInstInDbgRecords()
1133 if (Range.begin() == Range.end()) in reinsertInstInDbgRecords()
1138 assert(ThisMarker->StoredDbgRecords.empty()); in reinsertInstInDbgRecords()
1139 ThisMarker->absorbDebugValues(Range, *DM, true); in reinsertInstInDbgRecords()
1143 /// In asserts builds, this checks the numbering. In non-asserts builds, it
1144 /// is defined as a no-op inline function in BasicBlock.h.
1150 assert((!Prev || Prev->comesBefore(&I)) && in validateInstrOrdering()
1158 getContext().pImpl->setTrailingDbgRecords(this, foo); in setTrailingDbgRecords()
1162 return getContext().pImpl->getTrailingDbgRecords(this); in getTrailingDbgRecords()
1166 getContext().pImpl->deleteTrailingDbgRecords(this); in deleteTrailingDbgRecords()