1 ; RUN: llc -verify-machineinstrs -o - %s -mtriple=aarch64-linux-gnu -mattr=+reserve-x18 | FileCheck %s
2 ; RUN: not --crash llc -verify-machineinstrs -o - %s -mtriple=arm64-apple-darwin 2>&1 | FileCheck %s --check-prefix=DARWIN
4 ; DARWIN: ShadowCallStack attribute not supported on Darwin.
6 define void @f1() shadowcallstack {
15 define void @f2() shadowcallstack {
25 define i32 @f3() shadowcallstack {
27 ; CHECK: str x30, [x18], #8
28 ; CHECK: .cfi_escape 0x16, 0x12, 0x02, 0x82, 0x78
29 ; CHECK: str x30, [sp, #-16]!
30 %res = call i32 @bar()
31 %res1 = add i32 %res, 1
32 ; CHECK: ldr x30, [sp], #16
33 ; CHECK: ldr x30, [x18, #-8]!
38 define i32 @f4() shadowcallstack {
40 %res1 = call i32 @bar()
41 %res2 = call i32 @bar()
42 %res3 = call i32 @bar()
43 %res4 = call i32 @bar()
44 %res12 = add i32 %res1, %res2
45 %res34 = add i32 %res3, %res4
46 %res1234 = add i32 %res12, %res34
47 ; CHECK: ldp x30,{{.*}}, [sp
48 ; CHECK: ldr x30, [x18, #-8]!
53 define i32 @f5() shadowcallstack nounwind {
55 ; CHECK-NOT: .cfi_escape
56 %res = call i32 @bar()
57 %res1 = add i32 %res, 1
61 define i32 @f6() shadowcallstack nounwind uwtable {
63 ; CHECK: .cfi_escape 0x16, 0x12, 0x02, 0x82, 0x78
64 %res = call i32 @bar()
65 %res1 = add i32 %res, 1