[cfe-commits] r154684 - in /cfe/trunk: lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGDecl.cpp test/CodeGenCXX/block-byref-cxx-objc.cpp

John McCall rjmccall at apple.com
Fri Apr 13 11:44:05 PDT 2012


Author: rjmccall
Date: Fri Apr 13 13:44:05 2012
New Revision: 154684

URL: http://llvm.org/viewvc/llvm-project?rev=154684&view=rev
Log:
Don't enter cleanups for unreachable variables.  It's impossible to
jump into these scopes, and the cleanup-entering code sometimes wants
to do some operations first (e.g. a GEP), which can leave us with
unparented IR.

Modified:
    cfe/trunk/lib/CodeGen/CGBlocks.cpp
    cfe/trunk/lib/CodeGen/CGDecl.cpp
    cfe/trunk/test/CodeGenCXX/block-byref-cxx-objc.cpp

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=154684&r1=154683&r2=154684&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Fri Apr 13 13:44:05 2012
@@ -491,6 +491,8 @@
 /// a full-expression so that the block's cleanups are pushed at the
 /// right place in the stack.
 static void enterBlockScope(CodeGenFunction &CGF, BlockDecl *block) {
+  assert(CGF.HaveInsertPoint());
+
   // Allocate the block info and place it at the head of the list.
   CGBlockInfo &blockInfo =
     *new CGBlockInfo(block, CGF.CurFn->getName());

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=154684&r1=154683&r2=154684&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Apr 13 13:44:05 2012
@@ -1171,6 +1171,10 @@
   // If this was emitted as a global constant, we're done.
   if (emission.wasEmittedAsGlobal()) return;
 
+  // If we don't have an insertion point, we're done.  Sema prevents
+  // us from jumping into any of these scopes anyway.
+  if (!HaveInsertPoint()) return;
+
   const VarDecl &D = *emission.Variable;
 
   // Check the type for a cleanup.

Modified: cfe/trunk/test/CodeGenCXX/block-byref-cxx-objc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/block-byref-cxx-objc.cpp?rev=154684&r1=154683&r2=154684&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/block-byref-cxx-objc.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/block-byref-cxx-objc.cpp Fri Apr 13 13:44:05 2012
@@ -23,3 +23,13 @@
 // CHECK: call void @_Block_object_assign
 // CHECK: define internal void @__destroy_helper_block_
 // CHECK: call void @_Block_object_dispose
+
+// rdar://problem/11135650
+namespace test1 {
+  struct A { int x; A(); ~A(); };
+
+  void test() {
+    return;
+    __block A a;
+  }
+}





More information about the cfe-commits mailing list