aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/CodeGen/MachineDebugify.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2024-07-27 23:34:35 +0000
committerDimitry Andric <dim@FreeBSD.org>2024-12-01 12:32:12 +0000
commitfbc266465ed3585efdbd8e9ebf71e97ce7e8b464 (patch)
tree7560c2cbec09e542e5f2e2100ffc16ca742b1075 /contrib/llvm-project/llvm/lib/CodeGen/MachineDebugify.cpp
parentac8517f04c0fe31968ed43e36608ad02d72d3597 (diff)
Diffstat (limited to 'contrib/llvm-project/llvm/lib/CodeGen/MachineDebugify.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/CodeGen/MachineDebugify.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/contrib/llvm-project/llvm/lib/CodeGen/MachineDebugify.cpp b/contrib/llvm-project/llvm/lib/CodeGen/MachineDebugify.cpp
index c264e199cf47..bffdd51bfbca 100644
--- a/contrib/llvm-project/llvm/lib/CodeGen/MachineDebugify.cpp
+++ b/contrib/llvm-project/llvm/lib/CodeGen/MachineDebugify.cpp
@@ -65,6 +65,7 @@ bool applyDebugifyMetadataToMachineFunction(MachineModuleInfo &MMI,
// all the others.
Function *DbgValF = M.getFunction("llvm.dbg.value");
DbgValueInst *EarliestDVI = nullptr;
+ DbgVariableRecord *EarliestDVR = nullptr;
DenseMap<unsigned, DILocalVariable *> Line2Var;
DIExpression *Expr = nullptr;
if (DbgValF) {
@@ -80,6 +81,20 @@ bool applyDebugifyMetadataToMachineFunction(MachineModuleInfo &MMI,
Expr = DVI->getExpression();
}
}
+ for (BasicBlock &BB : F) {
+ for (Instruction &I : BB) {
+ for (DbgVariableRecord &DVR : filterDbgVars(I.getDbgRecordRange())) {
+ if (!DVR.isDbgValue())
+ continue;
+ unsigned Line = DVR.getDebugLoc().getLine();
+ assert(Line != 0 && "debugify should not insert line 0 locations");
+ Line2Var[Line] = DVR.getVariable();
+ if (!EarliestDVR || Line < EarliestDVR->getDebugLoc().getLine())
+ EarliestDVR = &DVR;
+ Expr = DVR.getExpression();
+ }
+ }
+ }
if (Line2Var.empty())
return true;
@@ -109,7 +124,8 @@ bool applyDebugifyMetadataToMachineFunction(MachineModuleInfo &MMI,
// Find a suitable local variable for the DBG_VALUE.
unsigned Line = MI.getDebugLoc().getLine();
if (!Line2Var.count(Line))
- Line = EarliestDVI->getDebugLoc().getLine();
+ Line = EarliestDVI ? EarliestDVI->getDebugLoc().getLine()
+ : EarliestDVR->getDebugLoc().getLine();
DILocalVariable *LocalVar = Line2Var[Line];
assert(LocalVar && "No variable for current line?");
VarSet.insert(LocalVar);