[llvm] [Inliner] Don't propagate memory attributes to byval params (PR #93381)

Krzysztof Pszeniczny via llvm-commits llvm-commits at lists.llvm.org
Sat May 25 09:40:49 PDT 2024


================
@@ -1389,6 +1389,12 @@ static void AddParamAndFnBasicAttributes(const CallBase &CB,
         if (!Arg)
           continue;
 
+        if (AL.hasParamAttr(I, Attribute::ByVal))
+          // It's unsound to propagate memory attributes to byval arguments.
+          // Even if CalledFunction doesn't e.g. write to the argument,
+          // the call to NewInnerCB may write to its by-value copy.
+          continue;
+
----------------
amharc wrote:

This would work too, but would also drop `readonly` etc. from calls which already had `readonly byval(...)` before inlining - not sure how much this matters though.

https://github.com/llvm/llvm-project/pull/93381


More information about the llvm-commits mailing list