-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[NFC][DebugInfo] Make some block-start-position methods return iterators #124287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -383,20 +383,24 @@ BasicBlock::const_iterator BasicBlock::getFirstNonPHIIt() const { | |
| return It; | ||
| } | ||
|
|
||
| const Instruction *BasicBlock::getFirstNonPHIOrDbg(bool SkipPseudoOp) const { | ||
| BasicBlock::const_iterator | ||
| BasicBlock::getFirstNonPHIOrDbg(bool SkipPseudoOp) const { | ||
| for (const Instruction &I : *this) { | ||
| if (isa<PHINode>(I) || isa<DbgInfoIntrinsic>(I)) | ||
| continue; | ||
|
|
||
| if (SkipPseudoOp && isa<PseudoProbeInst>(I)) | ||
| continue; | ||
|
|
||
| return &I; | ||
| BasicBlock::const_iterator It = I.getIterator(); | ||
| // Signal that this comes after any debug records. | ||
| It.setHeadBit(false); | ||
| return It; | ||
| } | ||
| return nullptr; | ||
| return end(); | ||
| } | ||
|
|
||
| const Instruction * | ||
| BasicBlock::const_iterator | ||
| BasicBlock::getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp) const { | ||
| for (const Instruction &I : *this) { | ||
| if (isa<PHINode>(I) || isa<DbgInfoIntrinsic>(I)) | ||
|
|
@@ -408,9 +412,13 @@ BasicBlock::getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp) const { | |
| if (SkipPseudoOp && isa<PseudoProbeInst>(I)) | ||
| continue; | ||
|
|
||
| return &I; | ||
| BasicBlock::const_iterator It = I.getIterator(); | ||
| // Signal that this comes after any debug records. | ||
| It.setHeadBit(false); | ||
|
||
| return It; | ||
|
|
||
| } | ||
| return nullptr; | ||
| return end(); | ||
| } | ||
|
|
||
| BasicBlock::const_iterator BasicBlock::getFirstInsertionPt() const { | ||
|
|
@@ -428,11 +436,10 @@ BasicBlock::const_iterator BasicBlock::getFirstInsertionPt() const { | |
| } | ||
|
|
||
| BasicBlock::const_iterator BasicBlock::getFirstNonPHIOrDbgOrAlloca() const { | ||
| const Instruction *FirstNonPHI = getFirstNonPHI(); | ||
| if (!FirstNonPHI) | ||
| const_iterator InsertPt = getFirstNonPHIIt(); | ||
| if (InsertPt == end()) | ||
| return end(); | ||
|
|
||
| const_iterator InsertPt = FirstNonPHI->getIterator(); | ||
| if (InsertPt->isEHPad()) | ||
| ++InsertPt; | ||
|
|
||
|
|
@@ -448,6 +455,9 @@ BasicBlock::const_iterator BasicBlock::getFirstNonPHIOrDbgOrAlloca() const { | |
| ++InsertPt; | ||
| } | ||
| } | ||
|
|
||
| // Signal that this comes after any debug records. | ||
| InsertPt.setHeadBit(false); | ||
|
Comment on lines
+461
to
+462
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And again
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other two call-sites always generate iterators with a false head bit anyway, but there's a path from |
||
| return InsertPt; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1656,7 +1656,8 @@ static Value *emitSetAndGetSwiftErrorValueAround(Instruction *Call, | |
| Builder.SetInsertPoint(Call->getNextNode()); | ||
| } else { | ||
| auto Invoke = cast<InvokeInst>(Call); | ||
| Builder.SetInsertPoint(Invoke->getNormalDest()->getFirstNonPHIOrDbg()); | ||
| BasicBlock::iterator It = Invoke->getNormalDest()->getFirstNonPHIOrDbg(); | ||
| Builder.SetInsertPoint(It); | ||
|
||
| } | ||
|
|
||
| // Get the current swifterror value and store it to the alloca. | ||
|
|
@@ -1697,7 +1698,7 @@ static void eliminateSwiftErrorAlloca(Function &F, AllocaInst *Alloca, | |
| static void eliminateSwiftErrorArgument(Function &F, Argument &Arg, | ||
| coro::Shape &Shape, | ||
| SmallVectorImpl<AllocaInst*> &AllocasToPromote) { | ||
| IRBuilder<> Builder(F.getEntryBlock().getFirstNonPHIOrDbg()); | ||
| IRBuilder<> Builder(&F.getEntryBlock(), F.getEntryBlock().getFirstNonPHIOrDbg()); | ||
|
|
||
| auto ArgTy = cast<PointerType>(Arg.getType()); | ||
| auto ValueTy = PointerType::getUnqual(F.getContext()); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When does
Instruction::getIteratorreturn an iterator with head bit set? Can this be an assert (that it's not set) instead?