[llvm] [Hexagon] Ignore debug uses in constant extender optimization (PR #231014)

via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 11 10:41:29 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-hexagon

Author: Aayuparm

<details>
<summary>Changes</summary>

## 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)

---
Full diff: https://github.com/llvm/llvm-project/pull/231014.diff


1 Files Affected:

- (modified) llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp (+2-2) 


``````````diff
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)});
     }

``````````

</details>


https://github.com/llvm/llvm-project/pull/231014


More information about the llvm-commits mailing list