[cfe-commits] r101997 - /cfe/trunk/lib/CodeGen/CGStmt.cpp

John McCall rjmccall at apple.com
Wed Apr 21 03:29:06 PDT 2010


Author: rjmccall
Date: Wed Apr 21 05:29:06 2010
New Revision: 101997

URL: http://llvm.org/viewvc/llvm-project?rev=101997&view=rev
Log:
Teach EmitBlock to put the target block immediately after the current block
(if there's a current block).  The chief advantage of doing this is that it
lets us pick blocks (e.g. EH blocks) to push to the end of the function so
that fallthrough happens consistently --- i.e. it gives us the flexibility
of ordering blocks as we please without having to change the order in which
we generate code.  There are standard (?) optimization passes which can do some
of that for us, but better to generate reasonable code to begin with.


Modified:
    cfe/trunk/lib/CodeGen/CGStmt.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=101997&r1=101996&r2=101997&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Wed Apr 21 05:29:06 2010
@@ -225,7 +225,12 @@
     }
   }
 
-  CurFn->getBasicBlockList().push_back(BB);
+  // Place the block after the current block, if possible, or else at
+  // the end of the function.
+  if (Builder.GetInsertBlock())
+    CurFn->getBasicBlockList().insertAfter(Builder.GetInsertBlock(), BB);
+  else
+    CurFn->getBasicBlockList().push_back(BB);
   Builder.SetInsertPoint(BB);
 }
 





More information about the cfe-commits mailing list