Skip to content

Commit 39ec9de

Browse files
AlexVlxarsenm
andauthored
[clang][CodeGen] sret args should always point to the alloca AS, so use that (#114062)
`sret` arguments are always going to reside in the stack/`alloca` address space, which makes the current formulation where their AS is derived from the pointee somewhat quaint. This patch ensures that `sret` ends up pointing to the `alloca` AS in IR function signatures, and also guards agains trying to pass a casted `alloca`d pointer to a `sret` arg, which can happen for most languages, when compiled for targets that have a non-zero `alloca` AS (e.g. AMDGCN) / map `LangAS::default` to a non-zero value (SPIR-V). A target could still choose to do something different here, by e.g. overriding `classifyReturnType` behaviour. In a broader sense, this patch extends non-aliased indirect args to also carry an AS, which leads to changing the `getIndirect()` interface. At the moment we're only using this for (indirect) returns, but it allows for future handling of indirect args themselves. We default to using the AllocaAS as that matches what Clang is currently doing, however if, in the future, a target would opt for e.g. placing indirect returns in some other storage, with another AS, this will require revisiting. --------- Co-authored-by: Matt Arsenault <[email protected]> Co-authored-by: Matt Arsenault <[email protected]>
1 parent 2bcf62b commit 39ec9de

35 files changed

+371
-164
lines changed

Diff for: clang/include/clang/CodeGen/CGFunctionInfo.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,16 @@ class ABIArgInfo {
206206
static ABIArgInfo getIgnore() {
207207
return ABIArgInfo(Ignore);
208208
}
209-
static ABIArgInfo getIndirect(CharUnits Alignment, bool ByVal = true,
210-
bool Realign = false,
209+
static ABIArgInfo getIndirect(CharUnits Alignment, unsigned AddrSpace,
210+
bool ByVal = true, bool Realign = false,
211211
llvm::Type *Padding = nullptr) {
212212
auto AI = ABIArgInfo(Indirect);
213213
AI.setIndirectAlign(Alignment);
214214
AI.setIndirectByVal(ByVal);
215215
AI.setIndirectRealign(Realign);
216216
AI.setSRetAfterThis(false);
217217
AI.setPaddingType(Padding);
218+
AI.setIndirectAddrSpace(AddrSpace);
218219
return AI;
219220
}
220221

@@ -232,7 +233,7 @@ class ABIArgInfo {
232233

233234
static ABIArgInfo getIndirectInReg(CharUnits Alignment, bool ByVal = true,
234235
bool Realign = false) {
235-
auto AI = getIndirect(Alignment, ByVal, Realign);
236+
auto AI = getIndirect(Alignment, 0, ByVal, Realign);
236237
AI.setInReg(true);
237238
return AI;
238239
}
@@ -422,12 +423,12 @@ class ABIArgInfo {
422423
}
423424

424425
unsigned getIndirectAddrSpace() const {
425-
assert(isIndirectAliased() && "Invalid kind!");
426+
assert((isIndirect() || isIndirectAliased()) && "Invalid kind!");
426427
return IndirectAttr.AddrSpace;
427428
}
428429

429430
void setIndirectAddrSpace(unsigned AddrSpace) {
430-
assert(isIndirectAliased() && "Invalid kind!");
431+
assert((isIndirect() || isIndirectAliased()) && "Invalid kind!");
431432
IndirectAttr.AddrSpace = AddrSpace;
432433
}
433434

Diff for: clang/lib/CodeGen/ABIInfo.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ bool ABIInfo::isPromotableIntegerTypeForABI(QualType Ty) const {
171171
return false;
172172
}
173173

174-
ABIArgInfo ABIInfo::getNaturalAlignIndirect(QualType Ty, bool ByVal,
175-
bool Realign,
174+
ABIArgInfo ABIInfo::getNaturalAlignIndirect(QualType Ty, unsigned AddrSpace,
175+
bool ByVal, bool Realign,
176176
llvm::Type *Padding) const {
177-
return ABIArgInfo::getIndirect(getContext().getTypeAlignInChars(Ty), ByVal,
178-
Realign, Padding);
177+
return ABIArgInfo::getIndirect(getContext().getTypeAlignInChars(Ty),
178+
AddrSpace, ByVal, Realign, Padding);
179179
}
180180

181181
ABIArgInfo ABIInfo::getNaturalAlignIndirectInReg(QualType Ty,

Diff for: clang/lib/CodeGen/ABIInfo.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ class ABIInfo {
110110
/// A convenience method to return an indirect ABIArgInfo with an
111111
/// expected alignment equal to the ABI alignment of the given type.
112112
CodeGen::ABIArgInfo
113-
getNaturalAlignIndirect(QualType Ty, bool ByVal = true, bool Realign = false,
113+
getNaturalAlignIndirect(QualType Ty, unsigned AddrSpace, bool ByVal = true,
114+
bool Realign = false,
114115
llvm::Type *Padding = nullptr) const;
115116

116117
CodeGen::ABIArgInfo getNaturalAlignIndirectInReg(QualType Ty,

Diff for: clang/lib/CodeGen/ABIInfoImpl.cpp

+9-6
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ ABIArgInfo DefaultABIInfo::classifyArgumentType(QualType Ty) const {
2121
// Records with non-trivial destructors/copy-constructors should not be
2222
// passed by value.
2323
if (CGCXXABI::RecordArgABI RAA = getRecordArgABI(Ty, getCXXABI()))
24-
return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
24+
return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace(),
25+
RAA == CGCXXABI::RAA_DirectInMemory);
2526

26-
return getNaturalAlignIndirect(Ty);
27+
return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace());
2728
}
2829

2930
// Treat an enum type as its underlying type.
@@ -36,7 +37,7 @@ ABIArgInfo DefaultABIInfo::classifyArgumentType(QualType Ty) const {
3637
Context.getTypeSize(Context.getTargetInfo().hasInt128Type()
3738
? Context.Int128Ty
3839
: Context.LongLongTy))
39-
return getNaturalAlignIndirect(Ty);
40+
return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace());
4041

4142
return (isPromotableIntegerTypeForABI(Ty)
4243
? ABIArgInfo::getExtend(Ty, CGT.ConvertType(Ty))
@@ -48,7 +49,7 @@ ABIArgInfo DefaultABIInfo::classifyReturnType(QualType RetTy) const {
4849
return ABIArgInfo::getIgnore();
4950

5051
if (isAggregateTypeForABI(RetTy))
51-
return getNaturalAlignIndirect(RetTy);
52+
return getNaturalAlignIndirect(RetTy, getDataLayout().getAllocaAddrSpace());
5253

5354
// Treat an enum type as its underlying type.
5455
if (const EnumType *EnumTy = RetTy->getAs<EnumType>())
@@ -59,7 +60,8 @@ ABIArgInfo DefaultABIInfo::classifyReturnType(QualType RetTy) const {
5960
getContext().getTypeSize(getContext().getTargetInfo().hasInt128Type()
6061
? getContext().Int128Ty
6162
: getContext().LongLongTy))
62-
return getNaturalAlignIndirect(RetTy);
63+
return getNaturalAlignIndirect(RetTy,
64+
getDataLayout().getAllocaAddrSpace());
6365

6466
return (isPromotableIntegerTypeForABI(RetTy) ? ABIArgInfo::getExtend(RetTy)
6567
: ABIArgInfo::getDirect());
@@ -126,7 +128,8 @@ bool CodeGen::classifyReturnType(const CGCXXABI &CXXABI, CGFunctionInfo &FI,
126128
if (const auto *RT = Ty->getAs<RecordType>())
127129
if (!isa<CXXRecordDecl>(RT->getDecl()) &&
128130
!RT->getDecl()->canPassInRegisters()) {
129-
FI.getReturnInfo() = Info.getNaturalAlignIndirect(Ty);
131+
FI.getReturnInfo() = Info.getNaturalAlignIndirect(
132+
Ty, Info.getDataLayout().getAllocaAddrSpace());
130133
return true;
131134
}
132135

Diff for: clang/lib/CodeGen/CGCall.cpp

+20-12
Original file line numberDiff line numberDiff line change
@@ -1671,10 +1671,8 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI) {
16711671

16721672
// Add type for sret argument.
16731673
if (IRFunctionArgs.hasSRetArg()) {
1674-
QualType Ret = FI.getReturnType();
1675-
unsigned AddressSpace = CGM.getTypes().getTargetAddressSpace(Ret);
1676-
ArgTypes[IRFunctionArgs.getSRetArgNo()] =
1677-
llvm::PointerType::get(getLLVMContext(), AddressSpace);
1674+
ArgTypes[IRFunctionArgs.getSRetArgNo()] = llvm::PointerType::get(
1675+
getLLVMContext(), FI.getReturnInfo().getIndirectAddrSpace());
16781676
}
16791677

16801678
// Add type for inalloca argument.
@@ -5144,7 +5142,6 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
51445142
// If the call returns a temporary with struct return, create a temporary
51455143
// alloca to hold the result, unless one is given to us.
51465144
Address SRetPtr = Address::invalid();
5147-
RawAddress SRetAlloca = RawAddress::invalid();
51485145
llvm::Value *UnusedReturnSizePtr = nullptr;
51495146
if (RetAI.isIndirect() || RetAI.isInAlloca() || RetAI.isCoerceAndExpand()) {
51505147
// For virtual function pointer thunks and musttail calls, we must always
@@ -5158,11 +5155,11 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
51585155
} else if (!ReturnValue.isNull()) {
51595156
SRetPtr = ReturnValue.getAddress();
51605157
} else {
5161-
SRetPtr = CreateMemTemp(RetTy, "tmp", &SRetAlloca);
5158+
SRetPtr = CreateMemTempWithoutCast(RetTy, "tmp");
51625159
if (HaveInsertPoint() && ReturnValue.isUnused()) {
51635160
llvm::TypeSize size =
51645161
CGM.getDataLayout().getTypeAllocSize(ConvertTypeForMem(RetTy));
5165-
UnusedReturnSizePtr = EmitLifetimeStart(size, SRetAlloca.getPointer());
5162+
UnusedReturnSizePtr = EmitLifetimeStart(size, SRetPtr.getBasePointer());
51665163
}
51675164
}
51685165
if (IRFunctionArgs.hasSRetArg()) {
@@ -5397,11 +5394,22 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
53975394
V->getType()->isIntegerTy())
53985395
V = Builder.CreateZExt(V, ArgInfo.getCoerceToType());
53995396

5400-
// If the argument doesn't match, perform a bitcast to coerce it. This
5401-
// can happen due to trivial type mismatches.
5397+
// The only plausible mismatch here would be for pointer address spaces,
5398+
// which can happen e.g. when passing a sret arg that is in the AllocaAS
5399+
// to a function that takes a pointer to and argument in the DefaultAS.
5400+
// We assume that the target has a reasonable mapping for the DefaultAS
5401+
// (it can be casted to from incoming specific ASes), and insert an AS
5402+
// cast to address the mismatch.
54025403
if (FirstIRArg < IRFuncTy->getNumParams() &&
5403-
V->getType() != IRFuncTy->getParamType(FirstIRArg))
5404-
V = Builder.CreateBitCast(V, IRFuncTy->getParamType(FirstIRArg));
5404+
V->getType() != IRFuncTy->getParamType(FirstIRArg)) {
5405+
assert(V->getType()->isPointerTy() && "Only pointers can mismatch!");
5406+
auto FormalAS = CallInfo.arguments()[ArgNo]
5407+
.type.getQualifiers()
5408+
.getAddressSpace();
5409+
auto ActualAS = I->Ty.getAddressSpace();
5410+
V = getTargetHooks().performAddrSpaceCast(
5411+
*this, V, ActualAS, FormalAS, IRFuncTy->getParamType(FirstIRArg));
5412+
}
54055413

54065414
if (ArgHasMaybeUndefAttr)
54075415
V = Builder.CreateFreeze(V);
@@ -5737,7 +5745,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
57375745
// pop this cleanup later on. Being eager about this is OK, since this
57385746
// temporary is 'invisible' outside of the callee.
57395747
if (UnusedReturnSizePtr)
5740-
pushFullExprCleanup<CallLifetimeEnd>(NormalEHLifetimeMarker, SRetAlloca,
5748+
pushFullExprCleanup<CallLifetimeEnd>(NormalEHLifetimeMarker, SRetPtr,
57415749
UnusedReturnSizePtr);
57425750

57435751
llvm::BasicBlock *InvokeDest = CannotThrow ? nullptr : getInvokeDest();

Diff for: clang/lib/CodeGen/CGExprAgg.cpp

+13-6
Original file line numberDiff line numberDiff line change
@@ -296,18 +296,25 @@ void AggExprEmitter::withReturnValueSlot(
296296
(RequiresDestruction && Dest.isIgnored());
297297

298298
Address RetAddr = Address::invalid();
299-
RawAddress RetAllocaAddr = RawAddress::invalid();
300299

301300
EHScopeStack::stable_iterator LifetimeEndBlock;
302301
llvm::Value *LifetimeSizePtr = nullptr;
303302
llvm::IntrinsicInst *LifetimeStartInst = nullptr;
304303
if (!UseTemp) {
305-
RetAddr = Dest.getAddress();
304+
// It is possible for the existing slot we are using directly to have been
305+
// allocated in the correct AS for an indirect return, and then cast to
306+
// the default AS (this is the behaviour of CreateMemTemp), however we know
307+
// that the return address is expected to point to the uncasted AS, hence we
308+
// strip possible pointer casts here.
309+
if (Dest.getAddress().isValid())
310+
RetAddr = Dest.getAddress().withPointer(
311+
Dest.getAddress().getBasePointer()->stripPointerCasts(),
312+
Dest.getAddress().isKnownNonNull());
306313
} else {
307-
RetAddr = CGF.CreateMemTemp(RetTy, "tmp", &RetAllocaAddr);
314+
RetAddr = CGF.CreateMemTempWithoutCast(RetTy, "tmp");
308315
llvm::TypeSize Size =
309316
CGF.CGM.getDataLayout().getTypeAllocSize(CGF.ConvertTypeForMem(RetTy));
310-
LifetimeSizePtr = CGF.EmitLifetimeStart(Size, RetAllocaAddr.getPointer());
317+
LifetimeSizePtr = CGF.EmitLifetimeStart(Size, RetAddr.getBasePointer());
311318
if (LifetimeSizePtr) {
312319
LifetimeStartInst =
313320
cast<llvm::IntrinsicInst>(std::prev(Builder.GetInsertPoint()));
@@ -316,7 +323,7 @@ void AggExprEmitter::withReturnValueSlot(
316323
"Last insertion wasn't a lifetime.start?");
317324

318325
CGF.pushFullExprCleanup<CodeGenFunction::CallLifetimeEnd>(
319-
NormalEHLifetimeMarker, RetAllocaAddr, LifetimeSizePtr);
326+
NormalEHLifetimeMarker, RetAddr, LifetimeSizePtr);
320327
LifetimeEndBlock = CGF.EHStack.stable_begin();
321328
}
322329
}
@@ -337,7 +344,7 @@ void AggExprEmitter::withReturnValueSlot(
337344
// Since we're not guaranteed to be in an ExprWithCleanups, clean up
338345
// eagerly.
339346
CGF.DeactivateCleanupBlock(LifetimeEndBlock, LifetimeStartInst);
340-
CGF.EmitLifetimeEnd(LifetimeSizePtr, RetAllocaAddr.getPointer());
347+
CGF.EmitLifetimeEnd(LifetimeSizePtr, RetAddr.getBasePointer());
341348
}
342349
}
343350

Diff for: clang/lib/CodeGen/ItaniumCXXABI.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,9 @@ bool ItaniumCXXABI::classifyReturnType(CGFunctionInfo &FI) const {
13501350
// If C++ prohibits us from making a copy, return by address.
13511351
if (!RD->canPassInRegisters()) {
13521352
auto Align = CGM.getContext().getTypeAlignInChars(FI.getReturnType());
1353-
FI.getReturnInfo() = ABIArgInfo::getIndirect(Align, /*ByVal=*/false);
1353+
FI.getReturnInfo() = ABIArgInfo::getIndirect(
1354+
Align, /*AddrSpace=*/CGM.getDataLayout().getAllocaAddrSpace(),
1355+
/*ByVal=*/false);
13541356
return true;
13551357
}
13561358
return false;

Diff for: clang/lib/CodeGen/MicrosoftCXXABI.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,9 @@ bool MicrosoftCXXABI::classifyReturnType(CGFunctionInfo &FI) const {
11721172

11731173
if (isIndirectReturn) {
11741174
CharUnits Align = CGM.getContext().getTypeAlignInChars(FI.getReturnType());
1175-
FI.getReturnInfo() = ABIArgInfo::getIndirect(Align, /*ByVal=*/false);
1175+
FI.getReturnInfo() = ABIArgInfo::getIndirect(
1176+
Align, /*AddrSpace=*/CGM.getDataLayout().getAllocaAddrSpace(),
1177+
/*ByVal=*/false);
11761178

11771179
// MSVC always passes `this` before the `sret` parameter.
11781180
FI.getReturnInfo().setSRetAfterThis(FI.isInstanceMethod());

Diff for: clang/lib/CodeGen/SwiftCallingConv.cpp

+11-5
Original file line numberDiff line numberDiff line change
@@ -796,11 +796,14 @@ bool swiftcall::mustPassRecordIndirectly(CodeGenModule &CGM,
796796

797797
static ABIArgInfo classifyExpandedType(SwiftAggLowering &lowering,
798798
bool forReturn,
799-
CharUnits alignmentForIndirect) {
799+
CharUnits alignmentForIndirect,
800+
unsigned IndirectAS) {
800801
if (lowering.empty()) {
801802
return ABIArgInfo::getIgnore();
802803
} else if (lowering.shouldPassIndirectly(forReturn)) {
803-
return ABIArgInfo::getIndirect(alignmentForIndirect, /*byval*/ false);
804+
return ABIArgInfo::getIndirect(alignmentForIndirect,
805+
/*AddrSpace=*/IndirectAS,
806+
/*byval=*/false);
804807
} else {
805808
auto types = lowering.getCoerceAndExpandTypes();
806809
return ABIArgInfo::getCoerceAndExpand(types.first, types.second);
@@ -809,18 +812,21 @@ static ABIArgInfo classifyExpandedType(SwiftAggLowering &lowering,
809812

810813
static ABIArgInfo classifyType(CodeGenModule &CGM, CanQualType type,
811814
bool forReturn) {
815+
unsigned IndirectAS = CGM.getDataLayout().getAllocaAddrSpace();
812816
if (auto recordType = dyn_cast<RecordType>(type)) {
813817
auto record = recordType->getDecl();
814818
auto &layout = CGM.getContext().getASTRecordLayout(record);
815819

816820
if (mustPassRecordIndirectly(CGM, record))
817-
return ABIArgInfo::getIndirect(layout.getAlignment(), /*byval*/ false);
821+
return ABIArgInfo::getIndirect(layout.getAlignment(),
822+
/*AddrSpace=*/IndirectAS, /*byval=*/false);
818823

819824
SwiftAggLowering lowering(CGM);
820825
lowering.addTypedData(recordType->getDecl(), CharUnits::Zero(), layout);
821826
lowering.finish();
822827

823-
return classifyExpandedType(lowering, forReturn, layout.getAlignment());
828+
return classifyExpandedType(lowering, forReturn, layout.getAlignment(),
829+
IndirectAS);
824830
}
825831

826832
// Just assume that all of our target ABIs can support returning at least
@@ -836,7 +842,7 @@ static ABIArgInfo classifyType(CodeGenModule &CGM, CanQualType type,
836842
lowering.finish();
837843

838844
CharUnits alignment = CGM.getContext().getTypeAlignInChars(type);
839-
return classifyExpandedType(lowering, forReturn, alignment);
845+
return classifyExpandedType(lowering, forReturn, alignment, IndirectAS);
840846
}
841847

842848
// Member pointer types need to be expanded, but it's a simple form of

Diff for: clang/lib/CodeGen/Targets/AArch64.cpp

+15-9
Original file line numberDiff line numberDiff line change
@@ -327,15 +327,17 @@ ABIArgInfo AArch64ABIInfo::coerceIllegalVector(QualType Ty, unsigned &NSRN,
327327
return ABIArgInfo::getDirect(ResType);
328328
}
329329

330-
return getNaturalAlignIndirect(Ty, /*ByVal=*/false);
330+
return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace(),
331+
/*ByVal=*/false);
331332
}
332333

333334
ABIArgInfo AArch64ABIInfo::coerceAndExpandPureScalableAggregate(
334335
QualType Ty, bool IsNamedArg, unsigned NVec, unsigned NPred,
335336
const SmallVectorImpl<llvm::Type *> &UnpaddedCoerceToSeq, unsigned &NSRN,
336337
unsigned &NPRN) const {
337338
if (!IsNamedArg || NSRN + NVec > 8 || NPRN + NPred > 4)
338-
return getNaturalAlignIndirect(Ty, /*ByVal=*/false);
339+
return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace(),
340+
/*ByVal=*/false);
339341
NSRN += NVec;
340342
NPRN += NPred;
341343

@@ -375,7 +377,8 @@ ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadicFn,
375377

376378
if (const auto *EIT = Ty->getAs<BitIntType>())
377379
if (EIT->getNumBits() > 128)
378-
return getNaturalAlignIndirect(Ty, false);
380+
return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace(),
381+
false);
379382

380383
if (Ty->isVectorType())
381384
NSRN = std::min(NSRN + 1, 8u);
@@ -411,8 +414,9 @@ ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadicFn,
411414
// Structures with either a non-trivial destructor or a non-trivial
412415
// copy constructor are always indirect.
413416
if (CGCXXABI::RecordArgABI RAA = getRecordArgABI(Ty, getCXXABI())) {
414-
return getNaturalAlignIndirect(Ty, /*ByVal=*/RAA ==
415-
CGCXXABI::RAA_DirectInMemory);
417+
return getNaturalAlignIndirect(
418+
Ty, /*AddrSpace=*/getDataLayout().getAllocaAddrSpace(),
419+
/*ByVal=*/RAA == CGCXXABI::RAA_DirectInMemory);
416420
}
417421

418422
// Empty records:
@@ -489,7 +493,8 @@ ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadicFn,
489493
: llvm::ArrayType::get(BaseTy, Size / Alignment));
490494
}
491495

492-
return getNaturalAlignIndirect(Ty, /*ByVal=*/false);
496+
return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace(),
497+
/*ByVal=*/false);
493498
}
494499

495500
ABIArgInfo AArch64ABIInfo::classifyReturnType(QualType RetTy,
@@ -507,7 +512,7 @@ ABIArgInfo AArch64ABIInfo::classifyReturnType(QualType RetTy,
507512

508513
// Large vector types should be returned via memory.
509514
if (RetTy->isVectorType() && getContext().getTypeSize(RetTy) > 128)
510-
return getNaturalAlignIndirect(RetTy);
515+
return getNaturalAlignIndirect(RetTy, getDataLayout().getAllocaAddrSpace());
511516

512517
if (!passAsAggregateType(RetTy)) {
513518
// Treat an enum type as its underlying type.
@@ -516,7 +521,8 @@ ABIArgInfo AArch64ABIInfo::classifyReturnType(QualType RetTy,
516521

517522
if (const auto *EIT = RetTy->getAs<BitIntType>())
518523
if (EIT->getNumBits() > 128)
519-
return getNaturalAlignIndirect(RetTy);
524+
return getNaturalAlignIndirect(RetTy,
525+
getDataLayout().getAllocaAddrSpace());
520526

521527
return (isPromotableIntegerTypeForABI(RetTy) && isDarwinPCS()
522528
? ABIArgInfo::getExtend(RetTy)
@@ -575,7 +581,7 @@ ABIArgInfo AArch64ABIInfo::classifyReturnType(QualType RetTy,
575581
return ABIArgInfo::getDirect(llvm::IntegerType::get(getVMContext(), Size));
576582
}
577583

578-
return getNaturalAlignIndirect(RetTy);
584+
return getNaturalAlignIndirect(RetTy, getDataLayout().getAllocaAddrSpace());
579585
}
580586

581587
/// isIllegalVectorType - check whether the vector type is legal for AArch64.

0 commit comments

Comments
 (0)