summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
diff options
context:
space:
mode:
authorTimur Iskhodzhanov <timurrrr@google.com>2013-12-03 12:05:18 +0000
committerTimur Iskhodzhanov <timurrrr@google.com>2013-12-03 12:05:18 +0000
commit4c719cf6c65f88af719f7e3582afd5ced4c5561f (patch)
treea6f830ee6949f5f165d6b533c29f1de3aa96dac9 /llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
parent8a25992f39b0001c980388d26cbfccb1e86e89d8 (diff)
downloadbcm5719-llvm-4c719cf6c65f88af719f7e3582afd5ced4c5561f.tar.gz
bcm5719-llvm-4c719cf6c65f88af719f7e3582afd5ced4c5561f.zip
Generalize debug info / EH emission in AsmPrinter
llvm-svn: 196270
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp44
1 files changed, 27 insertions, 17 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index ec5df1ec4c7..04bdfe7ae8d 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -197,6 +197,7 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M)
DwarfAddrSectionSym = 0;
DwarfAbbrevDWOSectionSym = DwarfStrDWOSectionSym = 0;
FunctionBeginSym = FunctionEndSym = 0;
+ CurFn = 0; CurMI = 0;
// Turn on accelerator tables for Darwin by default, pubnames by
// default for non-Darwin, and handle split dwarf.
@@ -1144,6 +1145,7 @@ void DwarfDebug::endSections() {
// Emit all Dwarf sections that should come after the content.
void DwarfDebug::endModule() {
+ assert(CurFn == 0);
if (!FirstCU)
return;
@@ -1225,8 +1227,7 @@ DbgVariable *DwarfDebug::findAbstractVariable(DIVariable &DV,
}
// If Var is a current function argument then add it to CurrentFnArguments list.
-bool DwarfDebug::addCurrentFnArgument(const MachineFunction *MF,
- DbgVariable *Var, LexicalScope *Scope) {
+bool DwarfDebug::addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope) {
if (!LScopes.isCurrentFunctionScope(Scope))
return false;
DIVariable DV = Var->getVariable();
@@ -1238,7 +1239,7 @@ bool DwarfDebug::addCurrentFnArgument(const MachineFunction *MF,
size_t Size = CurrentFnArguments.size();
if (Size == 0)
- CurrentFnArguments.resize(MF->getFunction()->arg_size());
+ CurrentFnArguments.resize(CurFn->getFunction()->arg_size());
// llvm::Function argument size is not good indicator of how many
// arguments does the function have at source level.
if (ArgNo > Size)
@@ -1249,7 +1250,7 @@ bool DwarfDebug::addCurrentFnArgument(const MachineFunction *MF,
// Collect variable information from side table maintained by MMI.
void DwarfDebug::collectVariableInfoFromMMITable(
- const MachineFunction *MF, SmallPtrSet<const MDNode *, 16> &Processed) {
+ SmallPtrSet<const MDNode *, 16> &Processed) {
MachineModuleInfo::VariableDbgInfoMapTy &VMap = MMI->getVariableDbgInfo();
for (MachineModuleInfo::VariableDbgInfoMapTy::iterator VI = VMap.begin(),
VE = VMap.end();
@@ -1270,7 +1271,7 @@ void DwarfDebug::collectVariableInfoFromMMITable(
DbgVariable *AbsDbgVariable = findAbstractVariable(DV, VP.second);
DbgVariable *RegVar = new DbgVariable(DV, AbsDbgVariable, this);
RegVar->setFrameIndex(VP.first);
- if (!addCurrentFnArgument(MF, RegVar, Scope))
+ if (!addCurrentFnArgument(RegVar, Scope))
addScopeVariable(Scope, RegVar);
if (AbsDbgVariable)
AbsDbgVariable->setFrameIndex(VP.first);
@@ -1317,11 +1318,10 @@ static DotDebugLocEntry getDebugLocEntry(AsmPrinter *Asm,
// Find variables for each lexical scope.
void
-DwarfDebug::collectVariableInfo(const MachineFunction *MF,
- SmallPtrSet<const MDNode *, 16> &Processed) {
+DwarfDebug::collectVariableInfo(SmallPtrSet<const MDNode *, 16> &Processed) {
// Grab the variable info that was squirreled away in the MMI side-table.
- collectVariableInfoFromMMITable(MF, Processed);
+ collectVariableInfoFromMMITable(Processed);
for (SmallVectorImpl<const MDNode *>::const_iterator
UVI = UserVariables.begin(),
@@ -1341,7 +1341,7 @@ DwarfDebug::collectVariableInfo(const MachineFunction *MF,
DIVariable DV(Var);
LexicalScope *Scope = NULL;
if (DV.getTag() == dwarf::DW_TAG_arg_variable &&
- DISubprogram(DV.getContext()).describes(MF->getFunction()))
+ DISubprogram(DV.getContext()).describes(CurFn->getFunction()))
Scope = LScopes.getCurrentFunctionScope();
else if (MDNode *IA = DV.getInlinedAt())
Scope = LScopes.findInlinedScope(DebugLoc::getFromDILocation(IA));
@@ -1355,7 +1355,7 @@ DwarfDebug::collectVariableInfo(const MachineFunction *MF,
assert(MInsn->isDebugValue() && "History must begin with debug value");
DbgVariable *AbsVar = findAbstractVariable(DV, MInsn->getDebugLoc());
DbgVariable *RegVar = new DbgVariable(DV, AbsVar, this);
- if (!addCurrentFnArgument(MF, RegVar, Scope))
+ if (!addCurrentFnArgument(RegVar, Scope))
addScopeVariable(Scope, RegVar);
if (AbsVar)
AbsVar->setMInsn(MInsn);
@@ -1437,6 +1437,8 @@ MCSymbol *DwarfDebug::getLabelAfterInsn(const MachineInstr *MI) {
// Process beginning of an instruction.
void DwarfDebug::beginInstruction(const MachineInstr *MI) {
+ assert(CurMI == 0);
+ CurMI = MI;
// Check if source location changes, but ignore DBG_VALUE locations.
if (!MI->isDebugValue()) {
DebugLoc DL = MI->getDebugLoc();
@@ -1478,14 +1480,16 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
}
// Process end of an instruction.
-void DwarfDebug::endInstruction(const MachineInstr *MI) {
+void DwarfDebug::endInstruction() {
+ assert(CurMI != 0);
// Don't create a new label after DBG_VALUE instructions.
// They don't generate code.
- if (!MI->isDebugValue())
+ if (!CurMI->isDebugValue())
PrevLabel = 0;
DenseMap<const MachineInstr *, MCSymbol *>::iterator I =
- LabelsAfterInsn.find(MI);
+ LabelsAfterInsn.find(CurMI);
+ CurMI = 0;
// No label needed.
if (I == LabelsAfterInsn.end())
@@ -1565,6 +1569,7 @@ static DebugLoc getFnDebugLoc(DebugLoc DL, const LLVMContext &Ctx) {
// Gather pre-function debug information. Assumes being called immediately
// after the function entry point has been emitted.
void DwarfDebug::beginFunction(const MachineFunction *MF) {
+ CurFn = MF;
// If there's no debug info for the function we're not going to do anything.
if (!MMI->hasDebugInfo())
@@ -1791,9 +1796,13 @@ void DwarfDebug::addScopeVariable(LexicalScope *LS, DbgVariable *Var) {
}
// Gather and emit post-function debug information.
-void DwarfDebug::endFunction(const MachineFunction *MF) {
- if (!MMI->hasDebugInfo() || LScopes.empty())
+void DwarfDebug::endFunction() {
+ assert(CurFn != 0);
+
+ if (!MMI->hasDebugInfo() || LScopes.empty()) {
+ CurFn = 0;
return;
+ }
// Define end label for subprogram.
FunctionEndSym = Asm->GetTempSymbol("func_end", Asm->getFunctionNumber());
@@ -1803,7 +1812,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
Asm->OutStreamer.getContext().setDwarfCompileUnitID(0);
SmallPtrSet<const MDNode *, 16> ProcessedVars;
- collectVariableInfo(MF, ProcessedVars);
+ collectVariableInfo(ProcessedVars);
LexicalScope *FnScope = LScopes.getCurrentFunctionScope();
CompileUnit *TheCU = SPMap.lookup(FnScope->getScopeNode());
@@ -1837,7 +1846,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
DIE *CurFnDIE = constructScopeDIE(TheCU, FnScope);
- if (!MF->getTarget().Options.DisableFramePointerElim(*MF))
+ if (!CurFn->getTarget().Options.DisableFramePointerElim(*CurFn))
TheCU->addFlag(CurFnDIE, dwarf::DW_AT_APPLE_omit_frame_ptr);
// Clear debug info
@@ -1853,6 +1862,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
LabelsBeforeInsn.clear();
LabelsAfterInsn.clear();
PrevLabel = NULL;
+ CurFn = 0;
}
// Register a source line with debug info. Returns the unique label that was
OpenPOWER on IntegriCloud