diff options
author | Dan Gohman <gohman@apple.com> | 2010-05-05 23:41:32 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-05-05 23:41:32 +0000 |
commit | 1cc0d628552a43568ec7c143698025ab18f2e072 (patch) | |
tree | 1d7064bf0f504ca4d7a77e424f0b445ac8e54f40 /lib/CodeGen/AsmPrinter/DwarfDebug.cpp | |
parent | b7d0688195a7bac5b53361d7b44d56b813d30246 (diff) |
Emit debug info for MachineInstrs with unknown debug locations, instead
of just letting them inherit the debug locations of adjacent instructions.
Debug info should aim to be either accurate or absent.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103135 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index e9e9ba55db..4da549866b 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -2150,8 +2150,20 @@ void DwarfDebug::collectVariableInfo() { void DwarfDebug::beginScope(const MachineInstr *MI) { // Check location. DebugLoc DL = MI->getDebugLoc(); - if (DL.isUnknown()) + if (DL.isUnknown()) { + // This instruction has no debug location. If the preceding instruction + // did, emit debug location information to indicate that the debug + // location is now unknown. + MCSymbol *Label = NULL; + if (DL == PrevInstLoc) + Label = PrevLabel; + else { + Label = recordSourceLine(DL.getLine(), DL.getCol(), 0); + PrevInstLoc = DL; + PrevLabel = Label; + } return; + } MDNode *Scope = DL.getScope(Asm->MF->getFunction()->getContext()); @@ -2564,23 +2576,28 @@ MCSymbol *DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, MDNode *S) { StringRef Dir; StringRef Fn; - DIDescriptor Scope(S); - if (Scope.isCompileUnit()) { - DICompileUnit CU(S); - Dir = CU.getDirectory(); - Fn = CU.getFilename(); - } else if (Scope.isSubprogram()) { - DISubprogram SP(S); - Dir = SP.getDirectory(); - Fn = SP.getFilename(); - } else if (Scope.isLexicalBlock()) { - DILexicalBlock DB(S); - Dir = DB.getDirectory(); - Fn = DB.getFilename(); - } else - assert(0 && "Unexpected scope info"); + unsigned Src = 1; + if (S) { + DIDescriptor Scope(S); + + if (Scope.isCompileUnit()) { + DICompileUnit CU(S); + Dir = CU.getDirectory(); + Fn = CU.getFilename(); + } else if (Scope.isSubprogram()) { + DISubprogram SP(S); + Dir = SP.getDirectory(); + Fn = SP.getFilename(); + } else if (Scope.isLexicalBlock()) { + DILexicalBlock DB(S); + Dir = DB.getDirectory(); + Fn = DB.getFilename(); + } else + assert(0 && "Unexpected scope info"); + + Src = GetOrCreateSourceID(Dir, Fn); + } - unsigned Src = GetOrCreateSourceID(Dir, Fn); MCSymbol *Label = MMI->getContext().CreateTempSymbol(); Lines.push_back(SrcLineInfo(Line, Col, Src, Label)); @@ -2967,8 +2984,6 @@ void DwarfDebug::emitDebugLines() { MCSymbol *Label = LineInfo.getLabel(); if (!Label->isDefined()) continue; // Not emitted, in dead code. - if (LineInfo.getLine() == 0) continue; - if (Asm->isVerbose()) { std::pair<unsigned, unsigned> SrcID = getSourceDirectoryAndFileIds(LineInfo.getSourceID()); |