[llvm-commits] [dragonegg] r164914 - in /dragonegg/trunk: src/Convert.cpp test/validator/c/EmptyBlock.c

Duncan Sands baldrick at free.fr
Sun Sep 30 00:56:43 PDT 2012


Author: baldrick
Date: Sun Sep 30 02:56:43 2012
New Revision: 164914

URL: http://llvm.org/viewvc/llvm-project?rev=164914&view=rev
Log:
There is no reason for a basic block that finished with an unsupported GCC
builtin (and that normally would have terminated it) to be empty.

Modified:
    dragonegg/trunk/src/Convert.cpp
    dragonegg/trunk/test/validator/c/EmptyBlock.c

Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=164914&r1=164913&r2=164914&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Sun Sep 30 02:56:43 2012
@@ -1401,15 +1401,15 @@
     }
   } else { // !ReturnBB
     BasicBlock *CurBB = Builder.GetInsertBlock();
-    // If the previous block has no terminator then it must be empty.
     if (CurBB->getTerminator() == 0) {
-      assert(CurBB->begin() == CurBB->end() && "Falls through to nowhere!");
-      // If it has a name then it may be branched to or have its address taken.
-      // If it doesn't even have a name then delete it.
-      if (!CurBB->getName().empty())
-        Builder.CreateUnreachable();
-      else
+      if (CurBB->getName().empty() && CurBB->begin() == CurBB->end())
+        // If the previous block has no label and is empty, remove it: it is a
+        // post-terminator block.
         CurBB->eraseFromParent();
+      else
+        // The previous block may contain code but no terminator if it finished
+        // with an unsupported GCC builtin.
+        Builder.CreateUnreachable();
     }
   }
 

Modified: dragonegg/trunk/test/validator/c/EmptyBlock.c
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/test/validator/c/EmptyBlock.c?rev=164914&r1=164913&r2=164914&view=diff
==============================================================================
--- dragonegg/trunk/test/validator/c/EmptyBlock.c (original)
+++ dragonegg/trunk/test/validator/c/EmptyBlock.c Sun Sep 30 02:56:43 2012
@@ -6,3 +6,11 @@
 {
   __builtin_longjmp (buf, 1);
 }
+
+double
+bar (int arg)
+{
+  foo (arg);
+  __builtin_return (__builtin_apply ((void (*) ()) foo,
+				     __builtin_apply_args (), 16));
+}





More information about the llvm-commits mailing list