[llvm] [SDAG] Use useDebugInstrRef instead of shouldUseDebugInstrRef (PR #160686)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 25 04:25:52 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-selectiondag
Author: Mikołaj Piróg (mikolaj-pirog)
<details>
<summary>Changes</summary>
`shouldUseDebugInstrRef` can return different value than `useDebugInstrRef`, since the first depends on opt level which can change. Inconsistent usage can lead to errors later.
I believe that using `should...` instead of `use...` here is a result of a minor error during this: https://github.com/llvm/llvm-project/pull/94149/files#diff-8ec547e1244562c5837ed180dd9bed61b3cd960ef90bb6002ea2db41a67ed693
Notice how before the change `InstrRef` is assigned value from `should...` *before* the opt change. Now, it's done after -- opt change happens here:
```c
bool SelectionDAGISelLegacy::runOnMachineFunction(MachineFunction &MF) {
...
// Decide what flavour of variable location debug-info will be used, before
// we change the optimisation level.
MF.setUseDebugInstrRef(MF.shouldUseDebugInstrRef());
....
return Selector->runOnMachineFunction(MF);
}
```
Then `runOnMachineFunction` uses `should...`, which after opt change may return different value than it did previously.
---
Full diff: https://github.com/llvm/llvm-project/pull/160686.diff
1 Files Affected:
- (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (+1-1)
``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index e61558c59bf0d..214edfc7c07f3 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -566,7 +566,7 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
SwiftError->setFunction(mf);
const Function &Fn = mf.getFunction();
- bool InstrRef = mf.shouldUseDebugInstrRef();
+ bool InstrRef = mf.useDebugInstrRef();
FuncInfo->set(MF->getFunction(), *MF, CurDAG);
``````````
</details>
https://github.com/llvm/llvm-project/pull/160686
More information about the llvm-commits
mailing list