Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit de90d74

Browse files
committed
Merging r308808, r308813 and r308906:
------------------------------------------------------------------------ r308808 | arsenm | 2017-07-21 16:56:13 -0700 (Fri, 21 Jul 2017) | 6 lines RA: Remove assert on empty live intervals This is possible if there is an undef use when splitting the vreg during spilling. Fixes bug 33620. ------------------------------------------------------------------------ ------------------------------------------------------------------------ r308813 | arsenm | 2017-07-21 17:24:01 -0700 (Fri, 21 Jul 2017) | 6 lines RA: Remove another assert on empty intervals This case is similar to the one fixed in r308808, except when rematerializing. Fixes bug 33884. ------------------------------------------------------------------------ ------------------------------------------------------------------------ r308906 | arsenm | 2017-07-24 11:07:55 -0700 (Mon, 24 Jul 2017) | 6 lines RA: Replace asserts related to empty live intervals These don't exactly assert the same thing anymore, and allow empty live intervals with non-empty uses. Removed in r308808 and r308813. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_50@309171 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 8842a08 commit de90d74

File tree

3 files changed

+84
-6
lines changed

3 files changed

+84
-6
lines changed

lib/CodeGen/InlineSpiller.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,8 +643,11 @@ void InlineSpiller::reMaterializeAll() {
643643
Edit->eraseVirtReg(Reg);
644644
continue;
645645
}
646-
assert((LIS.hasInterval(Reg) && !LIS.getInterval(Reg).empty()) &&
647-
"Reg with empty interval has reference");
646+
647+
assert(LIS.hasInterval(Reg) &&
648+
(!LIS.getInterval(Reg).empty() || !MRI.reg_nodbg_empty(Reg)) &&
649+
"Empty and not used live-range?!");
650+
648651
RegsToSpill[ResultPos++] = Reg;
649652
}
650653
RegsToSpill.erase(RegsToSpill.begin() + ResultPos, RegsToSpill.end());

lib/CodeGen/RegAllocBase.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,19 @@ void RegAllocBase::allocatePhysRegs() {
133133
if (AvailablePhysReg)
134134
Matrix->assign(*VirtReg, AvailablePhysReg);
135135

136-
for (VirtRegVec::iterator I = SplitVRegs.begin(), E = SplitVRegs.end();
137-
I != E; ++I) {
138-
LiveInterval *SplitVirtReg = &LIS->getInterval(*I);
136+
for (unsigned Reg : SplitVRegs) {
137+
assert(LIS->hasInterval(Reg));
138+
139+
LiveInterval *SplitVirtReg = &LIS->getInterval(Reg);
139140
assert(!VRM->hasPhys(SplitVirtReg->reg) && "Register already assigned");
140141
if (MRI->reg_nodbg_empty(SplitVirtReg->reg)) {
142+
assert(SplitVirtReg->empty() && "Non-empty but used interval");
141143
DEBUG(dbgs() << "not queueing unused " << *SplitVirtReg << '\n');
142144
aboutToRemoveInterval(*SplitVirtReg);
143145
LIS->removeInterval(SplitVirtReg->reg);
144146
continue;
145147
}
146148
DEBUG(dbgs() << "queuing new interval: " << *SplitVirtReg << "\n");
147-
assert(!SplitVirtReg->empty() && "expecting non-empty interval");
148149
assert(TargetRegisterInfo::isVirtualRegister(SplitVirtReg->reg) &&
149150
"expect split value in virtual register");
150151
enqueue(SplitVirtReg);
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# RUN: llc -mtriple=amdgcn-amd-amdhsa-opencl -verify-machineinstrs -stress-regalloc=1 -start-before=simple-register-coalescing -stop-after=greedy -o - %s | FileCheck %s
2+
# https://bugs.llvm.org/show_bug.cgi?id=33620
3+
4+
---
5+
# This would assert due to the empty live interval created for %vreg9
6+
# on the last S_NOP with an undef subreg use.
7+
8+
# CHECK-LABEL: name: expecting_non_empty_interval
9+
10+
# CHECK: undef %7.sub1 = V_MAC_F32_e32 0, undef %1, undef %7.sub1, implicit %exec
11+
# CHECK-NEXT: SI_SPILL_V64_SAVE %7, %stack.0, %sgpr0_sgpr1_sgpr2_sgpr3, %sgpr5, 0, implicit %exec :: (store 8 into %stack.0, align 4)
12+
# CHECK-NEXT: undef %5.sub1 = V_MOV_B32_e32 1786773504, implicit %exec
13+
# CHECK-NEXT: dead %2 = V_MUL_F32_e32 0, %5.sub1, implicit %exec
14+
15+
# CHECK: S_NOP 0, implicit %6.sub1
16+
# CHECK-NEXT: %8 = SI_SPILL_V64_RESTORE %stack.0, %sgpr0_sgpr1_sgpr2_sgpr3, %sgpr5, 0, implicit %exec :: (load 8 from %stack.0, align 4)
17+
# CHECK-NEXT: S_NOP 0, implicit %8.sub1
18+
# CHECK-NEXT: S_NOP 0, implicit undef %9.sub0
19+
20+
name: expecting_non_empty_interval
21+
tracksRegLiveness: true
22+
registers:
23+
- { id: 0, class: vreg_64, preferred-register: '' }
24+
- { id: 1, class: vgpr_32, preferred-register: '' }
25+
- { id: 2, class: vgpr_32, preferred-register: '' }
26+
- { id: 3, class: vreg_64, preferred-register: '' }
27+
body: |
28+
bb.0:
29+
successors: %bb.1
30+
undef %0.sub1 = V_MAC_F32_e32 0, undef %1, undef %0.sub1, implicit %exec
31+
undef %3.sub1 = V_MOV_B32_e32 1786773504, implicit %exec
32+
dead %2 = V_MUL_F32_e32 0, %3.sub1, implicit %exec
33+
34+
bb.1:
35+
S_NOP 0, implicit %3.sub1
36+
S_NOP 0, implicit %0.sub1
37+
S_NOP 0, implicit undef %0.sub0
38+
S_ENDPGM
39+
40+
...
41+
42+
# Similar assert which happens when trying to rematerialize.
43+
# https://bugs.llvm.org/show_bug.cgi?id=33884
44+
---
45+
# CHECK-LABEL: name: rematerialize_empty_interval_has_reference
46+
47+
# CHECK-NOT: MOV
48+
# CHECK: undef %3.sub2 = V_MOV_B32_e32 1786773504, implicit %exec
49+
50+
# CHECK: bb.1:
51+
# CHECK-NEXT: S_NOP 0, implicit %3.sub2
52+
# CHECK-NEXT: S_NOP 0, implicit undef %6.sub0
53+
# CHECK-NEXT: undef %4.sub2 = V_MOV_B32_e32 0, implicit %exec
54+
# CHECK-NEXT: S_NOP 0, implicit %4.sub2
55+
name: rematerialize_empty_interval_has_reference
56+
tracksRegLiveness: true
57+
registers:
58+
- { id: 0, class: vreg_128, preferred-register: '' }
59+
- { id: 1, class: vgpr_32, preferred-register: '' }
60+
- { id: 2, class: vgpr_32, preferred-register: '' }
61+
- { id: 3, class: vreg_128, preferred-register: '' }
62+
body: |
63+
bb.0:
64+
successors: %bb.1
65+
66+
undef %0.sub2 = V_MOV_B32_e32 0, implicit %exec
67+
undef %3.sub2 = V_MOV_B32_e32 1786773504, implicit %exec
68+
69+
bb.1:
70+
S_NOP 0, implicit %3.sub2
71+
S_NOP 0, implicit undef %0.sub0
72+
S_NOP 0, implicit %0.sub2
73+
74+
...

0 commit comments

Comments
 (0)