summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2008-05-22 01:40:10 +0000
committerEli Friedman <eli.friedman@gmail.com>2008-05-22 01:40:10 +0000
commit1763075b9c4709b311b99b611694c58513d9dcd8 (patch)
treedb41d98027a0f099db5a1b2df20befc02a07a204 /clang/lib/CodeGen/CodeGenFunction.cpp
parentc7460b1011eea2194f3c1109d77bbf986ca511e5 (diff)
downloadbcm5719-llvm-1763075b9c4709b311b99b611694c58513d9dcd8.tar.gz
bcm5719-llvm-1763075b9c4709b311b99b611694c58513d9dcd8.zip
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. llvm-svn: 51404
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index e4332f6e7fb..b17572ce478 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/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();
OpenPOWER on IntegriCloud