[PATCH] D27680: [CodeGen] Move lifetime.start of a variable when goto jumps back past its declaration

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 21 15:21:57 PST 2016


ahatanak added a comment.

In https://reviews.llvm.org/D27680#628272, @rjmccall wrote:

> Wouldn't it be simpler to just record an insertion point for the beginning of the current lexical scope and insert the lifetime.begin there instead of at the current IP?


I'm not sure I understood your comment, but it seems to me that simply moving the lifetime.start intrinsics to the current lexical scope wouldn't work in a case like this:

  { // This is the previous lexical scope.
  label1:
    ...
    int a; // We want to move the lifetime.start for "a" to the beginning of this scope (not the current lexical scope), since goto is not leaving its scope.
    ...
    { // This is the current lexical scope.
      int b; // We don't want to move the lifetime.start for "b", since goto is leaving its scope.
      goto label1;
    }
  }

Currently, the lifetime.start is inserted at the beginning of the basic block of the lexical scope holding the goto's destination.

Let me know if I misunderstood your comment or you've found a flaw in this approach.


https://reviews.llvm.org/D27680





More information about the cfe-commits mailing list