forked from OSchip/llvm-project
[OpaquePtr] Use ArgListEntry::IndirectType for lowering ABI attributes
Consolidate PreallocatedType and ByValType into IndirectType, and use that for inalloca.
This commit is contained in:
parent
89f2d98b98
commit
aad41e2299
|
@ -290,8 +290,7 @@ public:
|
||||||
bool IsSwiftError : 1;
|
bool IsSwiftError : 1;
|
||||||
bool IsCFGuardTarget : 1;
|
bool IsCFGuardTarget : 1;
|
||||||
MaybeAlign Alignment = None;
|
MaybeAlign Alignment = None;
|
||||||
Type *ByValType = nullptr;
|
Type *IndirectType = nullptr;
|
||||||
Type *PreallocatedType = nullptr;
|
|
||||||
|
|
||||||
ArgListEntry()
|
ArgListEntry()
|
||||||
: IsSExt(false), IsZExt(false), IsInReg(false), IsSRet(false),
|
: IsSExt(false), IsZExt(false), IsInReg(false), IsSRet(false),
|
||||||
|
|
|
@ -1076,15 +1076,12 @@ bool FastISel::lowerCallTo(CallLoweringInfo &CLI) {
|
||||||
}
|
}
|
||||||
MaybeAlign MemAlign = Arg.Alignment;
|
MaybeAlign MemAlign = Arg.Alignment;
|
||||||
if (Arg.IsByVal || Arg.IsInAlloca || Arg.IsPreallocated) {
|
if (Arg.IsByVal || Arg.IsInAlloca || Arg.IsPreallocated) {
|
||||||
PointerType *Ty = cast<PointerType>(Arg.Ty);
|
unsigned FrameSize = DL.getTypeAllocSize(Arg.IndirectType);
|
||||||
Type *ElementTy = Ty->getElementType();
|
|
||||||
unsigned FrameSize =
|
|
||||||
DL.getTypeAllocSize(Arg.ByValType ? Arg.ByValType : ElementTy);
|
|
||||||
|
|
||||||
// For ByVal, alignment should come from FE. BE will guess if this info
|
// For ByVal, alignment should come from FE. BE will guess if this info
|
||||||
// is not there, but there are cases it cannot get right.
|
// is not there, but there are cases it cannot get right.
|
||||||
if (!MemAlign)
|
if (!MemAlign)
|
||||||
MemAlign = Align(TLI.getByValTypeAlignment(ElementTy, DL));
|
MemAlign = Align(TLI.getByValTypeAlignment(Arg.IndirectType, DL));
|
||||||
Flags.setByValSize(FrameSize);
|
Flags.setByValSize(FrameSize);
|
||||||
} else if (!MemAlign) {
|
} else if (!MemAlign) {
|
||||||
MemAlign = DL.getABITypeAlign(Arg.Ty);
|
MemAlign = DL.getABITypeAlign(Arg.Ty);
|
||||||
|
|
|
@ -9578,18 +9578,14 @@ TargetLowering::LowerCallTo(TargetLowering::CallLoweringInfo &CLI) const {
|
||||||
}
|
}
|
||||||
Align MemAlign;
|
Align MemAlign;
|
||||||
if (Args[i].IsByVal || Args[i].IsInAlloca || Args[i].IsPreallocated) {
|
if (Args[i].IsByVal || Args[i].IsInAlloca || Args[i].IsPreallocated) {
|
||||||
PointerType *Ty = cast<PointerType>(Args[i].Ty);
|
unsigned FrameSize = DL.getTypeAllocSize(Args[i].IndirectType);
|
||||||
Type *ElementTy = Ty->getElementType();
|
|
||||||
|
|
||||||
unsigned FrameSize = DL.getTypeAllocSize(
|
|
||||||
Args[i].ByValType ? Args[i].ByValType : ElementTy);
|
|
||||||
Flags.setByValSize(FrameSize);
|
Flags.setByValSize(FrameSize);
|
||||||
|
|
||||||
// info is not there but there are cases it cannot get right.
|
// info is not there but there are cases it cannot get right.
|
||||||
if (auto MA = Args[i].Alignment)
|
if (auto MA = Args[i].Alignment)
|
||||||
MemAlign = *MA;
|
MemAlign = *MA;
|
||||||
else
|
else
|
||||||
MemAlign = Align(getByValTypeAlignment(ElementTy, DL));
|
MemAlign = Align(getByValTypeAlignment(Args[i].IndirectType, DL));
|
||||||
} else if (auto MA = Args[i].Alignment) {
|
} else if (auto MA = Args[i].Alignment) {
|
||||||
MemAlign = *MA;
|
MemAlign = *MA;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -119,15 +119,18 @@ void TargetLoweringBase::ArgListEntry::setAttributes(const CallBase *Call,
|
||||||
IsSwiftAsync = Call->paramHasAttr(ArgIdx, Attribute::SwiftAsync);
|
IsSwiftAsync = Call->paramHasAttr(ArgIdx, Attribute::SwiftAsync);
|
||||||
IsSwiftError = Call->paramHasAttr(ArgIdx, Attribute::SwiftError);
|
IsSwiftError = Call->paramHasAttr(ArgIdx, Attribute::SwiftError);
|
||||||
Alignment = Call->getParamStackAlign(ArgIdx);
|
Alignment = Call->getParamStackAlign(ArgIdx);
|
||||||
ByValType = nullptr;
|
IndirectType = nullptr;
|
||||||
|
assert(IsByVal + IsPreallocated + IsInAlloca <= 1 &&
|
||||||
|
"multiple ABI attributes?");
|
||||||
if (IsByVal) {
|
if (IsByVal) {
|
||||||
ByValType = Call->getParamByValType(ArgIdx);
|
IndirectType = Call->getParamByValType(ArgIdx);
|
||||||
if (!Alignment)
|
if (!Alignment)
|
||||||
Alignment = Call->getParamAlign(ArgIdx);
|
Alignment = Call->getParamAlign(ArgIdx);
|
||||||
}
|
}
|
||||||
PreallocatedType = nullptr;
|
|
||||||
if (IsPreallocated)
|
if (IsPreallocated)
|
||||||
PreallocatedType = Call->getParamPreallocatedType(ArgIdx);
|
IndirectType = Call->getParamPreallocatedType(ArgIdx);
|
||||||
|
if (IsInAlloca)
|
||||||
|
IndirectType = Call->getParamInAllocaType(ArgIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate a libcall taking the given operands as arguments and returning a
|
/// Generate a libcall taking the given operands as arguments and returning a
|
||||||
|
|
Loading…
Reference in New Issue