@@ -1777,13 +1777,13 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
1777
1777
auto SpillAlignment = Align(FrameData.getAlign(Def));
1778
1778
// Create a store instruction storing the value into the
1779
1779
// coroutine frame.
1780
- Instruction * InsertPt = nullptr ;
1780
+ BasicBlock::iterator InsertPt;
1781
1781
Type *ByValTy = nullptr;
1782
1782
if (auto *Arg = dyn_cast<Argument>(Def)) {
1783
1783
// For arguments, we will place the store instruction right after
1784
1784
// the coroutine frame pointer instruction, i.e. bitcast of
1785
1785
// coro.begin from i8* to %f.frame*.
1786
- InsertPt = Shape.getInsertPtAfterFramePtr();
1786
+ InsertPt = Shape.getInsertPtAfterFramePtr()->getIterator() ;
1787
1787
1788
1788
// If we're spilling an Argument, make sure we clear 'nocapture'
1789
1789
// from the coroutine function.
@@ -1794,35 +1794,35 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
1794
1794
} else if (auto *CSI = dyn_cast<AnyCoroSuspendInst>(Def)) {
1795
1795
// Don't spill immediately after a suspend; splitting assumes
1796
1796
// that the suspend will be followed by a branch.
1797
- InsertPt = CSI->getParent()->getSingleSuccessor()->getFirstNonPHI ();
1797
+ InsertPt = CSI->getParent()->getSingleSuccessor()->getFirstNonPHIIt ();
1798
1798
} else {
1799
1799
auto *I = cast<Instruction>(Def);
1800
1800
if (!DT.dominates(CB, I)) {
1801
1801
// If it is not dominated by CoroBegin, then spill should be
1802
1802
// inserted immediately after CoroFrame is computed.
1803
- InsertPt = Shape.getInsertPtAfterFramePtr();
1803
+ InsertPt = Shape.getInsertPtAfterFramePtr()->getIterator() ;
1804
1804
} else if (auto *II = dyn_cast<InvokeInst>(I)) {
1805
1805
// If we are spilling the result of the invoke instruction, split
1806
1806
// the normal edge and insert the spill in the new block.
1807
1807
auto *NewBB = SplitEdge(II->getParent(), II->getNormalDest());
1808
- InsertPt = NewBB->getTerminator();
1808
+ InsertPt = NewBB->getTerminator()->getIterator() ;
1809
1809
} else if (isa<PHINode>(I)) {
1810
1810
// Skip the PHINodes and EH pads instructions.
1811
1811
BasicBlock *DefBlock = I->getParent();
1812
1812
if (auto *CSI = dyn_cast<CatchSwitchInst>(DefBlock->getTerminator()))
1813
- InsertPt = splitBeforeCatchSwitch(CSI);
1813
+ InsertPt = splitBeforeCatchSwitch(CSI)->getIterator() ;
1814
1814
else
1815
- InsertPt = &* DefBlock->getFirstInsertionPt();
1815
+ InsertPt = DefBlock->getFirstInsertionPt();
1816
1816
} else {
1817
1817
assert(!I->isTerminator() && "unexpected terminator");
1818
1818
// For all other values, the spill is placed immediately after
1819
1819
// the definition.
1820
- InsertPt = I->getNextNode();
1820
+ InsertPt = I->getNextNode()->getIterator() ;
1821
1821
}
1822
1822
}
1823
1823
1824
1824
auto Index = FrameData.getFieldIndex(Def);
1825
- Builder.SetInsertPoint(InsertPt);
1825
+ Builder.SetInsertPoint(InsertPt->getParent(), InsertPt );
1826
1826
auto *G = Builder.CreateConstInBoundsGEP2_32(
1827
1827
FrameTy, FramePtr, 0, Index, Def->getName() + Twine(".spill.addr"));
1828
1828
if (ByValTy) {
@@ -1842,7 +1842,8 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
1842
1842
// reference provided with the frame GEP.
1843
1843
if (CurrentBlock != U->getParent()) {
1844
1844
CurrentBlock = U->getParent();
1845
- Builder.SetInsertPoint(&*CurrentBlock->getFirstInsertionPt());
1845
+ Builder.SetInsertPoint(CurrentBlock,
1846
+ CurrentBlock->getFirstInsertionPt());
1846
1847
1847
1848
auto *GEP = GetFramePointer(E.first);
1848
1849
GEP->setName(E.first->getName() + Twine(".reload.addr"));
@@ -1916,7 +1917,7 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
1916
1917
if (Shape.ABI == coro::ABI::Retcon || Shape.ABI == coro::ABI::RetconOnce ||
1917
1918
Shape.ABI == coro::ABI::Async) {
1918
1919
// If we found any allocas, replace all of their remaining uses with Geps.
1919
- Builder.SetInsertPoint(& SpillBlock->front ());
1920
+ Builder.SetInsertPoint(SpillBlock, SpillBlock->begin ());
1920
1921
for (const auto &P : FrameData.Allocas) {
1921
1922
AllocaInst *Alloca = P.Alloca;
1922
1923
auto *G = GetFramePointer(Alloca);
@@ -1935,7 +1936,8 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
1935
1936
// dbg.declares and dbg.values with the reload from the frame.
1936
1937
// Note: We cannot replace the alloca with GEP instructions indiscriminately,
1937
1938
// as some of the uses may not be dominated by CoroBegin.
1938
- Builder.SetInsertPoint(&Shape.AllocaSpillBlock->front());
1939
+ Builder.SetInsertPoint(Shape.AllocaSpillBlock,
1940
+ Shape.AllocaSpillBlock->begin());
1939
1941
SmallVector<Instruction *, 4> UsersToUpdate;
1940
1942
for (const auto &A : FrameData.Allocas) {
1941
1943
AllocaInst *Alloca = A.Alloca;
0 commit comments