================
@@ -1391,22 +1412,65 @@ static void AddParamAndFnBasicAttributes(const CallBase 
&CB,
 
       AttributeList AL = NewInnerCB->getAttributes();
       for (unsigned I = 0, E = InnerCB->arg_size(); I < E; ++I) {
-        // Check if the underlying value for the parameter is an argument.
-        const Value *UnderlyingV =
-            getUnderlyingObject(InnerCB->getArgOperand(I));
-        const Argument *Arg = dyn_cast<Argument>(UnderlyingV);
-        if (!Arg)
+        // It's unsound or requires special handling to propagate attributes to
+        // byval arguments. For reach even if CalledFunction doesn't e.g. write
+        // to the argument (readonly), the call to NewInnerCB may write to its
+        // by-value copy.
+        if (AL.hasParamAttr(I, Attribute::ByVal))
           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.
+        // Don't both propagating attrs to constants.
----------------
nikic wrote:

```suggestion
        // Don't bother propagating attrs to constants.
```

https://github.com/llvm/llvm-project/pull/91101
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to