[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
Mon Jan 9 13:41:27 PST 2017
ahatanak updated this revision to Diff 83680.
ahatanak added a comment.
Herald added a subscriber: mgorny.
I added an AST analysis pass that is run before IRGen and decides which VarDecls need their lifetimes to be extended or disabled. It only looks at VarDecls which have their addresses taken and are declared after a label is seen. It extends the lifetimes of VarDecls declared in a compound statement if there are backward gotos that don't leave the scope of the compound statement. However, if there are gotos that jump from outside into the compound statement too, it drops all lifetime markers for those VarDecls since emitting lifetime.start at the beginning of the compound statement might break use-after-scope check. For example:
// cannot move lifetime.start for "x" to the start of this block since the "goto label2" will
// jump over lifetime.start.
goto label1; // backward goto.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 16650 bytes
Desc: not available
More information about the cfe-commits