diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2008-05-22 01:40:10 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2008-05-22 01:40:10 +0000 |
commit | 3f2af1002249c8acc9ce17f1fc50324864feb8e1 (patch) | |
tree | 78a34b5f3203319ca8fd0bbf3f2af64c085ee47e /lib/CodeGen/CodeGenFunction.cpp | |
parent | 144ac61f9005a0da4327d4e62a4c453923b7bc0c (diff) |
Make debugging information usable. This is barebones, but it makes -g
actually work (instead of crashing llc), and there's enough info emitted
to get line number information in gdb. This should hopefully be helpful
for debugging non-working programs.
I got rid of the begin/endregion calls because the implementation wasn't
working; someone who knows the debugging info a bit better might try to
add it. I really have no clue how a compiler is supposed to emit them.
This commit shouldn't have any effect without -g.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51404 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index e4332f6e7f..b17572ce47 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -13,6 +13,7 @@ #include "CodeGenFunction.h" #include "CodeGenModule.h" +#include "CGDebugInfo.h" #include "clang/Basic/TargetInfo.h" #include "clang/AST/AST.h" #include "llvm/CallingConv.h" @@ -197,7 +198,16 @@ void CodeGenFunction::GenerateCode(const FunctionDecl *FD) { EntryBB); Builder.SetInsertPoint(EntryBB); - + + CGDebugInfo *DI = CGM.getDebugInfo(); + if (DI) { + CompoundStmt* body = cast<CompoundStmt>(CurFuncDecl->getBody()); + if (body->getLBracLoc().isValid()) { + DI->setLocation(body->getLBracLoc()); + } + DI->EmitFunctionStart(CurFn, Builder); + } + // Emit allocs for param decls. Give the LLVM Argument nodes names. llvm::Function::arg_iterator AI = CurFn->arg_begin(); @@ -221,6 +231,15 @@ void CodeGenFunction::GenerateCode(const FunctionDecl *FD) { 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(); |