From 1c6a38bcea17801e9a4738753aee845381af2b6c Mon Sep 17 00:00:00 2001 From: Sanjiv Gupta Date: Sun, 25 May 2008 05:15:42 +0000 Subject: 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 --- lib/CodeGen/CodeGenFunction.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'lib/CodeGen/CodeGenFunction.cpp') 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(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(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(); -- cgit v1.2.3-18-g5258