diff options
author | Sriraman Tallam <tmsriram@google.com> | 2021-05-26 17:12:31 -0700 |
---|---|---|
committer | Sriraman Tallam <tmsriram@google.com> | 2021-05-26 17:12:31 -0700 |
commit | caae570978c490a137921b9516162a382831209e (patch) | |
tree | 807ce9c57ea16b3cce0182c823624ed364d127c7 /llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp | |
parent | 74edfb28053dac26d82d1372123be03db630ef62 (diff) | |
download | llvm-caae570978c490a137921b9516162a382831209e.zip llvm-caae570978c490a137921b9516162a382831209e.tar.gz llvm-caae570978c490a137921b9516162a382831209e.tar.bz2 |
Emit correct location lists with basic block sections.
This patch addresses multiple things:
1) It ensures that const_value is emitted when possible with basic block
sections.
2) It emits location lists such that the labels are always within the
section boundary.
3) It fixes a bug when the parameter is first used in a non-entry block
which is in a different section from the entry block.
Differential Revision: https://reviews.llvm.org/D85085
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp index 70a4d5f..c81288c 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp @@ -290,16 +290,10 @@ void DebugHandlerBase::beginFunction(const MachineFunction *MF) { // doing that violates the ranges that are calculated in the history map. // However, we currently do not emit debug values for constant arguments // directly at the start of the function, so this code is still useful. - // FIXME: If the first mention of an argument is in a unique section basic - // block, we cannot always assign the CurrentFnBeginLabel as it lies in a - // different section. Temporarily, we disable generating loc list - // information or DW_AT_const_value when the block is in a different - // section. const DILocalVariable *DIVar = Entries.front().getInstr()->getDebugVariable(); if (DIVar->isParameter() && - getDISubprogram(DIVar->getScope())->describes(&MF->getFunction()) && - Entries.front().getInstr()->getParent()->sameSection(&MF->front())) { + getDISubprogram(DIVar->getScope())->describes(&MF->getFunction())) { if (!IsDescribedByReg(Entries.front().getInstr())) LabelsBeforeInsn[Entries.front().getInstr()] = Asm->getFunctionBegin(); if (Entries.front().getInstr()->getDebugExpression()->isFragment()) { @@ -385,22 +379,25 @@ void DebugHandlerBase::endInstruction() { DenseMap<const MachineInstr *, MCSymbol *>::iterator I = LabelsAfterInsn.find(CurMI); - CurMI = nullptr; - // No label needed. - if (I == LabelsAfterInsn.end()) - return; - - // Label already assigned. - if (I->second) + // No label needed or label already assigned. + if (I == LabelsAfterInsn.end() || I->second) { + CurMI = nullptr; return; + } - // We need a label after this instruction. - if (!PrevLabel) { + // We need a label after this instruction. With basic block sections, just + // use the end symbol of the section if this is the last instruction of the + // section. This reduces the need for an additional label and also helps + // merging ranges. + if (CurMI->getParent()->isEndSection() && CurMI->getNextNode() == nullptr) { + PrevLabel = CurMI->getParent()->getEndSymbol(); + } else if (!PrevLabel) { PrevLabel = MMI->getContext().createTempSymbol(); Asm->OutStreamer->emitLabel(PrevLabel); } I->second = PrevLabel; + CurMI = nullptr; } void DebugHandlerBase::endFunction(const MachineFunction *MF) { |