@@ -21,10 +21,16 @@ ABIArgInfo DefaultABIInfo::classifyArgumentType(QualType Ty) const {
21
21
// Records with non-trivial destructors/copy-constructors should not be
22
22
// passed by value.
23
23
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),
25
28
RAA == CGCXXABI::RAA_DirectInMemory);
26
29
27
- return getNaturalAlignIndirect (Ty, getDataLayout ().getAllocaAddrSpace ());
30
+ return getNaturalAlignIndirect (Ty,
31
+ getCodeGenOpts ().UseAllocaASForSrets
32
+ ? getDataLayout ().getAllocaAddrSpace ()
33
+ : CGT.getTargetAddressSpace (Ty));
28
34
}
29
35
30
36
// Treat an enum type as its underlying type.
@@ -37,7 +43,10 @@ ABIArgInfo DefaultABIInfo::classifyArgumentType(QualType Ty) const {
37
43
Context.getTypeSize (Context.getTargetInfo ().hasInt128Type ()
38
44
? Context.Int128Ty
39
45
: Context.LongLongTy ))
40
- return getNaturalAlignIndirect (Ty, getDataLayout ().getAllocaAddrSpace ());
46
+ return getNaturalAlignIndirect (Ty,
47
+ getCodeGenOpts ().UseAllocaASForSrets
48
+ ? getDataLayout ().getAllocaAddrSpace ()
49
+ : CGT.getTargetAddressSpace (Ty));
41
50
42
51
return (isPromotableIntegerTypeForABI (Ty)
43
52
? ABIArgInfo::getExtend (Ty, CGT.ConvertType (Ty))
@@ -49,7 +58,10 @@ ABIArgInfo DefaultABIInfo::classifyReturnType(QualType RetTy) const {
49
58
return ABIArgInfo::getIgnore ();
50
59
51
60
if (isAggregateTypeForABI (RetTy))
52
- return getNaturalAlignIndirect (RetTy, getDataLayout ().getAllocaAddrSpace ());
61
+ return getNaturalAlignIndirect (RetTy,
62
+ getCodeGenOpts ().UseAllocaASForSrets
63
+ ? getDataLayout ().getAllocaAddrSpace ()
64
+ : CGT.getTargetAddressSpace (RetTy));
53
65
54
66
// Treat an enum type as its underlying type.
55
67
if (const EnumType *EnumTy = RetTy->getAs <EnumType>())
@@ -61,7 +73,9 @@ ABIArgInfo DefaultABIInfo::classifyReturnType(QualType RetTy) const {
61
73
? getContext ().Int128Ty
62
74
: getContext ().LongLongTy ))
63
75
return getNaturalAlignIndirect (RetTy,
64
- getDataLayout ().getAllocaAddrSpace ());
76
+ getCodeGenOpts ().UseAllocaASForSrets
77
+ ? getDataLayout ().getAllocaAddrSpace ()
78
+ : CGT.getTargetAddressSpace (RetTy));
65
79
66
80
return (isPromotableIntegerTypeForABI (RetTy) ? ABIArgInfo::getExtend (RetTy)
67
81
: ABIArgInfo::getDirect ());
@@ -122,14 +136,16 @@ CGCXXABI::RecordArgABI CodeGen::getRecordArgABI(QualType T, CGCXXABI &CXXABI) {
122
136
}
123
137
124
138
bool CodeGen::classifyReturnType (const CGCXXABI &CXXABI, CGFunctionInfo &FI,
125
- const ABIInfo &Info) {
139
+ const ABIInfo &Info, CodeGenTypes &CGT ) {
126
140
QualType Ty = FI.getReturnType ();
127
141
128
142
if (const auto *RT = Ty->getAs <RecordType>())
129
143
if (!isa<CXXRecordDecl>(RT->getDecl ()) &&
130
144
!RT->getDecl ()->canPassInRegisters ()) {
131
145
FI.getReturnInfo () = Info.getNaturalAlignIndirect (
132
- Ty, Info.getDataLayout ().getAllocaAddrSpace ());
146
+ Ty, Info.getCodeGenOpts ().UseAllocaASForSrets
147
+ ? Info.getDataLayout ().getAllocaAddrSpace ()
148
+ : CGT.getTargetAddressSpace (Ty));
133
149
return true ;
134
150
}
135
151
0 commit comments