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
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index 2e36c5b..0148ab0 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -87,26 +87,11 @@
llvm::Value *AggLoc, bool isAggVol) {
// FIXME: handle vla's etc.
if (S.body_empty() || !isa<Expr>(S.body_back())) GetLast = false;
-
- CGDebugInfo *DI = CGM.getDebugInfo();
- if (DI) {
- if (S.getLBracLoc().isValid()) {
- DI->setLocation(S.getLBracLoc());
- }
- DI->EmitRegionStart(CurFn, Builder);
- }
for (CompoundStmt::const_body_iterator I = S.body_begin(),
E = S.body_end()-GetLast; I != E; ++I)
EmitStmt(*I);
- if (DI) {
- if (S.getRBracLoc().isValid()) {
- DI->setLocation(S.getRBracLoc());
- }
- DI->EmitRegionEnd(CurFn, Builder);
- }
-
if (!GetLast)
return RValue::get(0);
@@ -383,6 +368,15 @@
EmitAggExpr(RV, SRetPtr, false);
}
+ CGDebugInfo *DI = CGM.getDebugInfo();
+ if (DI) {
+ CompoundStmt* body = cast<CompoundStmt>(CurFuncDecl->getBody());
+ if (body->getRBracLoc().isValid()) {
+ DI->setLocation(body->getRBracLoc());
+ }
+ DI->EmitFunctionEnd(CurFn, Builder);
+ }
+
if (RetValue) {
Builder.CreateRet(RetValue);
} else {