[llvm] [Inliner] Prevent adding pointer attributes to non-pointer arguments (PR #115569)
Harald van Dijk via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 9 02:55:03 PST 2024
================
@@ -1477,6 +1477,15 @@ static void AddParamAndFnBasicAttributes(const CallBase &CB,
// If so, propagate its access attributes.
AL = AL.addParamAttributes(Context, I, ValidObjParamAttrs[ArgNo]);
+
+ // If the argument is not a pointer type, remove attributes which only
+ // apply to pointer types.
+ if (!NewInnerCB->getArgOperand(I)->getType()->isPointerTy()) {
+ AL = AL.removeParamAttribute(Context, I, Attribute::ReadNone);
+ AL = AL.removeParamAttribute(Context, I, Attribute::ReadOnly);
----------------
hvdijk wrote:
This only needs to handle the attributes that this function may have put in `ValidObjParamAttrs` earlier. `WriteOnly` is not in that list, see https://github.com/llvm/llvm-project/blob/48f6814b2c85f8b519955a9ef604c0e6479b25ba/llvm/lib/Transforms/Utils/InlineFunction.cpp#L1392-L1395 where it only checks these two attributes.
https://github.com/llvm/llvm-project/pull/115569
More information about the llvm-commits
mailing list