[cfe-commits] r64252 - in /cfe/trunk: lib/CodeGen/CGStmt.cpp test/CodeGen/vla.c

Anders Carlsson andersca at mac.com
Tue Feb 10 14:50:24 PST 2009


Author: andersca
Date: Tue Feb 10 16:50:24 2009
New Revision: 64252

URL: http://llvm.org/viewvc/llvm-project?rev=64252&view=rev
Log:
Handle the case where EmitBlock might be called multiple times for the same block. Fixes PR3536.

Modified:
    cfe/trunk/lib/CodeGen/CGStmt.cpp
    cfe/trunk/test/CodeGen/vla.c

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=64252&r1=64251&r2=64252&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Tue Feb 10 16:50:24 2009
@@ -182,8 +182,14 @@
 
   // If necessary, associate the block with the cleanup stack size.
   if (!CleanupEntries.empty()) {
-    BlockScopes[BB] = CleanupEntries.size() - 1;
-    CleanupEntries.back().Blocks.push_back(BB);
+    // Check if the basic block has already been inserted.
+    BlockScopeMap::iterator I = BlockScopes.find(BB);
+    if (I != BlockScopes.end()) {
+      assert(I->second == CleanupEntries.size() - 1);
+    } else {
+      BlockScopes[BB] = CleanupEntries.size() - 1;
+      CleanupEntries.back().Blocks.push_back(BB);
+    }
   }
   
   CurFn->getBasicBlockList().push_back(BB);

Modified: cfe/trunk/test/CodeGen/vla.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/vla.c?rev=64252&r1=64251&r2=64252&view=diff

==============================================================================
--- cfe/trunk/test/CodeGen/vla.c (original)
+++ cfe/trunk/test/CodeGen/vla.c Tue Feb 10 16:50:24 2009
@@ -18,3 +18,14 @@
   int vla[x];
   return vla[x-1];
 }
+
+void
+f(int count)
+{
+ int a[count];
+
+  do {  } while (0);
+
+  if (a[0] != 3) {
+  }
+}





More information about the cfe-commits mailing list