@@ -1674,14 +1674,6 @@ static Function *moveFunctionAdaptingType(Function *OldF, FunctionType *NewTy,
1674
1674
}
1675
1675
}
1676
1676
1677
- AttributeMask PtrOnlyAttrs;
1678
- for (auto K :
1679
- {Attribute::Dereferenceable, Attribute::DereferenceableOrNull,
1680
- Attribute::NoAlias, Attribute::NoCapture, Attribute::NoFree,
1681
- Attribute::NonNull, Attribute::NullPointerIsValid, Attribute::ReadNone,
1682
- Attribute::ReadOnly, Attribute::WriteOnly}) {
1683
- PtrOnlyAttrs.addAttribute (K);
1684
- }
1685
1677
SmallVector<AttributeSet> ArgAttrs;
1686
1678
AttributeList OldAttrs = OldF->getAttributes ();
1687
1679
@@ -1697,12 +1689,16 @@ static Function *moveFunctionAdaptingType(Function *OldF, FunctionType *NewTy,
1697
1689
AttributeSet ArgAttr = OldAttrs.getParamAttrs (I);
1698
1690
// Intrinsics get their attributes fixed later.
1699
1691
if (OldArgTy != NewArgTy && !IsIntrinsic)
1700
- ArgAttr = ArgAttr.removeAttributes (NewF->getContext (), PtrOnlyAttrs);
1692
+ ArgAttr = ArgAttr.removeAttributes (
1693
+ NewF->getContext (),
1694
+ AttributeFuncs::typeIncompatible (NewArgTy, ArgAttr));
1701
1695
ArgAttrs.push_back (ArgAttr);
1702
1696
}
1703
1697
AttributeSet RetAttrs = OldAttrs.getRetAttrs ();
1704
1698
if (OldF->getReturnType () != NewF->getReturnType () && !IsIntrinsic)
1705
- RetAttrs = RetAttrs.removeAttributes (NewF->getContext (), PtrOnlyAttrs);
1699
+ RetAttrs = RetAttrs.removeAttributes (
1700
+ NewF->getContext (),
1701
+ AttributeFuncs::typeIncompatible (NewF->getReturnType (), RetAttrs));
1706
1702
NewF->setAttributes (AttributeList::get (
1707
1703
NewF->getContext (), OldAttrs.getFnAttrs (), RetAttrs, ArgAttrs));
1708
1704
return NewF;
0 commit comments