xref: /llvm-project/llvm/test/CodeGen/ARM/cmse-errors.ll (revision 20c43d6bd5ba4354e690c582aa7d6ce8c93040a6)
1; RUN: not llc -mtriple=thumbv8m.main-eabi %s -o - 2>&1 | FileCheck %s
2
3%struct.two_ints = type { i32, i32 }
4%struct.__va_list = type { i8* }
5
6define void @test1(%struct.two_ints* noalias nocapture sret(%struct.two_ints) align 4 %agg.result) "cmse_nonsecure_entry" {
7entry:
8  %0 = bitcast %struct.two_ints* %agg.result to i64*
9  store i64 8589934593, i64* %0, align 4
10  ret void
11}
12; CHECK: error: {{.*}}test1{{.*}}: secure entry function would return value through pointer
13
14define void @test2(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) "cmse_nonsecure_entry" {
15entry:
16  ret void
17}
18; CHECK: error: {{.*}}test2{{.*}}:  secure entry function requires arguments on stack
19
20define void @test3(void (i32, i32, i32, i32, i32)* nocapture %p) {
21entry:
22  tail call void %p(i32 1, i32 2, i32 3, i32 4, i32 5) "cmse_nonsecure_call"
23  ret void
24}
25; CHECK: error: {{.*}}test3{{.*}}: call to non-secure function would require passing arguments on stack
26
27
28define void @test4(void (%struct.two_ints*)* nocapture %p) {
29entry:
30  %r = alloca %struct.two_ints, align 4
31  %0 = bitcast %struct.two_ints* %r to i8*
32  call void %p(%struct.two_ints* nonnull sret(%struct.two_ints) align 4 %r) "cmse_nonsecure_call"
33  ret void
34}
35; CHECK: error: {{.*}}test4{{.*}}: call to non-secure function would return value through pointer
36
37declare void @llvm.va_start(i8*) "nounwind"
38
39declare void @llvm.va_end(i8*) "nounwind"
40
41define i32 @test5(i32 %a, ...) "cmse_nonsecure_entry" {
42entry:
43  %vl = alloca %struct.__va_list, align 4
44  %0 = bitcast %struct.__va_list* %vl to i8*
45  call void @llvm.va_start(i8* nonnull %0)
46  %1 = getelementptr inbounds %struct.__va_list, %struct.__va_list* %vl, i32 0, i32 0
47  %argp.cur = load i8*, i8** %1, align 4
48  %argp.next = getelementptr inbounds i8, i8* %argp.cur, i32 4
49  store i8* %argp.next, i8** %1, align 4
50  %2 = bitcast i8* %argp.cur to i32*
51  %3 = load i32, i32* %2, align 4
52  call void @llvm.va_end(i8* nonnull %0)
53  ret i32 %3
54}
55; CHECK: error: {{.*}}test5{{.*}}: secure entry function must not be variadic
56
57define void @test6(void (i32, ...)* nocapture %p) {
58entry:
59  tail call void (i32, ...) %p(i32 1, i32 2, i32 3, i32 4, i32 5) "cmse_nonsecure_call"
60  ret void
61}
62; CHECK: error: {{.*}}test6{{.*}}: call to non-secure function would require passing arguments on stack
63
64define void @neg_test1(void (i32, ...)* nocapture %p)  {
65entry:
66  tail call void (i32, ...) %p(i32 1, i32 2, i32 3, i32 4) "cmse_nonsecure_call"
67  ret void
68}
69
70define void @neg_test2(i32 %a, ...) "cmse_nonsecure_entry" {
71entry:
72  ret void
73}
74; CHECK-NOT: error:
75