diff options
author | John McCall <rjmccall@apple.com> | 2010-04-21 10:29:06 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-04-21 10:29:06 +0000 |
commit | e683359fc9925b16c3fea1487411ab859484dcfb (patch) | |
tree | e84fa61d78a8d1528cd88b893925fac32994fa3c /clang/lib/CodeGen/CGStmt.cpp | |
parent | 2188696d98f1b45a2de613107c684b97df9e9487 (diff) | |
download | bcm5719-llvm-e683359fc9925b16c3fea1487411ab859484dcfb.tar.gz bcm5719-llvm-e683359fc9925b16c3fea1487411ab859484dcfb.zip |
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.
llvm-svn: 101997
Diffstat (limited to 'clang/lib/CodeGen/CGStmt.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGStmt.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index 07c96d82ca7..eb861f46906 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -225,7 +225,12 @@ void CodeGenFunction::EmitBlock(llvm::BasicBlock *BB, bool IsFinished) { } } - 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); } |