aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-10-06 18:36:08 +0000
committerDevang Patel <dpatel@apple.com>2009-10-06 18:36:08 +0000
commitbbd9fa4b4a0fea47f94ac3eb4eaf5cc8079defe1 (patch)
treee5e7cb17543843e953ab3c90a5e9bd13cbf0375f /lib/CodeGen
parent65705d1d76bd4edca324a52eaf27ecb6e6a8151c (diff)
Add support to attach debug info to an instruction.
This is not yet enabled. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83399 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp17
-rw-r--r--lib/CodeGen/CGDebugInfo.h1
-rw-r--r--lib/CodeGen/CGExpr.cpp6
-rw-r--r--lib/CodeGen/CGStmt.cpp34
4 files changed, 46 insertions, 12 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index be742d9b80..de9390eb9f 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -879,7 +879,7 @@ void CGDebugInfo::EmitFunctionStart(const char *Name, QualType ReturnType,
getOrCreateType(ReturnType, Unit),
Fn->hasInternalLinkage(), true/*definition*/);
- DebugFactory.InsertSubprogramStart(SP, Builder.GetInsertBlock());
+// DebugFactory.InsertSubprogramStart(SP, Builder.GetInsertBlock());
// Push function on region stack.
RegionStack.push_back(SP);
@@ -903,8 +903,19 @@ void CGDebugInfo::EmitStopPoint(llvm::Function *Fn, CGBuilderTy &Builder) {
// Get the appropriate compile unit.
llvm::DICompileUnit Unit = getOrCreateCompileUnit(CurLoc);
PresumedLoc PLoc = SM.getPresumedLoc(CurLoc);
+
+#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
+ llvm::DIDescriptor DR = RegionStack.back();
+ llvm::DIScope DS = llvm::DIScope(DR.getNode());
+ llvm::DILocation DO(NULL);
+ llvm::DILocation DL =
+ DebugFactory.CreateLocation(PLoc.getLine(), PLoc.getColumn(),
+ DS, DO);
+ Builder.SetCurrentDebugLocation(DL.getNode());
+#else
DebugFactory.InsertStopPoint(Unit, PLoc.getLine(), PLoc.getColumn(),
Builder.GetInsertBlock());
+#endif
}
/// EmitRegionStart- Constructs the debug code for entering a declarative
@@ -915,7 +926,9 @@ void CGDebugInfo::EmitRegionStart(llvm::Function *Fn, CGBuilderTy &Builder) {
D = RegionStack.back();
D = DebugFactory.CreateLexicalBlock(D);
RegionStack.push_back(D);
+#ifndef ATTACH_DEBUG_INFO_TO_AN_INSN
DebugFactory.InsertRegionStart(D, Builder.GetInsertBlock());
+#endif
}
/// EmitRegionEnd - Constructs the debug code for exiting a declarative
@@ -926,7 +939,9 @@ void CGDebugInfo::EmitRegionEnd(llvm::Function *Fn, CGBuilderTy &Builder) {
// Provide an region stop point.
EmitStopPoint(Fn, Builder);
+#ifndef ATTACH_DEBUG_INFO_TO_AN_INSN
DebugFactory.InsertRegionEnd(RegionStack.back(), Builder.GetInsertBlock());
+#endif
RegionStack.pop_back();
}
diff --git a/lib/CodeGen/CGDebugInfo.h b/lib/CodeGen/CGDebugInfo.h
index ff8ec0574c..0a617b9992 100644
--- a/lib/CodeGen/CGDebugInfo.h
+++ b/lib/CodeGen/CGDebugInfo.h
@@ -148,4 +148,5 @@ private:
} // namespace CodeGen
} // namespace clang
+
#endif
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index d89da3224f..7a124b6d13 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -31,7 +31,11 @@ llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(const llvm::Type *Ty,
const char *Name) {
if (!Builder.isNamePreserving())
Name = "";
- return new llvm::AllocaInst(Ty, 0, Name, AllocaInsertPt);
+ llvm::AllocaInst *AI = new llvm::AllocaInst(Ty, 0, Name, AllocaInsertPt);
+#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
+ Builder.SetDebugLocation(AI);
+#endif
+ return AI;
}
/// EvaluateExprAsBool - Perform the usual unary conversions on the specified
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index 2a5d5edd25..62e465d702 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -148,12 +148,13 @@ RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast,
CGDebugInfo *DI = getDebugInfo();
if (DI) {
+#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
+ DI->setLocation(S.getLBracLoc());
+ DI->EmitRegionStart(CurFn, Builder);
+#else
EnsureInsertPoint();
DI->setLocation(S.getLBracLoc());
- // FIXME: The llvm backend is currently not ready to deal with region_end
- // for block scoping. In the presence of always_inline functions it gets so
- // confused that it doesn't emit any debug info. Just disable this for now.
- //DI->EmitRegionStart(CurFn, Builder);
+#endif
}
// Keep track of the current cleanup stack depth.
@@ -166,13 +167,13 @@ RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast,
EmitStmt(*I);
if (DI) {
+#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
+ DI->setLocation(S.getLBracLoc());
+ DI->EmitRegionEnd(CurFn, Builder);
+#else
EnsureInsertPoint();
- DI->setLocation(S.getRBracLoc());
-
- // FIXME: The llvm backend is currently not ready to deal with region_end
- // for block scoping. In the presence of always_inline functions it gets so
- // confused that it doesn't emit any debug info. Just disable this for now.
- //DI->EmitRegionEnd(CurFn, Builder);
+ DI->setLocation(S.getLBracLoc());
+#endif
}
RValue RV;
@@ -478,6 +479,13 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S) {
BreakContinueStack.push_back(BreakContinue(AfterFor, ContinueBlock));
// If the condition is true, execute the body of the for stmt.
+#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
+ CGDebugInfo *DI = getDebugInfo();
+ if (DI) {
+ DI->setLocation(S.getSourceRange().getBegin());
+ DI->EmitRegionStart(CurFn, Builder);
+ }
+#endif
EmitStmt(S.getBody());
BreakContinueStack.pop_back();
@@ -490,6 +498,12 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S) {
// Finally, branch back up to the condition for the next iteration.
EmitBranch(CondBlock);
+#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
+ if (DI) {
+ DI->setLocation(S.getSourceRange().getEnd());
+ DI->EmitRegionEnd(CurFn, Builder);
+ }
+#endif
// Emit the fall-through block.
EmitBlock(AfterFor, true);