[PATCH] D82222: [DSE, MSSA] Treat passed by value args as invisible to caller.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 19 13:37:05 PDT 2020


efriedma added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1584
+        State.InvisibleToCallerBeforeRet.insert(&AI);
+        State.InvisibleToCallerAfterRet.insert(&AI);
+      }
----------------
fhahn wrote:
> efriedma wrote:
> > For inalloca and preallocated, the argument has the same address in the caller and the callee.  So if I'm understanding correctly, InvisibleToCallerBeforeRet should only apply specifically to byval.
> Right, I thought the caller cannot expect to observe any writes to any PassPointeeByVal argument, but it is not entirely clear from the langref. I've updated the code as suggested. Legacy DSE seems to treat them at least as if writes are not observable after the function returns.
For all of byval, inalloca, and preallocated, the allocation is implicitly freed when the function's stack frame is freed (when the function returns or unwinds).

The aspect where inalloca and preallocated differ is related to escaping.  Essentially, for inalloca/preallocated arguments, the address has already escaped before the function starts executing.

Not sure what "even if the function exits through an exception" means in this context.  The comment should be something more like "for byval, the caller doesn't know the address of the allocation".



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82222





More information about the llvm-commits mailing list