Skip to content

Commit 9295115

Browse files
committed
Merge branch 'urlog' of github.com:mateuszpn/llvm into urlog
2 parents e767c82 + 864f0d2 commit 9295115

File tree

230 files changed

+2402
-10134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

230 files changed

+2402
-10134
lines changed

.github/CODEOWNERS

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ sycl/source/detail/posix_ur.cpp @intel/unified-runtime-reviewers
5656
sycl/source/detail/ur.cpp @intel/unified-runtime-reviewers
5757
sycl/source/detail/windows_ur.cpp @intel/unified-runtime-reviewers
5858
sycl/test-e2e/Adapters/ @intel/unified-runtime-reviewers
59+
sycl/test-e2e/Adapters/level_zero/ @intel/unified-runtime-reviewers-level-zero
5960

6061
# Win Proxy Loader
6162
sycl/ur_win_proxy_loader @intel/llvm-reviewers-runtime
@@ -202,9 +203,11 @@ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h @intel/dpcpp-san
202203
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h @intel/dpcpp-sanitizers-review
203204
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h @intel/dpcpp-sanitizers-review
204205
llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h @intel/dpcpp-sanitizers-review
206+
llvm/include/llvm/Transforms/Instrumentation/SPIRVSanitizerCommonUtils.h @intel/dpcpp-sanitizers-review
205207
llvm/include/llvm/Transforms/Instrumentation/ThreadSanitizer.h @intel/dpcpp-sanitizers-review
206208
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @intel/dpcpp-sanitizers-review
207209
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @intel/dpcpp-sanitizers-review
210+
llvm/lib/Transforms/Instrumentation/SPIRVSanitizerCommonUtils.cpp @intel/dpcpp-sanitizers-review
208211
llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp @intel/dpcpp-sanitizers-review
209212
llvm/test/Instrumentation/AddressSanitizer/ @intel/dpcpp-sanitizers-review
210213
llvm/test/Instrumentation/MemorySanitizer/ @intel/dpcpp-sanitizers-review

.github/workflows/sycl-windows-run-tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,12 @@ jobs:
209209
rm e2econf_files.txt
210210
211211
- name: Pack E2E test binaries
212-
if: ${{ always() && inputs.tests_selector == 'e2e' && inputs.e2e_testing_mode == 'build-only' }}
212+
if: ${{ always() && !cancelled() && inputs.tests_selector == 'e2e' && inputs.e2e_testing_mode == 'build-only' }}
213213
shell: bash
214214
run: |
215215
tar -czf e2e_bin.tar.gz -C build-e2e .
216216
- name: Upload E2E test binaries
217-
if: ${{ always() && inputs.tests_selector == 'e2e' && inputs.e2e_testing_mode == 'build-only' }}
217+
if: ${{ always() && !cancelled() && inputs.tests_selector == 'e2e' && inputs.e2e_testing_mode == 'build-only' }}
218218
uses: actions/upload-artifact@v4
219219
with:
220220
name: ${{ inputs.e2e_binaries_artifact }}

clang/include/clang/Basic/CodeGenOptions.def

+5
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,11 @@ CODEGENOPT(DisableSYCLEarlyOpts, 1, 0)
480480
/// which do not contain "user" code.
481481
CODEGENOPT(OptimizeSYCLFramework, 1, 0)
482482

483+
/// Whether to use alloca address space for `sret` arguments.
484+
/// TODO: This option can be removed once a fix goes in that can
485+
/// work with the community changes for using the alloca address space.
486+
CODEGENOPT(UseAllocaASForSrets, 1, 0)
487+
483488
/// Turn on fp64 partial emulation for kernels with only fp64 conversion
484489
/// operations and no fp64 computation operations (requires Intel GPU backend
485490
/// supporting fp64 partial emulation)

clang/include/clang/Driver/Options.td

+7
Original file line numberDiff line numberDiff line change
@@ -8830,6 +8830,13 @@ def fsycl_is_native_cpu : Flag<["-"], "fsycl-is-native-cpu">,
88308830
HelpText<"Perform device compilation for Native CPU.">,
88318831
Visibility<[CC1Option]>,
88328832
MarshallingInfoFlag<LangOpts<"SYCLIsNativeCPU">>;
8833+
// TODO: This option can be removed once a fix goes in that can
8834+
// work with the community changes for using the alloca address space.
8835+
defm offload_use_alloca_addrspace_for_srets : BoolFOption<"offload-use-alloca-addrspace-for-srets",
8836+
CodeGenOpts<"UseAllocaASForSrets">,
8837+
DefaultTrue,
8838+
PosFlag<SetTrue, [], [CC1Option], "Use alloca address space for sret arguments for offloading targets">,
8839+
NegFlag<SetFalse>>;
88338840

88348841
} // let Visibility = [CC1Option]
88358842

clang/lib/Basic/Targets/NativeCPU.cpp

+7-45
Original file line numberDiff line numberDiff line change
@@ -60,50 +60,12 @@ NativeCPUTargetInfo::NativeCPUTargetInfo(const llvm::Triple &,
6060
}());
6161
if (HostTriple.getArch() != llvm::Triple::UnknownArch) {
6262
HostTarget = AllocateTarget(HostTriple, Opts);
63-
64-
// Copy properties from host target.
65-
BoolWidth = HostTarget->getBoolWidth();
66-
BoolAlign = HostTarget->getBoolAlign();
67-
IntWidth = HostTarget->getIntWidth();
68-
IntAlign = HostTarget->getIntAlign();
69-
HalfWidth = HostTarget->getHalfWidth();
70-
HalfAlign = HostTarget->getHalfAlign();
71-
FloatWidth = HostTarget->getFloatWidth();
72-
FloatAlign = HostTarget->getFloatAlign();
73-
DoubleWidth = HostTarget->getDoubleWidth();
74-
DoubleAlign = HostTarget->getDoubleAlign();
75-
LongWidth = HostTarget->getLongWidth();
76-
LongAlign = HostTarget->getLongAlign();
77-
LongLongWidth = HostTarget->getLongLongWidth();
78-
LongLongAlign = HostTarget->getLongLongAlign();
79-
PointerWidth = HostTarget->getPointerWidth(LangAS::Default);
80-
PointerAlign = HostTarget->getPointerAlign(LangAS::Default);
81-
MinGlobalAlign = HostTarget->getMinGlobalAlign(/*TypeSize=*/0,
82-
/*HasNonWeakDef=*/true);
83-
NewAlign = HostTarget->getNewAlign();
84-
DefaultAlignForAttributeAligned =
85-
HostTarget->getDefaultAlignForAttributeAligned();
86-
SizeType = HostTarget->getSizeType();
87-
PtrDiffType = HostTarget->getPtrDiffType(LangAS::Default);
88-
IntMaxType = HostTarget->getIntMaxType();
89-
WCharType = HostTarget->getWCharType();
90-
WIntType = HostTarget->getWIntType();
91-
Char16Type = HostTarget->getChar16Type();
92-
Char32Type = HostTarget->getChar32Type();
93-
Int64Type = HostTarget->getInt64Type();
94-
SigAtomicType = HostTarget->getSigAtomicType();
95-
ProcessIDType = HostTarget->getProcessIDType();
96-
97-
UseBitFieldTypeAlignment = HostTarget->useBitFieldTypeAlignment();
98-
UseZeroLengthBitfieldAlignment =
99-
HostTarget->useZeroLengthBitfieldAlignment();
100-
UseExplicitBitFieldAlignment = HostTarget->useExplicitBitFieldAlignment();
101-
ZeroLengthBitfieldBoundary = HostTarget->getZeroLengthBitfieldBoundary();
102-
103-
// This is a bit of a lie, but it controls __GCC_ATOMIC_XXX_LOCK_FREE, and
104-
// we need those macros to be identical on host and device, because (among
105-
// other things) they affect which standard library classes are defined,
106-
// and we need all classes to be defined on both the host and device.
107-
MaxAtomicInlineWidth = HostTarget->getMaxAtomicInlineWidth();
63+
copyAuxTarget(&*HostTarget);
10864
}
10965
}
66+
67+
void NativeCPUTargetInfo::setAuxTarget(const TargetInfo *Aux) {
68+
assert(Aux && "Cannot invoke setAuxTarget without a valid auxiliary target!");
69+
copyAuxTarget(Aux);
70+
getTargetOpts() = Aux->getTargetOpts();
71+
}

clang/lib/Basic/Targets/NativeCPU.h

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class LLVM_LIBRARY_VISIBILITY NativeCPUTargetInfo final : public TargetInfo {
5757
}
5858

5959
protected:
60+
void setAuxTarget(const TargetInfo *Aux) override;
61+
6062
ArrayRef<const char *> getGCCRegNames() const override { return {}; }
6163

6264
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {

clang/lib/CodeGen/ABIInfoImpl.cpp

+23-7
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,16 @@ 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, getDataLayout().getAllocaAddrSpace(),
24+
return getNaturalAlignIndirect(Ty,
25+
getCodeGenOpts().UseAllocaASForSrets
26+
? getDataLayout().getAllocaAddrSpace()
27+
: CGT.getTargetAddressSpace(Ty),
2528
RAA == CGCXXABI::RAA_DirectInMemory);
2629

27-
return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace());
30+
return getNaturalAlignIndirect(Ty,
31+
getCodeGenOpts().UseAllocaASForSrets
32+
? getDataLayout().getAllocaAddrSpace()
33+
: CGT.getTargetAddressSpace(Ty));
2834
}
2935

3036
// Treat an enum type as its underlying type.
@@ -37,7 +43,10 @@ ABIArgInfo DefaultABIInfo::classifyArgumentType(QualType Ty) const {
3743
Context.getTypeSize(Context.getTargetInfo().hasInt128Type()
3844
? Context.Int128Ty
3945
: Context.LongLongTy))
40-
return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace());
46+
return getNaturalAlignIndirect(Ty,
47+
getCodeGenOpts().UseAllocaASForSrets
48+
? getDataLayout().getAllocaAddrSpace()
49+
: CGT.getTargetAddressSpace(Ty));
4150

4251
return (isPromotableIntegerTypeForABI(Ty)
4352
? ABIArgInfo::getExtend(Ty, CGT.ConvertType(Ty))
@@ -49,7 +58,10 @@ ABIArgInfo DefaultABIInfo::classifyReturnType(QualType RetTy) const {
4958
return ABIArgInfo::getIgnore();
5059

5160
if (isAggregateTypeForABI(RetTy))
52-
return getNaturalAlignIndirect(RetTy, getDataLayout().getAllocaAddrSpace());
61+
return getNaturalAlignIndirect(RetTy,
62+
getCodeGenOpts().UseAllocaASForSrets
63+
? getDataLayout().getAllocaAddrSpace()
64+
: CGT.getTargetAddressSpace(RetTy));
5365

5466
// Treat an enum type as its underlying type.
5567
if (const EnumType *EnumTy = RetTy->getAs<EnumType>())
@@ -61,7 +73,9 @@ ABIArgInfo DefaultABIInfo::classifyReturnType(QualType RetTy) const {
6173
? getContext().Int128Ty
6274
: getContext().LongLongTy))
6375
return getNaturalAlignIndirect(RetTy,
64-
getDataLayout().getAllocaAddrSpace());
76+
getCodeGenOpts().UseAllocaASForSrets
77+
? getDataLayout().getAllocaAddrSpace()
78+
: CGT.getTargetAddressSpace(RetTy));
6579

6680
return (isPromotableIntegerTypeForABI(RetTy) ? ABIArgInfo::getExtend(RetTy)
6781
: ABIArgInfo::getDirect());
@@ -122,14 +136,16 @@ CGCXXABI::RecordArgABI CodeGen::getRecordArgABI(QualType T, CGCXXABI &CXXABI) {
122136
}
123137

124138
bool CodeGen::classifyReturnType(const CGCXXABI &CXXABI, CGFunctionInfo &FI,
125-
const ABIInfo &Info) {
139+
const ABIInfo &Info, CodeGenTypes &CGT) {
126140
QualType Ty = FI.getReturnType();
127141

128142
if (const auto *RT = Ty->getAs<RecordType>())
129143
if (!isa<CXXRecordDecl>(RT->getDecl()) &&
130144
!RT->getDecl()->canPassInRegisters()) {
131145
FI.getReturnInfo() = Info.getNaturalAlignIndirect(
132-
Ty, Info.getDataLayout().getAllocaAddrSpace());
146+
Ty, Info.getCodeGenOpts().UseAllocaASForSrets
147+
? Info.getDataLayout().getAllocaAddrSpace()
148+
: CGT.getTargetAddressSpace(Ty));
133149
return true;
134150
}
135151

clang/lib/CodeGen/ABIInfoImpl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ CGCXXABI::RecordArgABI getRecordArgABI(const RecordType *RT, CGCXXABI &CXXABI);
4646
CGCXXABI::RecordArgABI getRecordArgABI(QualType T, CGCXXABI &CXXABI);
4747

4848
bool classifyReturnType(const CGCXXABI &CXXABI, CGFunctionInfo &FI,
49-
const ABIInfo &Info);
49+
const ABIInfo &Info, CodeGenTypes &CGT);
5050

5151
/// Pass transparent unions as if they were the type of the first element. Sema
5252
/// should ensure that all elements of the union have the same "machine type".

clang/lib/CodeGen/CGCall.cpp

+26-8
Original file line numberDiff line numberDiff line change
@@ -1719,8 +1719,12 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI) {
17191719

17201720
// Add type for sret argument.
17211721
if (IRFunctionArgs.hasSRetArg()) {
1722-
ArgTypes[IRFunctionArgs.getSRetArgNo()] = llvm::PointerType::get(
1723-
getLLVMContext(), FI.getReturnInfo().getIndirectAddrSpace());
1722+
QualType Ret = FI.getReturnType();
1723+
unsigned AddressSpace = CGM.getCodeGenOpts().UseAllocaASForSrets
1724+
? FI.getReturnInfo().getIndirectAddrSpace()
1725+
: CGM.getTypes().getTargetAddressSpace(Ret);
1726+
ArgTypes[IRFunctionArgs.getSRetArgNo()] =
1727+
llvm::PointerType::get(getLLVMContext(), AddressSpace);
17241728
}
17251729

17261730
// Add type for inalloca argument.
@@ -5309,6 +5313,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
53095313
// If the call returns a temporary with struct return, create a temporary
53105314
// alloca to hold the result, unless one is given to us.
53115315
Address SRetPtr = Address::invalid();
5316+
RawAddress SRetAlloca = RawAddress::invalid();
53125317
llvm::Value *UnusedReturnSizePtr = nullptr;
53135318
if (RetAI.isIndirect() || RetAI.isInAlloca() || RetAI.isCoerceAndExpand()) {
53145319
// For virtual function pointer thunks and musttail calls, we must always
@@ -5322,19 +5327,27 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
53225327
} else if (!ReturnValue.isNull()) {
53235328
SRetPtr = ReturnValue.getAddress();
53245329
} else {
5325-
SRetPtr = CreateMemTempWithoutCast(RetTy, "tmp");
5330+
SRetPtr = CGM.getCodeGenOpts().UseAllocaASForSrets
5331+
? CreateMemTempWithoutCast(RetTy, "tmp")
5332+
: CreateMemTemp(RetTy, "tmp", &SRetAlloca);
53265333
if (HaveInsertPoint() && ReturnValue.isUnused()) {
53275334
llvm::TypeSize size =
53285335
CGM.getDataLayout().getTypeAllocSize(ConvertTypeForMem(RetTy));
5329-
UnusedReturnSizePtr = EmitLifetimeStart(size, SRetPtr.getBasePointer());
5336+
if (CGM.getCodeGenOpts().UseAllocaASForSrets)
5337+
UnusedReturnSizePtr =
5338+
EmitLifetimeStart(size, SRetPtr.getBasePointer());
5339+
else
5340+
UnusedReturnSizePtr =
5341+
EmitLifetimeStart(size, SRetAlloca.getPointer());
53305342
}
53315343
}
53325344
if (IRFunctionArgs.hasSRetArg()) {
53335345
// A mismatch between the allocated return value's AS and the target's
53345346
// chosen IndirectAS can happen e.g. when passing the this pointer through
53355347
// a chain involving stores to / loads from the DefaultAS; we address this
53365348
// here, symmetrically with the handling we have for normal pointer args.
5337-
if (SRetPtr.getAddressSpace() != RetAI.getIndirectAddrSpace()) {
5349+
if (CGM.getCodeGenOpts().UseAllocaASForSrets &&
5350+
(SRetPtr.getAddressSpace() != RetAI.getIndirectAddrSpace())) {
53385351
llvm::Value *V = SRetPtr.getBasePointer();
53395352
LangAS SAS = getLangASFromTargetAS(SRetPtr.getAddressSpace());
53405353
LangAS DAS = getLangASFromTargetAS(RetAI.getIndirectAddrSpace());
@@ -5916,9 +5929,14 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
59165929
// can't depend on being inside of an ExprWithCleanups, so we need to manually
59175930
// pop this cleanup later on. Being eager about this is OK, since this
59185931
// temporary is 'invisible' outside of the callee.
5919-
if (UnusedReturnSizePtr)
5920-
pushFullExprCleanup<CallLifetimeEnd>(NormalEHLifetimeMarker, SRetPtr,
5921-
UnusedReturnSizePtr);
5932+
if (UnusedReturnSizePtr) {
5933+
if (CGM.getCodeGenOpts().UseAllocaASForSrets)
5934+
pushFullExprCleanup<CallLifetimeEnd>(NormalEHLifetimeMarker, SRetPtr,
5935+
UnusedReturnSizePtr);
5936+
else
5937+
pushFullExprCleanup<CallLifetimeEnd>(NormalEHLifetimeMarker, SRetAlloca,
5938+
UnusedReturnSizePtr);
5939+
}
59225940

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

clang/lib/CodeGen/ItaniumCXXABI.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -1349,10 +1349,14 @@ bool ItaniumCXXABI::classifyReturnType(CGFunctionInfo &FI) const {
13491349

13501350
// If C++ prohibits us from making a copy, return by address.
13511351
if (!RD->canPassInRegisters()) {
1352-
auto Align = CGM.getContext().getTypeAlignInChars(FI.getReturnType());
1353-
FI.getReturnInfo() = ABIArgInfo::getIndirect(
1354-
Align, /*AddrSpace=*/CGM.getDataLayout().getAllocaAddrSpace(),
1355-
/*ByVal=*/false);
1352+
QualType Ret = FI.getReturnType();
1353+
auto Align = CGM.getContext().getTypeAlignInChars(Ret);
1354+
unsigned AddressSpace = CGM.getCodeGenOpts().UseAllocaASForSrets
1355+
? CGM.getDataLayout().getAllocaAddrSpace()
1356+
: CGM.getTypes().getTargetAddressSpace(Ret);
1357+
FI.getReturnInfo() =
1358+
ABIArgInfo::getIndirect(Align, /*AddrSpace=*/AddressSpace,
1359+
/*ByVal=*/false);
13561360
return true;
13571361
}
13581362
return false;

clang/lib/CodeGen/MicrosoftCXXABI.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -1172,10 +1172,14 @@ bool MicrosoftCXXABI::classifyReturnType(CGFunctionInfo &FI) const {
11721172
bool isIndirectReturn = !isTrivialForABI || FI.isInstanceMethod();
11731173

11741174
if (isIndirectReturn) {
1175-
CharUnits Align = CGM.getContext().getTypeAlignInChars(FI.getReturnType());
1176-
FI.getReturnInfo() = ABIArgInfo::getIndirect(
1177-
Align, /*AddrSpace=*/CGM.getDataLayout().getAllocaAddrSpace(),
1178-
/*ByVal=*/false);
1175+
QualType Ret = FI.getReturnType();
1176+
CharUnits Align = CGM.getContext().getTypeAlignInChars(Ret);
1177+
unsigned AddressSpace = CGM.getCodeGenOpts().UseAllocaASForSrets
1178+
? CGM.getDataLayout().getAllocaAddrSpace()
1179+
: CGM.getTypes().getTargetAddressSpace(Ret);
1180+
FI.getReturnInfo() =
1181+
ABIArgInfo::getIndirect(Align, /*AddrSpace=*/AddressSpace,
1182+
/*ByVal=*/false);
11791183

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

clang/lib/CodeGen/Targets/AArch64.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class AArch64ABIInfo : public ABIInfo {
6060
SmallVectorImpl<llvm::Type *> &Flattened) const;
6161

6262
void computeInfo(CGFunctionInfo &FI) const override {
63-
if (!::classifyReturnType(getCXXABI(), FI, *this))
63+
if (!::classifyReturnType(getCXXABI(), FI, *this, CGT))
6464
FI.getReturnInfo() =
6565
classifyReturnType(FI.getReturnType(), FI.isVariadic());
6666

clang/lib/CodeGen/Targets/ARM.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ void WindowsARMTargetCodeGenInfo::setTargetAttributes(
232232
}
233233

234234
void ARMABIInfo::computeInfo(CGFunctionInfo &FI) const {
235-
if (!::classifyReturnType(getCXXABI(), FI, *this))
235+
if (!::classifyReturnType(getCXXABI(), FI, *this, CGT))
236236
FI.getReturnInfo() = classifyReturnType(FI.getReturnType(), FI.isVariadic(),
237237
FI.getCallingConvention());
238238

clang/lib/CodeGen/Targets/SPIR.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ ABIArgInfo CommonSPIRABIInfo::classifyKernelArgumentType(QualType Ty) const {
5151
}
5252
// Pass all aggregate types allowed by Sema by value.
5353
if (isAggregateTypeForABI(Ty))
54-
return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace());
54+
return getNaturalAlignIndirect(Ty,
55+
getCodeGenOpts().UseAllocaASForSrets
56+
? getDataLayout().getAllocaAddrSpace()
57+
: CGT.getTargetAddressSpace(Ty));
5558
}
5659

5760
return DefaultABIInfo::classifyArgumentType(Ty);
@@ -129,7 +132,11 @@ ABIArgInfo CommonSPIRABIInfo::classifyRegcallArgumentType(QualType Ty) const {
129132
// Records with non-trivial destructors/copy-constructors should not be
130133
// passed by value.
131134
if (auto RAA = getRecordArgABI(Ty, getCXXABI()))
132-
return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
135+
return getNaturalAlignIndirect(Ty,
136+
getCodeGenOpts().UseAllocaASForSrets
137+
? getDataLayout().getAllocaAddrSpace()
138+
: CGT.getTargetAddressSpace(Ty),
139+
RAA == CGCXXABI::RAA_DirectInMemory);
133140

134141
// Ignore empty structs/unions.
135142
if (isEmptyRecord(getContext(), Ty, true))
@@ -321,7 +328,10 @@ ABIArgInfo SPIRVABIInfo::classifyArgumentType(QualType Ty) const {
321328
// Records with non-trivial destructors/copy-constructors should not be
322329
// passed by value.
323330
if (auto RAA = getRecordArgABI(Ty, getCXXABI()))
324-
return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace(),
331+
return getNaturalAlignIndirect(Ty,
332+
getCodeGenOpts().UseAllocaASForSrets
333+
? getDataLayout().getAllocaAddrSpace()
334+
: CGT.getTargetAddressSpace(Ty),
325335
RAA == CGCXXABI::RAA_DirectInMemory);
326336

327337
if (const RecordType *RT = Ty->getAs<RecordType>()) {

0 commit comments

Comments
 (0)