From ab197ebb1abe6cad99fc10fabca00740dff91529 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Tue, 11 Nov 2008 22:06:59 +0000 Subject: Change EmitBranch to always clear the insert point to clarify irgen invariants. llvm-svn: 59085 --- clang/lib/CodeGen/CGStmt.cpp | 3 ++- clang/lib/CodeGen/CodeGenFunction.h | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'clang/lib/CodeGen') diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index f2088f416d5..97a7a057687 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -168,11 +168,12 @@ void CodeGenFunction::EmitBranch(llvm::BasicBlock *Target) { // If the last block was an empty placeholder, remove it now. // TODO: cache and reuse these. CurBB->eraseFromParent(); - Builder.ClearInsertionPoint(); } else { // Otherwise, create a fall-through branch. Builder.CreateBr(Target); } + + Builder.ClearInsertionPoint(); } void CodeGenFunction::EmitDummyBlock() { diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index d482086e1a1..b833380e49a 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -229,6 +229,10 @@ public: /// EmitBranch - Emit a branch to the specified basic block from the /// current insert block, taking care to avoid creation of branches /// from dummy blocks. + /// + /// This function clears the current insertion point. The caller + /// should follow calls to this function with calls to Emit*Block + /// prior to generation new code. void EmitBranch(llvm::BasicBlock *Block); /// EmitDummyBlock - Emit a new block which will never be branched -- cgit v1.2.3