[llvm] [ArgPromotion] Infer parameter attributes on functions (PR #110245)
Matthew Devereau via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 27 06:00:53 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);
----------------
MDevereau wrote:
Not that it looks particularly better, but I think you can one-line this with
```c++
Arg->getParent()->addParamAttrs(Arg->getArgNo(),
AttrBuilder(Arg->getContext())
.addAttribute(Attribute::NoCapture)
.addAttribute(Attribute::ReadOnly));
```
https://github.com/llvm/llvm-project/pull/110245
More information about the llvm-commits
mailing list