Skip to content

Commit 4f614a8

Browse files
authored
[AMDGPULowerBufferFatPointers] Use typeIncompatible() (#122902)
Use typeIncompatible() to drop attributes incompatible with the new argument/return type, instead of keeping a custom list.
1 parent 2f7807e commit 4f614a8

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)