[PATCH] D97924: [LangRef] clarify the semantics of nocapture

Nuno Lopes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 8 06:16:55 PST 2021


nlopes added a comment.

In D97924#2607361 <https://reviews.llvm.org/D97924#2607361>, @jdoerfert wrote:

>   // G is only used in this function and always written first, no leakage!
>   static int *G;
>   void noescape1(int *p) {
>       int q;
>       G = cond() ? p : &q;
>       *G = 3;
>   }

I agree with all your examples except this one. The remaining examples are easy to justify because they store pointers to local memory that is not escaped, so those pointers don't escape either.
This example I think is better handled in two separate phases: one that removes global variables (your example's global variable can be removed easily). Then we have a cheap escape analysis that shouldn't worry with those "fake" escapes because they've been removed already.
We just need a definition of capture that is precise enough for the kind of escape analysis we want to implement. The case above seems a bit artificial.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97924



More information about the llvm-commits mailing list