@@ -1398,7 +1398,7 @@ static void AddParamAndFnBasicAttributes(const CallBase &CB,
1398
1398
if (!Arg)
1399
1399
continue ;
1400
1400
1401
- if (AL. hasParamAttr (I, Attribute::ByVal))
1401
+ if (NewInnerCB-> getParamAttr (I, Attribute::ByVal). isValid ( ))
1402
1402
// It's unsound to propagate memory attributes to byval arguments.
1403
1403
// Even if CalledFunction doesn't e.g. write to the argument,
1404
1404
// the call to NewInnerCB may write to its by-value copy.
@@ -1407,24 +1407,29 @@ static void AddParamAndFnBasicAttributes(const CallBase &CB,
1407
1407
unsigned ArgNo = Arg->getArgNo ();
1408
1408
// If so, propagate its access attributes.
1409
1409
AL = AL.addParamAttributes (Context, I, ValidParamAttrs[ArgNo]);
1410
+ auto NewCBHasParamAttr = [&](Attribute::AttrKind Kind) {
1411
+ return AL.hasParamAttr (I, Kind) ||
1412
+ NewInnerCB->getParamAttr (I, Kind).isValid ();
1413
+ };
1414
+
1410
1415
// We can have conflicting attributes from the inner callsite and
1411
1416
// to-be-inlined callsite. In that case, choose the most
1412
1417
// restrictive.
1413
1418
1414
1419
// readonly + writeonly means we can never deref so make readnone.
1415
- if (AL. hasParamAttr (I, Attribute::ReadOnly) &&
1416
- AL. hasParamAttr (I, Attribute::WriteOnly))
1420
+ if (NewCBHasParamAttr ( Attribute::ReadOnly) &&
1421
+ NewCBHasParamAttr ( Attribute::WriteOnly))
1417
1422
AL = AL.addParamAttribute (Context, I, Attribute::ReadNone);
1418
1423
1419
1424
// If have readnone, need to clear readonly/writeonly
1420
- if (AL. hasParamAttr (I, Attribute::ReadNone)) {
1425
+ if (NewCBHasParamAttr ( Attribute::ReadNone)) {
1421
1426
AL = AL.removeParamAttribute (Context, I, Attribute::ReadOnly);
1422
1427
AL = AL.removeParamAttribute (Context, I, Attribute::WriteOnly);
1423
1428
}
1424
1429
1425
1430
// Writable cannot exist in conjunction w/ readonly/readnone
1426
- if (AL. hasParamAttr (I, Attribute::ReadOnly) ||
1427
- AL. hasParamAttr (I, Attribute::ReadNone))
1431
+ if (NewCBHasParamAttr ( Attribute::ReadOnly) ||
1432
+ NewCBHasParamAttr ( Attribute::ReadNone))
1428
1433
AL = AL.removeParamAttribute (Context, I, Attribute::Writable);
1429
1434
}
1430
1435
NewInnerCB->setAttributes (AL);
0 commit comments