Skip to content

Commit 4f7d894

Browse files
authored
[Hexagon] Add a case to BitTracker for new register class (llvm#128580)
Code in the HexagonBitTracker checks for a specific register class when processing sub-registers. A crash occurred due to a register class that was not handled. The register class is DoubleRegs_with_isub_hi_in_IntRegsLow8RegClassID, which is a class formed by creating a register pair when one of the sub registers is a Low8 integer register. Fixes llvm#128078 Patch by: Brendon Cahoon
1 parent 352c48f commit 4f7d894

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

llvm/lib/Target/Hexagon/HexagonBitTracker.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ BT::BitMask HexagonEvaluator::mask(Register Reg, unsigned Sub) const {
9494
bool IsSubLo = (Sub == HRI.getHexagonSubRegIndex(RC, Hexagon::ps_sub_lo));
9595
switch (ID) {
9696
case Hexagon::DoubleRegsRegClassID:
97+
case Hexagon::DoubleRegs_with_isub_hi_in_IntRegsLow8RegClassID:
9798
case Hexagon::HvxWRRegClassID:
9899
case Hexagon::HvxVQRRegClassID:
99100
return IsSubLo ? BT::BitMask(0, RW-1)
@@ -139,6 +140,7 @@ const TargetRegisterClass &HexagonEvaluator::composeWithSubRegIndex(
139140

140141
switch (RC.getID()) {
141142
case Hexagon::DoubleRegsRegClassID:
143+
case Hexagon::DoubleRegs_with_isub_hi_in_IntRegsLow8RegClassID:
142144
return Hexagon::IntRegsRegClass;
143145
case Hexagon::HvxWRRegClassID:
144146
return Hexagon::HvxVRRegClass;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
; RUN: llc -mtriple=hexagon -mcpu=hexagonv75 -mattr=+hvxv75,+hvx-length64b,-small-data < %s | FileCheck %s
2+
3+
; Test that the compiler generates code, and doesn't crash, when the compiler
4+
; creates a DoubleReg value with an IntLow8Reg value. The BitTracker pass
5+
; needs to handle this register class.
6+
7+
; CHECK: [[REG:r[0-9]+:[0-9]+]] = combine(#33,#32)
8+
; CHECK: memd({{.*}}) = [[REG]]
9+
10+
@out = external dso_local global [100 x i32], align 512
11+
@in55 = external dso_local global [55 x i32], align 256
12+
@.str.3 = external dso_local unnamed_addr constant [29 x i8], align 1
13+
14+
define dso_local void @main(i1 %cond) local_unnamed_addr #0 {
15+
entry:
16+
br label %for.body.i198
17+
18+
for.body.i198:
19+
br i1 %cond, label %for.body34.preheader, label %for.body.i198
20+
21+
for.body34.preheader:
22+
%wide.load269.5 = load <16 x i32>, <16 x i32>* bitcast (i32* getelementptr inbounds ([100 x i32], [100 x i32]* @out, i32 0, i32 80) to <16 x i32>*), align 64
23+
%0 = add nsw <16 x i32> %wide.load269.5, zeroinitializer
24+
%rdx.shuf270 = shufflevector <16 x i32> %0, <16 x i32> undef, <16 x i32> <i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
25+
%bin.rdx271 = add <16 x i32> %0, %rdx.shuf270
26+
%bin.rdx273 = add <16 x i32> %bin.rdx271, zeroinitializer
27+
%bin.rdx275 = add <16 x i32> %bin.rdx273, zeroinitializer
28+
%bin.rdx277 = add <16 x i32> %bin.rdx275, zeroinitializer
29+
%1 = extractelement <16 x i32> %bin.rdx277, i32 0
30+
%add45 = add nsw i32 0, %1
31+
%add45.1 = add nsw i32 0, %add45
32+
%add45.2 = add nsw i32 0, %add45.1
33+
%add45.3 = add nsw i32 0, %add45.2
34+
call void (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i32 0, i32 0), i32 %add45.3) #2
35+
store i32 32, i32* getelementptr inbounds ([55 x i32], [55 x i32]* @in55, i32 0, i32 32), align 128
36+
store i32 33, i32* getelementptr inbounds ([55 x i32], [55 x i32]* @in55, i32 0, i32 33), align 4
37+
ret void
38+
}
39+
40+
declare dso_local void @printf(i8*, ...) local_unnamed_addr #1

0 commit comments

Comments
 (0)