[PATCH] D155956: [FunctionAttrs] Consider recursive argmem effects (PR63936)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 9 13:00:02 PDT 2023


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/IPO/FunctionAttrs.cpp:279
+  if (ArgMR != ModRefInfo::NoModRef)
+    ME |= RecursiveArgME & MemoryEffects(ArgMR);
+
----------------
goldstein.w.n wrote:
> I don't really understand the rationale behind creating a seperate recursive variable.
> 
> It seems the original intent is to track calls with bundled arguments for which apprently IRMemLocation is incomplete.
> But if you only add back recursive args if memloc indicates mod/ref, doesn't that defeat the purpose?
> If so, why not just update ME directly for bundled calls?
Lets take a case like this:
```
define void @test_recursive_argmem_read(ptr %p) {
  %pval = load ptr, ptr %p
  call void @test_recursive_argmem_read(ptr %pval)
  ret void
}
```
At the point where we inspect the recursive `@test_recursive_argmem_read` call, we don't know whether that call will read or write `%pval`. (Well, in this specific example we do if we scan instructions from top to bottom, but generally we don't, because it depends on visitation order.)

We could just conservatively assume that all pointers passed to a recursive access will be read+write accessed and add the corresponding effects right away. That would be correct, but it would also be overly conservative. In this case, it is sufficient to only add read effects for the affected locations, we don't need to add any write effects.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155956/new/

https://reviews.llvm.org/D155956



More information about the llvm-commits mailing list