@@ -1682,15 +1682,6 @@ static Instruction *splitBeforeCatchSwitch(CatchSwitchInst *CatchSwitch) {
1682
1682
return CleanupRet;
1683
1683
}
1684
1684
1685
- static void createFramePtr (coro::Shape &Shape) {
1686
- auto *CB = Shape.CoroBegin ;
1687
- IRBuilder<> Builder (CB->getNextNode ());
1688
- StructType *FrameTy = Shape.FrameTy ;
1689
- PointerType *FramePtrTy = FrameTy->getPointerTo ();
1690
- Shape.FramePtr =
1691
- cast<Instruction>(Builder.CreateBitCast (CB, FramePtrTy, " FramePtr" ));
1692
- }
1693
-
1694
1685
// Replace all alloca and SSA values that are accessed across suspend points
1695
1686
// with GetElementPointer from coroutine frame + loads and stores. Create an
1696
1687
// AllocaSpillBB that will become the new entry block for the resume parts of
@@ -1702,7 +1693,6 @@ static void createFramePtr(coro::Shape &Shape) {
1702
1693
// becomes:
1703
1694
//
1704
1695
// %hdl = coro.begin(...)
1705
- // %FramePtr = bitcast i8* hdl to %f.frame*
1706
1696
// br label %AllocaSpillBB
1707
1697
//
1708
1698
// AllocaSpillBB:
@@ -1781,8 +1771,7 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
1781
1771
Type *ByValTy = nullptr ;
1782
1772
if (auto *Arg = dyn_cast<Argument>(Def)) {
1783
1773
// For arguments, we will place the store instruction right after
1784
- // the coroutine frame pointer instruction, i.e. bitcast of
1785
- // coro.begin from i8* to %f.frame*.
1774
+ // the coroutine frame pointer instruction, i.e. coro.begin.
1786
1775
InsertPt = Shape.getInsertPtAfterFramePtr ()->getIterator ();
1787
1776
1788
1777
// If we're spilling an Argument, make sure we clear 'nocapture'
@@ -1987,16 +1976,12 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
1987
1976
// to the pointer in the frame.
1988
1977
for (const auto &Alias : A.Aliases ) {
1989
1978
auto *FramePtr = GetFramePointer (Alloca);
1990
- auto *FramePtrRaw =
1991
- Builder.CreateBitCast (FramePtr, Type::getInt8PtrTy (C));
1992
1979
auto &Value = *Alias.second ;
1993
1980
auto ITy = IntegerType::get (C, Value.getBitWidth ());
1994
- auto *AliasPtr = Builder.CreateGEP (Type::getInt8Ty (C), FramePtrRaw ,
1981
+ auto *AliasPtr = Builder.CreateGEP (Type::getInt8Ty (C), FramePtr ,
1995
1982
ConstantInt::get (ITy, Value));
1996
- auto *AliasPtrTyped =
1997
- Builder.CreateBitCast (AliasPtr, Alias.first ->getType ());
1998
1983
Alias.first ->replaceUsesWithIf (
1999
- AliasPtrTyped , [&](Use &U) { return DT.dominates (CB, U); });
1984
+ AliasPtr , [&](Use &U) { return DT.dominates (CB, U); });
2000
1985
}
2001
1986
}
2002
1987
@@ -2769,17 +2754,8 @@ static void sinkLifetimeStartMarkers(Function &F, coro::Shape &Shape,
2769
2754
// Sink lifetime.start markers to dominate block when they are
2770
2755
// only used outside the region.
2771
2756
if (Valid && Lifetimes.size () != 0 ) {
2772
- // May be AI itself, when the type of AI is i8*
2773
- auto *NewBitCast = [&](AllocaInst *AI) -> Value* {
2774
- if (isa<AllocaInst>(Lifetimes[0 ]->getOperand (1 )))
2775
- return AI;
2776
- auto *Int8PtrTy = Type::getInt8PtrTy (F.getContext ());
2777
- return CastInst::Create (Instruction::BitCast, AI, Int8PtrTy, " " ,
2778
- DomBB->getTerminator ());
2779
- }(AI);
2780
-
2781
2757
auto *NewLifetime = Lifetimes[0 ]->clone ();
2782
- NewLifetime->replaceUsesOfWith (NewLifetime->getOperand (1 ), NewBitCast );
2758
+ NewLifetime->replaceUsesOfWith (NewLifetime->getOperand (1 ), AI );
2783
2759
NewLifetime->insertBefore (DomBB->getTerminator ());
2784
2760
2785
2761
// All the outsided lifetime.start markers are no longer necessary.
@@ -3121,7 +3097,7 @@ void coro::buildCoroutineFrame(
3121
3097
Shape.ABI == coro::ABI::Async)
3122
3098
sinkSpillUsesAfterCoroBegin (F, FrameData, Shape.CoroBegin );
3123
3099
Shape.FrameTy = buildFrameType (F, Shape, FrameData);
3124
- createFramePtr ( Shape) ;
3100
+ Shape. FramePtr = Shape. CoroBegin ;
3125
3101
// For now, this works for C++ programs only.
3126
3102
buildFrameDebugInfo (F, Shape, FrameData);
3127
3103
insertSpills (FrameData, Shape);
0 commit comments