Skip to content

Commit 4f1c8bc

Browse files
committed
[RegAlloc] Fix use-after-free in RegAllocBase::cleanupFailedVReg
Since #128400 already mentions it's not clear about the necessity of removing intervals from regunits, this PR avoids the issue by simply skipping that step. Fixes SWDEV-527146.
1 parent 08e40c1 commit 4f1c8bc

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

llvm/lib/CodeGen/RegAllocBase.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,8 @@ void RegAllocBase::cleanupFailedVReg(Register FailedReg, MCRegister PhysReg,
178178
for (MCRegAliasIterator Aliases(PhysReg, TRI, true); Aliases.isValid();
179179
++Aliases) {
180180
for (MachineOperand &MO : MRI->reg_operands(*Aliases)) {
181-
if (MO.readsReg()) {
181+
if (MO.readsReg())
182182
MO.setIsUndef(true);
183-
LIS->removeAllRegUnitsForPhysReg(MO.getReg());
184-
}
185183
}
186184
}
187185
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; RUN: not llc -mcpu=gfx1100 -mtriple=amdgcn-amd-amdhsa -stress-regalloc=4 %s 2>&1 | FileCheck %s
2+
3+
; CHECK: ran out of registers during register allocation in function 'f'
4+
5+
define <16 x half> @f(i1 %LGV2, <16 x half> %0) {
6+
BB:
7+
br i1 %LGV2, label %SW_C3, label %SW_C
8+
9+
SW_C: ; preds = %BB
10+
%B1 = fmul <16 x half> %0, zeroinitializer
11+
ret <16 x half> %B1
12+
13+
SW_C3: ; preds = %BB
14+
ret <16 x half> <half 0xH0000, half poison, half poison, half poison, half poison, half poison, half poison, half poison, half poison, half poison, half poison, half poison, half poison, half poison, half poison, half poison>
15+
}

0 commit comments

Comments
 (0)