[CoroFrame][OpaquePtr] Remove getPointerElementType() call
Get it from the byval type instead.
This commit is contained in:
parent
02e7479e6b
commit
22f4f94256
|
@ -1571,7 +1571,7 @@ static Instruction *insertSpills(const FrameDataInfo &FrameData,
|
||||||
// Create a store instruction storing the value into the
|
// Create a store instruction storing the value into the
|
||||||
// coroutine frame.
|
// coroutine frame.
|
||||||
Instruction *InsertPt = nullptr;
|
Instruction *InsertPt = nullptr;
|
||||||
bool NeedToCopyArgPtrValue = false;
|
Type *ByValTy = nullptr;
|
||||||
if (auto *Arg = dyn_cast<Argument>(Def)) {
|
if (auto *Arg = dyn_cast<Argument>(Def)) {
|
||||||
// For arguments, we will place the store instruction right after
|
// For arguments, we will place the store instruction right after
|
||||||
// the coroutine frame pointer instruction, i.e. bitcast of
|
// the coroutine frame pointer instruction, i.e. bitcast of
|
||||||
|
@ -1583,8 +1583,7 @@ static Instruction *insertSpills(const FrameDataInfo &FrameData,
|
||||||
Arg->getParent()->removeParamAttr(Arg->getArgNo(), Attribute::NoCapture);
|
Arg->getParent()->removeParamAttr(Arg->getArgNo(), Attribute::NoCapture);
|
||||||
|
|
||||||
if (Arg->hasByValAttr())
|
if (Arg->hasByValAttr())
|
||||||
NeedToCopyArgPtrValue = true;
|
ByValTy = Arg->getParamByValType();
|
||||||
|
|
||||||
} else if (auto *CSI = dyn_cast<AnyCoroSuspendInst>(Def)) {
|
} else if (auto *CSI = dyn_cast<AnyCoroSuspendInst>(Def)) {
|
||||||
// Don't spill immediately after a suspend; splitting assumes
|
// Don't spill immediately after a suspend; splitting assumes
|
||||||
// that the suspend will be followed by a branch.
|
// that the suspend will be followed by a branch.
|
||||||
|
@ -1619,11 +1618,10 @@ static Instruction *insertSpills(const FrameDataInfo &FrameData,
|
||||||
Builder.SetInsertPoint(InsertPt);
|
Builder.SetInsertPoint(InsertPt);
|
||||||
auto *G = Builder.CreateConstInBoundsGEP2_32(
|
auto *G = Builder.CreateConstInBoundsGEP2_32(
|
||||||
FrameTy, FramePtr, 0, Index, Def->getName() + Twine(".spill.addr"));
|
FrameTy, FramePtr, 0, Index, Def->getName() + Twine(".spill.addr"));
|
||||||
if (NeedToCopyArgPtrValue) {
|
if (ByValTy) {
|
||||||
// For byval arguments, we need to store the pointed value in the frame,
|
// For byval arguments, we need to store the pointed value in the frame,
|
||||||
// instead of the pointer itself.
|
// instead of the pointer itself.
|
||||||
auto *Value =
|
auto *Value = Builder.CreateLoad(ByValTy, Def);
|
||||||
Builder.CreateLoad(Def->getType()->getPointerElementType(), Def);
|
|
||||||
Builder.CreateAlignedStore(Value, G, SpillAlignment);
|
Builder.CreateAlignedStore(Value, G, SpillAlignment);
|
||||||
} else {
|
} else {
|
||||||
Builder.CreateAlignedStore(Def, G, SpillAlignment);
|
Builder.CreateAlignedStore(Def, G, SpillAlignment);
|
||||||
|
@ -1641,7 +1639,7 @@ static Instruction *insertSpills(const FrameDataInfo &FrameData,
|
||||||
|
|
||||||
auto *GEP = GetFramePointer(E.first);
|
auto *GEP = GetFramePointer(E.first);
|
||||||
GEP->setName(E.first->getName() + Twine(".reload.addr"));
|
GEP->setName(E.first->getName() + Twine(".reload.addr"));
|
||||||
if (NeedToCopyArgPtrValue)
|
if (ByValTy)
|
||||||
CurrentReload = GEP;
|
CurrentReload = GEP;
|
||||||
else
|
else
|
||||||
CurrentReload = Builder.CreateAlignedLoad(
|
CurrentReload = Builder.CreateAlignedLoad(
|
||||||
|
|
Loading…
Reference in a new issue