[clang] [llvm] [CodeGen] Fix VNInfo mapping in LiveRange::assign (PR #148790)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 15 00:07:55 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-regalloc

Author: None (pzzp)

<details>
<summary>Changes</summary>

Ensure segments use the correct copied VNInfos when assigning from another
LiveRange.

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


1 Files Affected:

- (modified) llvm/include/llvm/CodeGen/LiveInterval.h (+3-1) 


``````````diff
diff --git a/llvm/include/llvm/CodeGen/LiveInterval.h b/llvm/include/llvm/CodeGen/LiveInterval.h
index e1c5717f5face..29c3416ccc0c8 100644
--- a/llvm/include/llvm/CodeGen/LiveInterval.h
+++ b/llvm/include/llvm/CodeGen/LiveInterval.h
@@ -257,11 +257,13 @@ namespace llvm {
       assert(Other.segmentSet == nullptr &&
              "Copying of LiveRanges with active SegmentSets is not supported");
       // Duplicate valnos.
+      auto FirstNewVNIIdx = valnos.size();
       for (const VNInfo *VNI : Other.valnos)
         createValueCopy(VNI, Allocator);
       // Now we can copy segments and remap their valnos.
       for (const Segment &S : Other.segments)
-        segments.push_back(Segment(S.start, S.end, valnos[S.valno->id]));
+        segments.push_back(
+            Segment(S.start, S.end, valnos[FirstNewVNIIdx + S.valno->id]));
     }
 
     /// advanceTo - Advance the specified iterator to point to the Segment

``````````

</details>


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


More information about the llvm-commits mailing list