Skip to content

Commit 9699442

Browse files
author
Hendrik Greving
committed
RegisterCoalescer: Fix iterating through use operands.
Fixes a minor bug when trying to iterate through use operands when updating debug use operands. Extends a test to include above. Differential Revision: https://reviews.llvm.org/D104576
1 parent 186f2ac commit 9699442

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

llvm/lib/CodeGen/RegisterCoalescer.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1557,7 +1557,9 @@ bool RegisterCoalescer::reMaterializeTrivialDef(const CoalescerPair &CP,
15571557
// If the virtual SrcReg is completely eliminated, update all DBG_VALUEs
15581558
// to describe DstReg instead.
15591559
if (MRI->use_nodbg_empty(SrcReg)) {
1560-
for (MachineOperand &UseMO : MRI->use_operands(SrcReg)) {
1560+
for (MachineRegisterInfo::use_iterator UI = MRI->use_begin(SrcReg);
1561+
UI != MRI->use_end();) {
1562+
MachineOperand &UseMO = *UI++;
15611563
MachineInstr *UseMI = UseMO.getParent();
15621564
if (UseMI->isDebugValue()) {
15631565
if (Register::isPhysicalRegister(DstReg))

llvm/test/DebugInfo/MIR/X86/regcoalescer.mir

+10-7
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@
2727
!16 = !{!7}
2828
!17 = !{!18}
2929
!18 = !DILocalVariable(name: "bazinga", scope: !14, file: !1, line: 13, type: !7)
30-
!19 = !DILocation(line: 14, column: 11, scope: !14)
31-
!20 = !DILocation(line: 13, column: 7, scope: !14)
32-
!21 = !DILocation(line: 16, column: 3, scope: !14)
30+
!19 = !DILocalVariable(name: "bazinga2", scope: !14, file: !1, line: 13, type: !7)
31+
!20 = !DILocation(line: 14, column: 11, scope: !14)
32+
!21 = !DILocation(line: 13, column: 7, scope: !14)
33+
!22 = !DILocation(line: 16, column: 3, scope: !14)
3334

3435
...
3536
---
@@ -39,12 +40,14 @@ registers:
3940
- { id: 0, class: gr32, preferred-register: '' }
4041
body: |
4142
bb.0.entry:
42-
%0 = MOV32r0 implicit-def dead $eflags, debug-location !19
43-
DBG_VALUE %0, _, !18, !DIExpression(), debug-location !20
44-
$eax = COPY killed %0, debug-location !21
45-
RET 0, killed $eax, debug-location !21
43+
%0 = MOV32r0 implicit-def dead $eflags, debug-location !20
44+
DBG_VALUE %0, _, !18, !DIExpression(), debug-location !21
45+
DBG_VALUE %0, _, !19, !DIExpression(), debug-location !22
46+
$eax = COPY killed %0, debug-location !22
47+
RET 0, killed $eax, debug-location !22
4648
4749
...
4850

4951
# CHECK: $eax = MOV32r0
5052
# CHECK-NEXT: DBG_VALUE $eax
53+
# CHECK-NEXT: DBG_VALUE $eax

0 commit comments

Comments
 (0)