1 // REQUIRES: arm-registered-target
2 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -S -emit-llvm -o - -mbranch-protection=none %s | FileCheck %s --check-prefix=CHECK --check-prefix=NONE
3 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -S -emit-llvm -o - -mbranch-protection=pac-ret %s | FileCheck %s --check-prefix=CHECK --check-prefix=PART
4 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -S -emit-llvm -o - -mbranch-protection=pac-ret+leaf %s | FileCheck %s --check-prefix=CHECK --check-prefix=ALL
5 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -S -emit-llvm -o - -mbranch-protection=pac-ret+b-key %s | FileCheck %s --check-prefix=CHECK --check-prefix=PART
6 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -S -emit-llvm -o - -mbranch-protection=bti %s | FileCheck %s --check-prefix=CHECK --check-prefix=BTE
8 // Check there are branch protection function attributes
10 // CHECK-LABEL: @foo() #[[#ATTR:]]
12 // NONE-NOT: attributes #[[#ATTR]] = { {{.*}} "sign-return-address"
13 // NONE-NOT: attributes #[[#ATTR]] = { {{.*}} "sign-return-address-key"
14 // NONE-NOT: attributes #[[#ATTR]] = { {{.*}} "branch-target-enforcement"
16 // ALL: attributes #[[#ATTR]] = { {{.*}} "sign-return-address"="all"
17 // PART: attributes #[[#ATTR]] = { {{.*}} "sign-return-address"="non-leaf"
18 // BTE: attributes #[[#ATTR]] = { {{.*}} "branch-target-enforcement"
21 // Check module attributes
23 // NONE-NOT: !"branch-target-enforcement"
24 // PART-NOT: !"branch-target-enforcement"
25 // ALL-NOT: !"branch-target-enforcement"
26 // BTE: !{i32 8, !"branch-target-enforcement", i32 1}
28 // NONE-NOT: !"sign-return-address"
29 // PART: !{i32 8, !"sign-return-address", i32 1}
30 // ALL: !{i32 8, !"sign-return-address", i32 1}
31 // BTE-NOT: !"sign-return-address"
33 // NONE-NOT: !"sign-return-address-all", i32 0}
34 // PART-NOT: !"sign-return-address-all", i32 0}
35 // ALL: !{i32 8, !"sign-return-address-all", i32 1}
36 // BTE-NOT: !"sign-return-address-all", i32 0}