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
This commit is contained in:
Dan Gohman
2010-05-05 23:41:32 +00:00
parent b7d0688195
commit 1cc0d62855

View File

@@ -2150,8 +2150,20 @@ void DwarfDebug::collectVariableInfo() {
void DwarfDebug::beginScope(const MachineInstr *MI) { void DwarfDebug::beginScope(const MachineInstr *MI) {
// Check location. // Check location.
DebugLoc DL = MI->getDebugLoc(); 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; return;
}
MDNode *Scope = DL.getScope(Asm->MF->getFunction()->getContext()); MDNode *Scope = DL.getScope(Asm->MF->getFunction()->getContext());
@@ -2564,23 +2576,28 @@ MCSymbol *DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, MDNode *S) {
StringRef Dir; StringRef Dir;
StringRef Fn; StringRef Fn;
DIDescriptor Scope(S); unsigned Src = 1;
if (Scope.isCompileUnit()) { if (S) {
DICompileUnit CU(S); DIDescriptor Scope(S);
Dir = CU.getDirectory();
Fn = CU.getFilename(); if (Scope.isCompileUnit()) {
} else if (Scope.isSubprogram()) { DICompileUnit CU(S);
DISubprogram SP(S); Dir = CU.getDirectory();
Dir = SP.getDirectory(); Fn = CU.getFilename();
Fn = SP.getFilename(); } else if (Scope.isSubprogram()) {
} else if (Scope.isLexicalBlock()) { DISubprogram SP(S);
DILexicalBlock DB(S); Dir = SP.getDirectory();
Dir = DB.getDirectory(); Fn = SP.getFilename();
Fn = DB.getFilename(); } else if (Scope.isLexicalBlock()) {
} else DILexicalBlock DB(S);
assert(0 && "Unexpected scope info"); 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(); MCSymbol *Label = MMI->getContext().CreateTempSymbol();
Lines.push_back(SrcLineInfo(Line, Col, Src, Label)); Lines.push_back(SrcLineInfo(Line, Col, Src, Label));
@@ -2967,8 +2984,6 @@ void DwarfDebug::emitDebugLines() {
MCSymbol *Label = LineInfo.getLabel(); MCSymbol *Label = LineInfo.getLabel();
if (!Label->isDefined()) continue; // Not emitted, in dead code. if (!Label->isDefined()) continue; // Not emitted, in dead code.
if (LineInfo.getLine() == 0) continue;
if (Asm->isVerbose()) { if (Asm->isVerbose()) {
std::pair<unsigned, unsigned> SrcID = std::pair<unsigned, unsigned> SrcID =
getSourceDirectoryAndFileIds(LineInfo.getSourceID()); getSourceDirectoryAndFileIds(LineInfo.getSourceID());