xref: /llvm-project/llvm/test/MC/ARM/seh-checks.s (revision 298e9cac9204b788dd6a18dba669b40acf2aaa3c)
1// This test checks error reporting for mismatched prolog/epilog lengths
2
3// RUN: not llvm-mc -triple thumbv7-pc-win32 -filetype=obj -o /dev/null %s 2>&1 | FileCheck %s
4
5// CHECK-NOT: func1
6// CHECK: error: Incorrect size for func2 epilogue: 6 bytes of instructions in range, but .seh directives corresponding to 4 bytes
7// CHECK: error: Incorrect size for func3 prologue: 4 bytes of instructions in range, but .seh directives corresponding to 2 bytes
8
9        .text
10        .syntax unified
11
12        .seh_proc func1
13func1:
14        // Instruction with indeterminate length
15        b other
16        .seh_endprologue
17        nop
18        .seh_startepilogue
19        // The p2align causes the length of the epilogue to be unknown, so
20        // we can't report errors about the mismatch here.
21        .p2align 1
22        pop {r4-r7-lr}
23        .seh_save_regs {r4-r7,lr}
24        bx lr
25        .seh_nop
26        .seh_endepilogue
27        .seh_endproc
28
29        .seh_proc func2
30func2:
31        .seh_endprologue
32        nop
33        .seh_startepilogue
34        // As we're popping into lr instead of directly into pc, this pop
35        // becomes a wide instruction.
36        pop {r4-r7,lr}
37        // The directive things we're making a narrow instruction, which
38        // is wrong.
39        .seh_save_regs {r4-r7,lr}
40        bx lr
41        .seh_nop
42        .seh_endepilogue
43        .seh_endproc
44
45        .seh_proc func3
46func3:
47        nop.w
48        .seh_nop
49        .seh_endprologue
50        nop
51        .seh_endproc
52