[llvm] [Hexagon] Ignore debug uses in constant extender optimization (PR #231014)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 11 10:40:41 PDT 2026
https://github.com/Aayuparm created https://github.com/llvm/llvm-project/pull/231014
## Summary
The Hexagon constant-extender optimization pass currently includes debug
register uses when calculating offset ranges and when collecting uses whose
offsets need updating.
This allows a `DBG_VALUE` instruction to change the generated ordinary
Machine IR.
Use `use_nodbg_operands()` in both scans so debug-only uses do not affect
constant-extender optimization.
## Testing
Reproduced the original issue before the change (reproducer provided
in the original issue):
ordinary Machine IR: DIFFER (expected)
After rebuilding llc with the change, the reproducer reports:
unexpected: ordinary Machine IR is equal
The latter is the expected fixed behavior because the reproducer script was
written to fail when the ordinary Machine IR becomes equal.
Reproducer command:
LLC=../build/bin/llc ./issue-reproducer.sh
Issue - [https://github.com/llvm/llvm-project/issues/227926](url)
>From 323f4441f57bc061761188ad6e3536d968866eae Mon Sep 17 00:00:00 2001
From: Aayush Parmar <aayuparm at qti.qualcomm.com>
Date: Sun, 11 Oct 2026 22:35:14 +0530
Subject: [PATCH] [Hexagon] Ignore debug uses in constant extender optimization
---
llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp b/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
index 90df4a5633dbb..273b07b60439f 100644
--- a/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
@@ -1117,7 +1117,7 @@ OffsetRange HCE::getOffsetRange(const ExtDesc &ED) const {
// all uses of Rd.
OffsetRange HCE::getOffsetRange(Register Rd) const {
OffsetRange Range;
- for (const MachineOperand &Op : MRI->use_operands(Rd.Reg)) {
+ for (const MachineOperand &Op : MRI->use_nodbg_operands(Rd.Reg)) {
// Make sure that the register being used by this operand is identical
// to the register that was defined: using a different subregister
// precludes any non-trivial range.
@@ -1861,7 +1861,7 @@ bool HCE::replaceInstr(unsigned Idx, Register ExtR, const ExtenderInit &ExtI) {
// must follow the Rd in the operand list.
std::vector<std::pair<MachineInstr*,unsigned>> RegOps;
if (ED.IsDef && Diff != 0) {
- for (MachineOperand &Op : MRI->use_operands(ED.Rd.Reg)) {
+ for (MachineOperand &Op : MRI->use_nodbg_operands(ED.Rd.Reg)) {
MachineInstr &UI = *Op.getParent();
RegOps.push_back({&UI, getOperandIndex(UI, Op)});
}
More information about the llvm-commits
mailing list