diff options
author | David Stenberg <david.stenberg@ericsson.com> | 2019-05-28 13:23:25 +0000 |
---|---|---|
committer | David Stenberg <david.stenberg@ericsson.com> | 2019-05-28 13:23:25 +0000 |
commit | 5d0e6b6755da38084809d38bf527164a7f285ecd (patch) | |
tree | 0603f89dc3768a237a91e34d25b63a4158abb4ae /llvm/lib/CodeGen/AsmPrinter | |
parent | d3ed418ad3c4bd233b926e586888e177d4fa82be (diff) | |
download | bcm5719-llvm-5d0e6b6755da38084809d38bf527164a7f285ecd.tar.gz bcm5719-llvm-5d0e6b6755da38084809d38bf527164a7f285ecd.zip |
Stop undef fragments from closing non-overlapping fragments
Summary:
When DwarfDebug::buildLocationList() encountered an undef debug value,
it would truncate all open values, regardless if they were overlapping or
not. This patch fixes so that it only does that for overlapping fragments.
This change unearthed a bug that I had introduced in D57511,
which I have fixed in this patch. The code in DebugHandlerBase that
changes labels for parameter debug values could break DwarfDebug's
assumption that the labels for the entries in the debug value history
are monotonically increasing. Before this patch, that bug could result
in location list entries whose ending address was lower than the
beginning address, and with the changes for undef debug values that this
patch introduces it could trigger an assertion, due to attempting to
emit location list entries with empty ranges. A reproducer for the bug
is added in param-reg-const-mix.mir.
Reviewers: aprantl, jmorse, probinson
Reviewed By: aprantl
Subscribers: javed.absar, llvm-commits
Tags: #debug-info, #llvm
Differential Revision: https://reviews.llvm.org/D62379
llvm-svn: 361820
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp | 9 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 22 |
2 files changed, 17 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp index 22c28cccd89..22f458e4b03 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp @@ -246,8 +246,13 @@ void DebugHandlerBase::beginFunction(const MachineFunction *MF) { Pred.getInstr()->getDebugExpression()); })) break; - if (!IsDescribedByReg(I->getInstr())) - LabelsBeforeInsn[I->getInstr()] = Asm->getFunctionBegin(); + // The code that generates location lists for DWARF assumes that the + // entries' start labels are monotonically increasing, and since we + // don't change the label for fragments that are described by + // registers, we must bail out when encountering such a fragment. + if (IsDescribedByReg(I->getInstr())) + break; + LabelsBeforeInsn[I->getInstr()] = Asm->getFunctionBegin(); } } } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 070b1b64a36..f5501a1f0ef 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1139,16 +1139,6 @@ void DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc, for (auto EB = Entries.begin(), EI = EB, EE = Entries.end(); EI != EE; ++EI) { const MachineInstr *Instr = EI->getInstr(); - if (EI->isDbgValue()) { - // Check if a variable is inaccessible in this range. - // TODO: This should only truncate open ranges that are overlapping. - if (Instr->getNumOperands() > 1 && - Instr->getOperand(0).isReg() && !Instr->getOperand(0).getReg()) { - OpenRanges.clear(); - continue; - } - } - // Remove all values that are no longer live. size_t Index = std::distance(EB, EI); auto Last = @@ -1177,8 +1167,16 @@ void DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc, // If this history map entry has a debug value, add that to the list of // open ranges. if (EI->isDbgValue()) { - auto Value = getDebugLocValue(Instr); - OpenRanges.emplace_back(EI->getEndIndex(), Value); + // Do not add undef debug values, as they are redundant information in + // the location list entries. An undef debug results in an empty location + // description. If there are any non-undef fragments then padding pieces + // with empty location descriptions will automatically be inserted, and if + // all fragments are undef then the whole location list entry is + // redundant. + if (!Instr->isUndefDebugValue()) { + auto Value = getDebugLocValue(Instr); + OpenRanges.emplace_back(EI->getEndIndex(), Value); + } } // Location list entries with empty location descriptions are redundant |