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 3 4; DARWIN: ShadowCallStack attribute not supported on Darwin. 5 6define void @f1() shadowcallstack { 7 ; CHECK: f1: 8 ; CHECK-NOT: x18 9 ; CHECK: ret 10 ret void 11} 12 13declare void @foo() 14 15define void @f2() shadowcallstack { 16 ; CHECK: f2: 17 ; CHECK-NOT: x18 18 ; CHECK: b foo 19 tail call void @foo() 20 ret void 21} 22 23declare i32 @bar() 24 25define i32 @f3() shadowcallstack { 26 ; CHECK: f3: 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]! 34 ; CHECK: ret 35 ret i32 %res 36} 37 38define i32 @f4() shadowcallstack { 39 ; CHECK: f4: 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]! 49 ; CHECK: ret 50 ret i32 %res1234 51} 52 53define i32 @f5() shadowcallstack nounwind { 54 ; CHECK: f5: 55 ; CHECK-NOT: .cfi_escape 56 %res = call i32 @bar() 57 %res1 = add i32 %res, 1 58 ret i32 %res 59} 60 61