MIR Parser: Report an error when a jump table entry is redefined.
[oota-llvm.git] / test / CodeGen / MIR / X86 / jump-table-redefinition-error.mir
1 # RUN: not llc -march=x86-64 -start-after branch-folder -stop-after branch-folder -o /dev/null %s 2>&1 | FileCheck %s
2
3 --- |
4
5   define i32 @test_jumptable(i32 %in) {
6   entry:
7     switch i32 %in, label %def [
8       i32 0, label %lbl1
9       i32 1, label %lbl2
10       i32 2, label %lbl3
11       i32 3, label %lbl4
12     ]
13
14   def:
15     ret i32 0
16
17   lbl1:
18     ret i32 1
19
20   lbl2:
21     ret i32 2
22
23   lbl3:
24     ret i32 4
25
26   lbl4:
27     ret i32 8
28   }
29
30 ...
31 ---
32 name:            test_jumptable
33 jumpTable:
34   kind:          label-difference32
35   entries:
36     - id:        0
37       blocks:    [ '%bb.3.lbl1', '%bb.4.lbl2', '%bb.5.lbl3', '%bb.6.lbl4' ]
38 # CHECK: [[@LINE+1]]:18: redefinition of jump table entry '%jump-table.0'
39     - id:        0
40       blocks:    [ '%bb.3.lbl1', '%bb.4.lbl2', '%bb.5.lbl3', '%bb.6.lbl4' ]
41 body:
42   - id:          0
43     name:        entry
44     successors:  [ '%bb.2.def', '%bb.1.entry' ]
45     instructions:
46       - '%eax = MOV32rr %edi, implicit-def %rax'
47       - 'CMP32ri8 %edi, 3, implicit-def %eflags'
48       - 'JA_1 %bb.2.def, implicit %eflags'
49   - id:          1
50     name:        entry
51     successors:  [ '%bb.3.lbl1', '%bb.4.lbl2', '%bb.5.lbl3', '%bb.6.lbl4' ]
52     instructions:
53       - '%rcx = LEA64r %rip, 1, _, %jump-table.0, _'
54       - '%rax = MOVSX64rm32 %rcx, 4, %rax, 0, _'
55       - '%rax = ADD64rr %rax, %rcx, implicit-def %eflags'
56       - 'JMP64r %rax'
57   - id:          2
58     name:        def
59     instructions:
60       - '%eax = MOV32r0 implicit-def %eflags'
61       - 'RETQ %eax'
62   - id:          3
63     name:        lbl1
64     instructions:
65       - '%eax = MOV32ri 1'
66       - 'RETQ %eax'
67   - id:          4
68     name:        lbl2
69     instructions:
70       - '%eax = MOV32ri 2'
71       - 'RETQ %eax'
72   - id:          5
73     name:        lbl3
74     instructions:
75       - '%eax = MOV32ri 4'
76       - 'RETQ %eax'
77   - id:          6
78     name:        lbl4
79     instructions:
80       - '%eax = MOV32ri 8'
81       - 'RETQ %eax'
82 ...