@@ -49,6 +49,8 @@ addFlagsUsingAttrFn(ISD::ArgFlagsTy &Flags,
49
49
Flags.setNest ();
50
50
if (AttrFn (Attribute::ByVal))
51
51
Flags.setByVal ();
52
+ if (AttrFn (Attribute::ByRef))
53
+ Flags.setByRef ();
52
54
if (AttrFn (Attribute::Preallocated))
53
55
Flags.setPreallocated ();
54
56
if (AttrFn (Attribute::InAlloca))
@@ -221,17 +223,26 @@ void CallLowering::setArgFlags(CallLowering::ArgInfo &Arg, unsigned OpIdx,
221
223
}
222
224
223
225
Align MemAlign = DL.getABITypeAlign (Arg.Ty );
224
- if (Flags.isByVal () || Flags.isInAlloca () || Flags.isPreallocated ()) {
226
+ if (Flags.isByVal () || Flags.isInAlloca () || Flags.isPreallocated () ||
227
+ Flags.isByRef ()) {
225
228
assert (OpIdx >= AttributeList::FirstArgIndex);
226
229
unsigned ParamIdx = OpIdx - AttributeList::FirstArgIndex;
227
230
228
231
Type *ElementTy = FuncInfo.getParamByValType (ParamIdx);
232
+ if (!ElementTy)
233
+ ElementTy = FuncInfo.getParamByRefType (ParamIdx);
229
234
if (!ElementTy)
230
235
ElementTy = FuncInfo.getParamInAllocaType (ParamIdx);
231
236
if (!ElementTy)
232
237
ElementTy = FuncInfo.getParamPreallocatedType (ParamIdx);
238
+
233
239
assert (ElementTy && " Must have byval, inalloca or preallocated type" );
234
- Flags.setByValSize (DL.getTypeAllocSize (ElementTy));
240
+
241
+ uint64_t MemSize = DL.getTypeAllocSize (ElementTy);
242
+ if (Flags.isByRef ())
243
+ Flags.setByRefSize (MemSize);
244
+ else
245
+ Flags.setByValSize (MemSize);
235
246
236
247
// For ByVal, alignment should be passed from FE. BE will guess if
237
248
// this info is not there but there are cases it cannot get right.
0 commit comments