diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-09-27 07:15:59 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-09-27 07:15:59 +0000 |
commit | 274ff37583b21f634c9a6d7906eac1b11e70d19c (patch) | |
tree | 0b72a32e903ba65bf4360448536385908fb5551e /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | b22ff5975099c07773302e2e05f1c03754481868 (diff) | |
download | bcm5719-llvm-274ff37583b21f634c9a6d7906eac1b11e70d19c.tar.gz bcm5719-llvm-274ff37583b21f634c9a6d7906eac1b11e70d19c.zip |
Simplify code to emit the unified return block and move it to the end
of the function.
llvm-svn: 56752
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index e3674281e03..b182ecf055f 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -79,20 +79,12 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) { 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 @@ void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy, 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"); |