[PATCH] D83468: [Debuginfo] Fix for PR46653
Jaydeep Chauhan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 19 12:19:58 PDT 2020
Jac1494 added a comment.
>> Also possible it's not a bug at all & GlobalISel just ends up doing some optimization that does end up creating a necessary/correct line 0 at the start of the function where SelectionDAG/FastISel does not.
@dblaikie SelectionDAG/FastISel is also creating necessary/correct line zero. Also this line zero is user can control using "-use-unknown-locations=Disable" option as per below code.But this options is not fully working for Global-isel because of incorrect line zeros.
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:1964
if (!DL) {
// We have an unspecified location, which might want to be line 0.
// If we have already emitted a line-0 record, don't repeat it.
if (LastAsmLine == 0)
return;
// If user said Don't Do That, don't do that.
if (UnknownLocations == Disable)
return;
// See if we have a reason to emit a line-0 record now.
// Reasons to emit a line-0 record include:
// - User asked for it (UnknownLocations).
// - Instruction has a label, so it's referenced from somewhere else,
// possibly debug information; we want it to have a source location.
// - Instruction is at the top of a block; we don't want to inherit the
// location from the physically previous (maybe unrelated) block.
if (UnknownLocations == Enable || PrevLabel ||
(PrevInstBB && PrevInstBB != MI->getParent())) {
// Preserve the file and column numbers, if we can, to save space in
// the encoded line table.
// Do not update PrevInstLoc, it remembers the last non-0 line.
const MDNode *Scope = nullptr;
unsigned Column = 0;
if (PrevInstLoc) {
Scope = PrevInstLoc.getScope();
Column = PrevInstLoc.getCol();
}
recordSourceLine(/*Line=*/0, Column, Scope, /*Flags=*/0);
}
return;
}
List of SelectionDAG/FastIsel base test cases are given below which creating meaningful/correct line zero.
CodeGen/X86/dbg-line-0-no-discriminator.ll
CodeGen/X86/stack-protector.ll
CodeGen/X86/unknown-location.ll
DebugInfo/AArch64/line-header.ll
DebugInfo/MIR/X86/debug-loc-0.mir
DebugInfo/X86/dbg-prolog-end.ll
DebugInfo/X86/dwarf-no-source-loc.ll
DebugInfo/X86/tail-merge.ll
>> Best to look at the assembly/optimizations/etc and see why it's getting line zero and decide whether it's dropping a usable location, or doing the right thing with line 0.
Because of below code Global-isel is creating line zero and This is still looks incorrect to me,Because it is not solving jump behavior but it is creating jump behavior by adding line zero.
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp:2183
// We only emit constants into the entry block from here. To prevent jumpy
// debug behaviour set the line to 0.
if (const DebugLoc &DL = Inst.getDebugLoc())
EntryBuilder->setDebugLoc(
DebugLoc::get(0, 0, DL.getScope(), DL.getInlinedAt()));
else
EntryBuilder->setDebugLoc(DebugLoc());
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83468/new/
https://reviews.llvm.org/D83468
More information about the llvm-commits
mailing list