1 // REQUIRES: arm-registered-target
2 // RUN: %clang_cc1 -triple thumbv7m-unknown-unknown-eabi -emit-llvm %s -o - \
3 // RUN: | FileCheck %s --check-prefix=CHECK
4 // RUN: %clang_cc1 -triple thumbv7m-unknown-unknown-eabi -mbranch-target-enforce -emit-llvm %s -o - \
5 // RUN: | FileCheck %s --check-prefix=CHECK
6 // RUN: %clang_cc1 -triple thumbv7m-unknown-unknown-eabi -msign-return-address=all -emit-llvm %s -o - \
7 // RUN: | FileCheck %s --check-prefix=CHECK
8 // RUN: %clang_cc1 -triple thumbv7m-unknown-unknown-eabi -mbranch-target-enforce -msign-return-address=all -emit-llvm %s -o - \
9 // RUN: | FileCheck %s --check-prefix=CHECK
11 __attribute__((target("branch-protection=none"))) void none() {}
12 // CHECK: define{{.*}} void @none() #[[#NONE:]]
14 __attribute__((target("branch-protection=standard"))) void std() {}
15 // CHECK: define{{.*}} void @std() #[[#STD:]]
17 __attribute__((target("branch-protection=bti"))) void btionly() {}
18 // CHECK: define{{.*}} void @btionly() #[[#BTI:]]
20 __attribute__((target("branch-protection=pac-ret"))) void paconly0() {}
21 // CHECK: define{{.*}} void @paconly0() #[[#PAC:]]
23 __attribute__((target("branch-protection=pac-ret+b-key"))) void paconly1() {}
24 // CHECK: define{{.*}} void @paconly1() #[[#PAC]]
26 __attribute__((target("branch-protection=pac-ret+bti"))) void pacbti0() {}
27 // CHECK: define{{.*}} void @pacbti0() #[[#STD]]
29 __attribute__((target("branch-protection=bti+pac-ret"))) void pacbti1() {}
30 // CHECK: define{{.*}} void @pacbti1() #[[#STD]]
32 __attribute__((target("branch-protection=pac-ret+leaf"))) void leaf() {}
33 // CHECK: define{{.*}} void @leaf() #[[#PACLEAF:]]
35 __attribute__((target("branch-protection=pac-ret+leaf+bti"))) void btileaf() {}
36 // CHECK: define{{.*}} void @btileaf() #[[#BTIPACLEAF:]]
38 // CHECK-DAG: attributes #[[#NONE]] = { {{.*}}
40 // CHECK-DAG: attributes #[[#STD]] = { {{.*}} "branch-target-enforcement" {{.*}} "sign-return-address"="non-leaf"
42 // CHECK-DAG: attributes #[[#BTI]] = { {{.*}} "branch-target-enforcement"
44 // CHECK-DAG: attributes #[[#PAC]] = { {{.*}} "sign-return-address"="non-leaf"
46 // CHECK-DAG: attributes #[[#PACLEAF]] = { {{.*}} "sign-return-address"="all"
48 // CHECK-DAG: attributes #[[#BTIPACLEAF]] = { {{.*}} "branch-target-enforcement" {{.*}} "sign-return-address"="all"