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

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 24 19:46:58 PST 2016


rjmccall added a comment.

In https://reviews.llvm.org/D27680#630192, @ahatanak wrote:

> Ah, good idea. That sounds like a much simpler and less invasive approach. I agree that the performance impact would probably be small, and if it turns out to have a significant impact, we can reduce the number of times we move the lifetime.start (without moving it retroactively) by checking whether a label was seen.


Oh, good idea, that's a great way to heuristically get the performance back if we decide it's important.



================
Comment at: lib/CodeGen/CGDecl.cpp:917
+      if (!InsertPt)
+        Builder.SetInsertPoint(BB, BB->begin());
+      // If InsertPt is a terminator, insert it before InsertPt.
----------------
BB->begin() is not necessarily a legal place to insert a call.  This could happen if e.g. a scope was unconditionally entered after a statement including a ternary expression.

Also, I think lexical scopes don't necessarily have an active basic block upon entry, because their entry can be unreachable.  This happens most importantly with e.g. switch statements, but can also happen with goto or simply with unreachable code (which it's still important to not crash on).


https://reviews.llvm.org/D27680





More information about the cfe-commits mailing list