[cfe-commits] r56752 - /cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
Daniel Dunbar
daniel at zuster.org
Sat Sep 27 00:15:59 PDT 2008
Author: ddunbar
Date: Sat Sep 27 02:15:59 2008
New Revision: 56752
URL: http://llvm.org/viewvc/llvm-project?rev=56752&view=rev
Log:
Simplify code to emit the unified return block and move it to the end
of the function.
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=56752&r1=56751&r2=56752&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Sat Sep 27 02:15:59 2008
@@ -79,20 +79,12 @@
DI->EmitRegionEnd(CurFn, Builder);
}
- // Emit a return for code that falls off the end. If insert point
- // is a dummy block with no predecessors then remove the block itself.
- llvm::BasicBlock *BB = Builder.GetInsertBlock();
- if (isDummyBlock(BB)) {
- BB->eraseFromParent();
- } else {
- // Just transfer to return
- Builder.CreateBr(ReturnBlock);
- }
assert(BreakContinueStack.empty() &&
"mismatched push/pop in break/continue stack!");
- // Emit function epilog (to return).
- Builder.SetInsertPoint(ReturnBlock);
+ // Emit function epilog (to return). This has the nice side effect
+ // of also automatically handling code that falls off the end.
+ EmitBlock(ReturnBlock);
EmitFunctionEpilog(FnRetTy, ReturnValue);
// Remove the AllocaInsertPt instruction, which is just a convenience for us.
@@ -123,7 +115,7 @@
AllocaInsertPt = new llvm::BitCastInst(Undef, llvm::Type::Int32Ty, "allocapt",
EntryBB);
- ReturnBlock = llvm::BasicBlock::Create("return", CurFn);
+ ReturnBlock = llvm::BasicBlock::Create("return");
ReturnValue = 0;
if (!RetTy->isVoidType())
ReturnValue = CreateTempAlloca(ConvertType(RetTy), "retval");
More information about the cfe-commits
mailing list