xref: /llvm-project/llvm/test/MC/AsmParser/seh-directive-errors.s (revision c9017bc79397e12734b58165273ae70f328d0002)
1# RUN: not llvm-mc -triple x86_64-windows-msvc %s -filetype=obj -o /dev/null 2>&1 | FileCheck %s --implicit-check-not=error:
2# RUN: not llvm-mc -triple x86_64-windows-msvc %s -o /dev/null 2>&1 | FileCheck %s --implicit-check-not=error:
3	.text
4
5# CHECK: error: .seh_ directive must appear within an active frame
6	.seh_handlerdata
7
8	.seh_pushreg %rsi
9	# CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: .seh_ directive must appear within an active frame
10
11	.seh_stackalloc 32
12	# CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: .seh_ directive must appear within an active frame
13
14	.def	 f;
15	.scl	2;
16	.type	32;
17	.endef
18	.globl	f                       # -- Begin function f
19	.p2align	4, 0x90
20f:                                      # @f
21.seh_proc f
22	pushq	%rsi
23	.seh_pushreg %rsi
24	pushq	%rdi
25	.seh_pushreg %rdi
26	pushq	%rbx
27	.seh_pushreg %rbx
28	subq	$32, %rsp
29	.seh_stackalloc 0
30	# CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: stack allocation size must be non-zero
31	.seh_stackalloc 7
32	# CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: stack allocation size is not a multiple of 8
33	.seh_stackalloc 32
34	.seh_endprologue
35	nop
36	addq	$32, %rsp
37	popq	%rbx
38	popq	%rdi
39	popq	%rsi
40	retq
41	.seh_handlerdata
42	.text
43	.seh_endproc
44
45
46	.seh_pushreg %rsi
47	# CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: .seh_ directive must appear within an active frame
48
49g:
50	.seh_proc g
51	pushq %rbp
52	.seh_pushreg %rbx
53	pushq %rsi
54	.seh_pushreg %rsi
55	.seh_endprologue
56	.seh_setframe 3 255
57	# CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: you must specify a stack pointer offset
58	.seh_setframe 3, 255
59	# CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: offset is not a multiple of 16
60	.seh_setframe 3, 256
61	# CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: frame offset must be less than or equal to 240
62	.seh_setframe 3, 128
63	.seh_setframe 3, 128
64	# CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: frame register and offset can be set at most once
65	nop
66	popq %rsi
67	popq %rbp
68	retq
69	.seh_endproc
70
71        .globl  h                       # -- Begin function h
72        .p2align        4, 0x90
73h:                                      # @h
74.seh_proc h
75# %bb.0:                                # %entry
76        subq    $72, %rsp
77        .seh_stackalloc 72
78        movaps  %xmm7, 48(%rsp)         # 16-byte Spill
79        .seh_savexmm 7 44
80	# CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: you must specify an offset on the stack
81        .seh_savexmm %xmm7, 44
82	# CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: offset is not a multiple of 16
83        .seh_savexmm %xmm7, 48
84        movaps  %xmm6, 32(%rsp)         # 16-byte Spill
85        .seh_savexmm %xmm6, 32
86        .seh_endprologue
87        movapd  %xmm0, %xmm6
88        callq   getdbl
89        movapd  %xmm0, %xmm7
90        addsd   %xmm6, %xmm7
91        callq   getdbl
92        addsd   %xmm7, %xmm0
93        movaps  32(%rsp), %xmm6         # 16-byte Reload
94        movaps  48(%rsp), %xmm7         # 16-byte Reload
95        addq    $72, %rsp
96        retq
97        .seh_handlerdata
98        .text
99        .seh_endproc
100                                        # -- End function
101
102	.globl i
103	.def i; .scl 2; .type 32; .endef
104        .p2align        4, 0x90
105i:
106	.seh_proc i
107	pushq %rbp
108	.seh_pushreg 32
109# CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: incorrect register number for use with this directive
110	pushq %rbx
111	.seh_pushreg %xmm0
112# CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: register is not supported for use with this directive
113	leaq 16(%rsp), %rbp
114	.seh_setframe %xmm0, 16
115# CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: register is not supported for use with this directive
116	.seh_endprologue
117	ret
118	.seh_endproc
119