Skip to content

Commit e021e15

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 e021e15

File tree

2 files changed

+63
-3
lines changed

2 files changed

+63
-3
lines changed

llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,10 @@ bool MipsDelaySlotFiller::searchRange(MachineBasicBlock &MBB, IterTy Begin,
694694
IterTy CurrI = I;
695695
++I;
696696
LLVM_DEBUG(dbgs() << DEBUG_TYPE ": checking instruction: "; CurrI->dump());
697-
// skip debug value
698-
if (CurrI->isDebugInstr()) {
697+
// Skip debug value.
698+
// Instruction TargetOpcode::JUMP_TABLE_DEBUG_INFO is only used to note
699+
// jump table debug info, we did not need to emit it.
700+
if (CurrI->isDebugInstr() || CurrI->isJumpTableDebugInfo()) {
699701
LLVM_DEBUG(dbgs() << DEBUG_TYPE ": ignoring debug instruction: ";
700702
CurrI->dump());
701703
continue;

llvm/test/CodeGen/Mips/jumptable_labels.ll

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
; RUN: llc -mtriple=mips-elf < %s | FileCheck %s -check-prefix=O32
22
; RUN: llc -mtriple=mips64-elf -target-abi=n32 < %s | FileCheck %s -check-prefix=N32
33
; RUN: llc -mtriple=mips64-elf < %s | FileCheck %s -check-prefix=N64
4+
; RUN: llc -mtriple=mipsel-windows-gnu < %s | FileCheck %s -check-prefix=MIPSEL
45

56
; We only use the '$' prefix on O32. The others use the ELF convention.
67
; O32: $JTI0_0
@@ -12,6 +13,63 @@
1213
; N32: .LBB0_2:
1314
; N64: .LBB0_2:
1415

16+
; MIPSEL-LABEL: _Z3foo:
17+
; MIPSEL: # %bb.0: # %entry
18+
; MIPSEL-NEXT: addiu $sp, $sp, -16
19+
; MIPSEL-NEXT: sltiu $1, $4, 7
20+
; MIPSEL-NEXT: beqz $1, .LBB0_6
21+
; MIPSEL-NEXT: sw $4, 4($sp)
22+
; MIPSEL-NEXT: # %bb.1: # %entry
23+
; MIPSEL-NEXT: sll $1, $4, 2
24+
; MIPSEL-NEXT: lui $2, %hi($JTI0_0)
25+
; MIPSEL-NEXT: addu $1, $1, $2
26+
; MIPSEL-NEXT: lw $1, %lo($JTI0_0)($1)
27+
; MIPSEL-NEXT: jr $1
28+
; MIPSEL-NEXT: nop
29+
; MIPSEL-NEXT: .LBB0_2: # %sw.bb
30+
; MIPSEL-NEXT: lui $1, %hi($.str)
31+
; MIPSEL-NEXT: addiu $1, $1, %lo($.str)
32+
; MIPSEL-NEXT: j .LBB0_10
33+
; MIPSEL-NEXT: sw $1, 8($sp)
34+
; MIPSEL-NEXT: .LBB0_3: # %sw.bb4
35+
; MIPSEL-NEXT: lui $1, %hi($.str.4)
36+
; MIPSEL-NEXT: addiu $1, $1, %lo($.str.4)
37+
; MIPSEL-NEXT: j .LBB0_10
38+
; MIPSEL-NEXT: sw $1, 8($sp)
39+
; MIPSEL-NEXT: .LBB0_4: # %sw.bb2
40+
; MIPSEL-NEXT: lui $1, %hi($.str.2)
41+
; MIPSEL-NEXT: addiu $1, $1, %lo($.str.2)
42+
; MIPSEL-NEXT: j .LBB0_10
43+
; MIPSEL-NEXT: sw $1, 8($sp)
44+
; MIPSEL-NEXT: .LBB0_5: # %sw.bb3
45+
; MIPSEL-NEXT: lui $1, %hi($.str.3)
46+
; MIPSEL-NEXT: addiu $1, $1, %lo($.str.3)
47+
; MIPSEL-NEXT: j .LBB0_10
48+
; MIPSEL-NEXT: sw $1, 8($sp)
49+
; MIPSEL-NEXT: .LBB0_6: # %sw.epilog
50+
; MIPSEL-NEXT: lui $1, %hi($.str.7)
51+
; MIPSEL-NEXT: addiu $1, $1, %lo($.str.7)
52+
; MIPSEL-NEXT: j .LBB0_10
53+
; MIPSEL-NEXT: sw $1, 8($sp)
54+
; MIPSEL-NEXT: .LBB0_7: # %sw.bb1
55+
; MIPSEL-NEXT: lui $1, %hi($.str.1)
56+
; MIPSEL-NEXT: addiu $1, $1, %lo($.str.1)
57+
; MIPSEL-NEXT: j .LBB0_10
58+
; MIPSEL-NEXT: sw $1, 8($sp)
59+
; MIPSEL-NEXT: .LBB0_8: # %sw.bb5
60+
; MIPSEL-NEXT: lui $1, %hi($.str.5)
61+
; MIPSEL-NEXT: addiu $1, $1, %lo($.str.5)
62+
; MIPSEL-NEXT: j .LBB0_10
63+
; MIPSEL-NEXT: sw $1, 8($sp)
64+
; MIPSEL-NEXT: .LBB0_9: # %sw.bb6
65+
; MIPSEL-NEXT: lui $1, %hi($.str.6)
66+
; MIPSEL-NEXT: addiu $1, $1, %lo($.str.6)
67+
; MIPSEL-NEXT: sw $1, 8($sp)
68+
; MIPSEL-NEXT: .LBB0_10: # %return
69+
; MIPSEL-NEXT: lw $2, 8($sp)
70+
; MIPSEL-NEXT: jr $ra
71+
; MIPSEL-NEXT: addiu $sp, $sp, 16
72+
1573
@.str = private unnamed_addr constant [2 x i8] c"A\00", align 1
1674
@.str.1 = private unnamed_addr constant [2 x i8] c"B\00", align 1
1775
@.str.2 = private unnamed_addr constant [2 x i8] c"C\00", align 1
@@ -21,7 +79,7 @@
2179
@.str.6 = private unnamed_addr constant [2 x i8] c"G\00", align 1
2280
@.str.7 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
2381

24-
define ptr @_Z3fooi(i32 signext %Letter) {
82+
define ptr @_Z3foo(i32 signext %Letter) {
2583
entry:
2684
%retval = alloca ptr, align 8
2785
%Letter.addr = alloca i32, align 4

0 commit comments

Comments
 (0)