[llvm] [ArgPromotion] Infer parameter attributes on functions (PR #110245)
    Nikita Popov via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Fri Sep 27 05:52:41 PDT 2024
    
    
  
================
@@ -743,6 +743,10 @@ static bool findArgParts(Argument *Arg, const DataLayout &DL, AAResults &AAR,
   // Okay, now we know that the argument is only used by load instructions, and
   // it is safe to unconditionally perform all of them.
 
+  // We can infer `nocapture readonly` as the argument is only used by loads.
+  Arg->getParent()->addParamAttr(Arg->getArgNo(), Attribute::NoCapture);
+  Arg->getParent()->addParamAttr(Arg->getArgNo(), Attribute::ReadOnly);
----------------
nikic wrote:
We should not modify attributes in findArgParts like this, because it mixed analysis and transform. Note that we will fail to report the attribute change to the PM as implemented.
https://github.com/llvm/llvm-project/pull/110245
    
    
More information about the llvm-commits
mailing list