Skip to content

Commit 57618e7

Browse files
committed
[Mips] When emit instruction, ignore JUMP_TABLE_DEBUG_INFO
When -triple is windows, SelectionDAGLegalize process Legalizing br_jt, would generate ISD::JUMP_TABLE_DEBUG_INFO. Then Mips process emitInstruction, would think JUMP_TABLE_DEBUG_INFO is a pseudo instruction and generate an error `Pseudo opcode found in emitInstruction()`. This instruction `TargetOpcode::JUMP_TABLE_DEBUG_INFO` is only used to note jump table debug info, so we can ignore it when Mips emit instruction. Fix #134916.
1 parent 0baacd1 commit 57618e7

File tree

2 files changed

+130
-0
lines changed

2 files changed

+130
-0
lines changed

llvm/lib/Target/Mips/MipsAsmPrinter.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,17 @@ void MipsAsmPrinter::emitInstruction(const MachineInstr *MI) {
269269
continue;
270270
}
271271

272+
// This instruction is only used to note jump table debug info, we
273+
// did not need to emit it.
274+
if (I->getOpcode() == TargetOpcode::JUMP_TABLE_DEBUG_INFO) {
275+
LLVM_DEBUG(
276+
dbgs()
277+
<< DEBUG_TYPE
278+
<< ": JUMP_TABLE_DEBUG_INFO is an instruction which was used to "
279+
"note jump table debug info, did not emit it."
280+
<< "\n");
281+
continue;
282+
}
272283
// The inMips16Mode() test is not permanent.
273284
// Some instructions are marked as pseudo right now which
274285
// would make the test fail for the wrong reason but
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
; RUN: llc -mtriple=mipsel-windows-gnu < %s | FileCheck %s -check-prefix=MIPSEL
2+
3+
@.str = private unnamed_addr constant [2 x i8] c"A\00", align 1
4+
@.str.1 = private unnamed_addr constant [2 x i8] c"B\00", align 1
5+
@.str.2 = private unnamed_addr constant [2 x i8] c"C\00", align 1
6+
@.str.3 = private unnamed_addr constant [2 x i8] c"D\00", align 1
7+
@.str.4 = private unnamed_addr constant [2 x i8] c"E\00", align 1
8+
@.str.5 = private unnamed_addr constant [2 x i8] c"F\00", align 1
9+
@.str.6 = private unnamed_addr constant [2 x i8] c"G\00", align 1
10+
@.str.7 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
11+
12+
define ptr @jumptable(i32 signext %Letter) nounwind {
13+
; MIPSEL-LABEL: jumptable:
14+
; MIPSEL: # %bb.0: # %entry
15+
; MIPSEL-NEXT: addiu $sp, $sp, -16
16+
; MIPSEL-NEXT: sltiu $1, $4, 7
17+
; MIPSEL-NEXT: beqz $1, LBB0_6
18+
; MIPSEL-NEXT: sw $4, 4($sp)
19+
; MIPSEL-NEXT: # %bb.1: # %entry
20+
; MIPSEL-NEXT: sll $1, $4, 2
21+
; MIPSEL-NEXT: lui $2, %hi($JTI0_0)
22+
; MIPSEL-NEXT: addu $1, $1, $2
23+
; MIPSEL-NEXT: lw $1, %lo($JTI0_0)($1)
24+
; MIPSEL-NEXT: jr $1
25+
; MIPSEL-NEXT: LBB0_2: # %sw.bb
26+
; MIPSEL-NEXT: lui $1, %hi($.str)
27+
; MIPSEL-NEXT: addiu $1, $1, %lo($.str)
28+
; MIPSEL-NEXT: j LBB0_10
29+
; MIPSEL-NEXT: sw $1, 8($sp)
30+
; MIPSEL-NEXT: LBB0_3: # %sw.bb4
31+
; MIPSEL-NEXT: lui $1, %hi($.str.4)
32+
; MIPSEL-NEXT: addiu $1, $1, %lo($.str.4)
33+
; MIPSEL-NEXT: j LBB0_10
34+
; MIPSEL-NEXT: sw $1, 8($sp)
35+
; MIPSEL-NEXT: LBB0_4: # %sw.bb2
36+
; MIPSEL-NEXT: lui $1, %hi($.str.2)
37+
; MIPSEL-NEXT: addiu $1, $1, %lo($.str.2)
38+
; MIPSEL-NEXT: j LBB0_10
39+
; MIPSEL-NEXT: sw $1, 8($sp)
40+
; MIPSEL-NEXT: LBB0_5: # %sw.bb3
41+
; MIPSEL-NEXT: lui $1, %hi($.str.3)
42+
; MIPSEL-NEXT: addiu $1, $1, %lo($.str.3)
43+
; MIPSEL-NEXT: j LBB0_10
44+
; MIPSEL-NEXT: sw $1, 8($sp)
45+
; MIPSEL-NEXT: LBB0_6: # %sw.epilog
46+
; MIPSEL-NEXT: lui $1, %hi($.str.7)
47+
; MIPSEL-NEXT: addiu $1, $1, %lo($.str.7)
48+
; MIPSEL-NEXT: j LBB0_10
49+
; MIPSEL-NEXT: sw $1, 8($sp)
50+
; MIPSEL-NEXT: LBB0_7: # %sw.bb1
51+
; MIPSEL-NEXT: lui $1, %hi($.str.1)
52+
; MIPSEL-NEXT: addiu $1, $1, %lo($.str.1)
53+
; MIPSEL-NEXT: j LBB0_10
54+
; MIPSEL-NEXT: sw $1, 8($sp)
55+
; MIPSEL-NEXT: LBB0_8: # %sw.bb5
56+
; MIPSEL-NEXT: lui $1, %hi($.str.5)
57+
; MIPSEL-NEXT: addiu $1, $1, %lo($.str.5)
58+
; MIPSEL-NEXT: j LBB0_10
59+
; MIPSEL-NEXT: sw $1, 8($sp)
60+
; MIPSEL-NEXT: LBB0_9: # %sw.bb6
61+
; MIPSEL-NEXT: lui $1, %hi($.str.6)
62+
; MIPSEL-NEXT: addiu $1, $1, %lo($.str.6)
63+
; MIPSEL-NEXT: sw $1, 8($sp)
64+
; MIPSEL-NEXT: LBB0_10: # %return
65+
; MIPSEL-NEXT: lw $2, 8($sp)
66+
; MIPSEL-NEXT: jr $ra
67+
; MIPSEL-NEXT: addiu $sp, $sp, 16
68+
69+
entry:
70+
%retval = alloca ptr, align 8
71+
%Letter.addr = alloca i32, align 4
72+
store i32 %Letter, ptr %Letter.addr, align 4
73+
%0 = load i32, ptr %Letter.addr, align 4
74+
switch i32 %0, label %sw.epilog [
75+
i32 0, label %sw.bb
76+
i32 1, label %sw.bb1
77+
i32 2, label %sw.bb2
78+
i32 3, label %sw.bb3
79+
i32 4, label %sw.bb4
80+
i32 5, label %sw.bb5
81+
i32 6, label %sw.bb6
82+
]
83+
84+
sw.bb:
85+
store ptr @.str, ptr %retval, align 8
86+
br label %return
87+
88+
sw.bb1:
89+
store ptr @.str.1, ptr %retval, align 8
90+
br label %return
91+
92+
sw.bb2:
93+
store ptr @.str.2, ptr %retval, align 8
94+
br label %return
95+
96+
sw.bb3:
97+
store ptr @.str.3, ptr %retval, align 8
98+
br label %return
99+
100+
sw.bb4:
101+
store ptr @.str.4, ptr %retval, align 8
102+
br label %return
103+
104+
sw.bb5:
105+
store ptr @.str.5, ptr %retval, align 8
106+
br label %return
107+
108+
sw.bb6:
109+
store ptr @.str.6, ptr %retval, align 8
110+
br label %return
111+
112+
sw.epilog:
113+
store ptr @.str.7, ptr %retval, align 8
114+
br label %return
115+
116+
return:
117+
%1 = load ptr, ptr %retval, align 8
118+
ret ptr %1
119+
}

0 commit comments

Comments
 (0)