@@ -1674,14 +1674,6 @@ static Function *moveFunctionAdaptingType(Function *OldF, FunctionType *NewTy,
16741674 }
16751675 }
16761676
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- }
16851677 SmallVector<AttributeSet> ArgAttrs;
16861678 AttributeList OldAttrs = OldF->getAttributes ();
16871679
@@ -1697,12 +1689,16 @@ static Function *moveFunctionAdaptingType(Function *OldF, FunctionType *NewTy,
16971689 AttributeSet ArgAttr = OldAttrs.getParamAttrs (I);
16981690 // Intrinsics get their attributes fixed later.
16991691 if (OldArgTy != NewArgTy && !IsIntrinsic)
1700- ArgAttr = ArgAttr.removeAttributes (NewF->getContext (), PtrOnlyAttrs);
1692+ ArgAttr = ArgAttr.removeAttributes (
1693+ NewF->getContext (),
1694+ AttributeFuncs::typeIncompatible (NewArgTy, ArgAttr));
17011695 ArgAttrs.push_back (ArgAttr);
17021696 }
17031697 AttributeSet RetAttrs = OldAttrs.getRetAttrs ();
17041698 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));
17061702 NewF->setAttributes (AttributeList::get (
17071703 NewF->getContext (), OldAttrs.getFnAttrs (), RetAttrs, ArgAttrs));
17081704 return NewF;
0 commit comments