diff options
author | Sanjiv Gupta <sanjiv.gupta@microchip.com> | 2008-05-25 05:15:42 +0000 |
---|---|---|
committer | Sanjiv Gupta <sanjiv.gupta@microchip.com> | 2008-05-25 05:15:42 +0000 |
commit | 1c6a38bcea17801e9a4738753aee845381af2b6c (patch) | |
tree | ececb2af4e35a2ba10f5311d54c941b9f270c1fb /lib/CodeGen/CodeGenFunction.cpp | |
parent | 143520261eb41411beb3e2a8cf6d8dc822db7d50 (diff) |
Generate subprogram debug info with -g.
Also take care of freeing memory at the right places.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51553 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index b17572ce47..0a016c6416 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -205,7 +205,7 @@ void CodeGenFunction::GenerateCode(const FunctionDecl *FD) { if (body->getLBracLoc().isValid()) { DI->setLocation(body->getLBracLoc()); } - DI->EmitFunctionStart(CurFn, Builder); + DI->EmitFunctionStart(FD, CurFn, Builder); } // Emit allocs for param decls. Give the LLVM Argument nodes names. @@ -225,21 +225,20 @@ void CodeGenFunction::GenerateCode(const FunctionDecl *FD) { // Emit the function body. EmitStmt(FD->getBody()); + if (DI) { + CompoundStmt* body = cast<CompoundStmt>(CurFuncDecl->getBody()); + if (body->getRBracLoc().isValid()) { + DI->setLocation(body->getRBracLoc()); + } + 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 { - CGDebugInfo *DI = CGM.getDebugInfo(); - if (DI) { - CompoundStmt* body = cast<CompoundStmt>(CurFuncDecl->getBody()); - if (body->getRBracLoc().isValid()) { - DI->setLocation(body->getRBracLoc()); - } - DI->EmitFunctionEnd(CurFn, Builder); - } - // FIXME: if this is C++ main, this should return 0. if (CurFn->getReturnType() == llvm::Type::VoidTy) Builder.CreateRetVoid(); |