forked from OSchip/llvm-project
Add support to attach debug info to an instruction.
This is not yet enabled. llvm-svn: 83399
This commit is contained in:
parent
273cdf096c
commit
5d90d62701
|
@ -879,7 +879,7 @@ void CGDebugInfo::EmitFunctionStart(const char *Name, QualType ReturnType,
|
||||||
getOrCreateType(ReturnType, Unit),
|
getOrCreateType(ReturnType, Unit),
|
||||||
Fn->hasInternalLinkage(), true/*definition*/);
|
Fn->hasInternalLinkage(), true/*definition*/);
|
||||||
|
|
||||||
DebugFactory.InsertSubprogramStart(SP, Builder.GetInsertBlock());
|
// DebugFactory.InsertSubprogramStart(SP, Builder.GetInsertBlock());
|
||||||
|
|
||||||
// Push function on region stack.
|
// Push function on region stack.
|
||||||
RegionStack.push_back(SP);
|
RegionStack.push_back(SP);
|
||||||
|
@ -903,8 +903,19 @@ void CGDebugInfo::EmitStopPoint(llvm::Function *Fn, CGBuilderTy &Builder) {
|
||||||
// Get the appropriate compile unit.
|
// Get the appropriate compile unit.
|
||||||
llvm::DICompileUnit Unit = getOrCreateCompileUnit(CurLoc);
|
llvm::DICompileUnit Unit = getOrCreateCompileUnit(CurLoc);
|
||||||
PresumedLoc PLoc = SM.getPresumedLoc(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(),
|
DebugFactory.InsertStopPoint(Unit, PLoc.getLine(), PLoc.getColumn(),
|
||||||
Builder.GetInsertBlock());
|
Builder.GetInsertBlock());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EmitRegionStart- Constructs the debug code for entering a declarative
|
/// 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 = RegionStack.back();
|
||||||
D = DebugFactory.CreateLexicalBlock(D);
|
D = DebugFactory.CreateLexicalBlock(D);
|
||||||
RegionStack.push_back(D);
|
RegionStack.push_back(D);
|
||||||
|
#ifndef ATTACH_DEBUG_INFO_TO_AN_INSN
|
||||||
DebugFactory.InsertRegionStart(D, Builder.GetInsertBlock());
|
DebugFactory.InsertRegionStart(D, Builder.GetInsertBlock());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EmitRegionEnd - Constructs the debug code for exiting a declarative
|
/// 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.
|
// Provide an region stop point.
|
||||||
EmitStopPoint(Fn, Builder);
|
EmitStopPoint(Fn, Builder);
|
||||||
|
|
||||||
|
#ifndef ATTACH_DEBUG_INFO_TO_AN_INSN
|
||||||
DebugFactory.InsertRegionEnd(RegionStack.back(), Builder.GetInsertBlock());
|
DebugFactory.InsertRegionEnd(RegionStack.back(), Builder.GetInsertBlock());
|
||||||
|
#endif
|
||||||
RegionStack.pop_back();
|
RegionStack.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,4 +148,5 @@ private:
|
||||||
} // namespace CodeGen
|
} // namespace CodeGen
|
||||||
} // namespace clang
|
} // namespace clang
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -31,7 +31,11 @@ llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(const llvm::Type *Ty,
|
||||||
const char *Name) {
|
const char *Name) {
|
||||||
if (!Builder.isNamePreserving())
|
if (!Builder.isNamePreserving())
|
||||||
Name = "";
|
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
|
/// EvaluateExprAsBool - Perform the usual unary conversions on the specified
|
||||||
|
|
|
@ -148,12 +148,13 @@ RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast,
|
||||||
|
|
||||||
CGDebugInfo *DI = getDebugInfo();
|
CGDebugInfo *DI = getDebugInfo();
|
||||||
if (DI) {
|
if (DI) {
|
||||||
|
#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
|
||||||
|
DI->setLocation(S.getLBracLoc());
|
||||||
|
DI->EmitRegionStart(CurFn, Builder);
|
||||||
|
#else
|
||||||
EnsureInsertPoint();
|
EnsureInsertPoint();
|
||||||
DI->setLocation(S.getLBracLoc());
|
DI->setLocation(S.getLBracLoc());
|
||||||
// FIXME: The llvm backend is currently not ready to deal with region_end
|
#endif
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep track of the current cleanup stack depth.
|
// Keep track of the current cleanup stack depth.
|
||||||
|
@ -166,13 +167,13 @@ RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast,
|
||||||
EmitStmt(*I);
|
EmitStmt(*I);
|
||||||
|
|
||||||
if (DI) {
|
if (DI) {
|
||||||
|
#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
|
||||||
|
DI->setLocation(S.getLBracLoc());
|
||||||
|
DI->EmitRegionEnd(CurFn, Builder);
|
||||||
|
#else
|
||||||
EnsureInsertPoint();
|
EnsureInsertPoint();
|
||||||
DI->setLocation(S.getRBracLoc());
|
DI->setLocation(S.getLBracLoc());
|
||||||
|
#endif
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RValue RV;
|
RValue RV;
|
||||||
|
@ -478,6 +479,13 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S) {
|
||||||
BreakContinueStack.push_back(BreakContinue(AfterFor, ContinueBlock));
|
BreakContinueStack.push_back(BreakContinue(AfterFor, ContinueBlock));
|
||||||
|
|
||||||
// If the condition is true, execute the body of the for stmt.
|
// 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());
|
EmitStmt(S.getBody());
|
||||||
|
|
||||||
BreakContinueStack.pop_back();
|
BreakContinueStack.pop_back();
|
||||||
|
@ -490,6 +498,12 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S) {
|
||||||
|
|
||||||
// Finally, branch back up to the condition for the next iteration.
|
// Finally, branch back up to the condition for the next iteration.
|
||||||
EmitBranch(CondBlock);
|
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.
|
// Emit the fall-through block.
|
||||||
EmitBlock(AfterFor, true);
|
EmitBlock(AfterFor, true);
|
||||||
|
|
Loading…
Reference in New Issue