[PATCH] D69955: [DebugInfo] Add helper for finding entry value candidates [NFC]
David Stenberg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 7 10:10:45 PST 2019
dstenb created this revision.
dstenb added reviewers: djtodoro, NikolaPrica.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
dstenb added a child revision: D69889: [DebugInfo] Avoid creating entry values for clobbered registers.
The conditions that are used to determine if entry values should be
emitted for a parameter are quite many, and will grow slightly
in a follow-up commit, so move those to a helper function, as was
suggested in the code review for D69889 <https://reviews.llvm.org/D69889>.
Repository:
rL LLVM
https://reviews.llvm.org/D69955
Files:
llvm/lib/CodeGen/LiveDebugValues.cpp
Index: llvm/lib/CodeGen/LiveDebugValues.cpp
===================================================================
--- llvm/lib/CodeGen/LiveDebugValues.cpp
+++ llvm/lib/CodeGen/LiveDebugValues.cpp
@@ -1285,15 +1285,6 @@
std::greater<unsigned int>>
Pending;
- // Besides parameter's modification, check whether a DBG_VALUE is inlined
- // in order to deduce whether the variable that it tracks comes from
- // a different function. If that is the case we can't track its entry value.
- auto IsUnmodifiedFuncParam = [&](const MachineInstr &MI) {
- auto *DIVar = MI.getDebugVariable();
- return DIVar->isParameter() && DIVar->isNotModified() &&
- !MI.getDebugLoc()->getInlinedAt();
- };
-
const TargetLowering *TLI = MF.getSubtarget().getTargetLowering();
unsigned SP = TLI->getStackPointerRegisterToSaveRestore();
Register FP = TRI->getFrameRegister(MF);
@@ -1305,21 +1296,51 @@
// representing candidates for production of debug entry values.
DebugParamMap DebugEntryVals;
- MachineBasicBlock &First_MBB = *(MF.begin());
// Only in the case of entry MBB collect DBG_VALUEs representing
// function parameters in order to generate debug entry values for them.
+ //
// Currently, we generate debug entry values only for parameters that are
// unmodified throughout the function and located in a register.
- // TODO: Add support for parameters that are described as fragments.
- // TODO: Add support for modified arguments that can be expressed
- // by using its entry value.
- // TODO: Add support for local variables that are expressed in terms of
- // parameters entry values.
+ auto IsEntryValueCandidate = [&](const MachineInstr &MI) {
+ if (!MI.isDebugValue())
+ return false;
+
+ // TODO: Add support for local variables that are expressed in terms of
+ // parameters entry values.
+ // TODO: Add support for modified arguments that can be expressed
+ // by using its entry value.
+ auto *DIVar = MI.getDebugVariable();
+ if (!DIVar->isParameter() || !DIVar->isNotModified())
+ return false;
+
+ // Do not consider parameters that belong to an inlined function.
+ if (MI.getDebugLoc()->getInlinedAt())
+ return false;
+
+ // Do not consider indirect debug values (TODO: explain why).
+ if (MI.isIndirectDebugValue())
+ return false;
+
+ // Only consider parameters that are described using registers. Parameters
+ // that are passed on the stack are not yet supported, so ignore debug
+ // values that are described by the frame or stack pointer.
+ if (!IsRegOtherThanSPAndFP(MI.getOperand(0)))
+ return false;
+
+ // Do not consider parameters that we have already handled.
+ if (DebugEntryVals.count(MI.getDebugVariable()))
+ return false;
+
+ // TODO: Add support for parameters that are described as fragments.
+ if (MI.getDebugExpression()->isFragment())
+ return false;
+
+ return true;
+ };
+
+ MachineBasicBlock &First_MBB = *(MF.begin());
for (auto &MI : First_MBB)
- if (MI.isDebugValue() && IsUnmodifiedFuncParam(MI) &&
- !MI.isIndirectDebugValue() && IsRegOtherThanSPAndFP(MI.getOperand(0)) &&
- !DebugEntryVals.count(MI.getDebugVariable()) &&
- !MI.getDebugExpression()->isFragment())
+ if (IsEntryValueCandidate(MI))
DebugEntryVals[MI.getDebugVariable()] = &MI;
// Initialize per-block structures and scan for fragment overlaps.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69955.228273.patch
Type: text/x-patch
Size: 3472 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191107/35d1b10c/attachment.bin>
More information about the llvm-commits
mailing list