1 // REQUIRES: aarch64-registered-target
2 // RUN: %clang_cc1 -triple aarch64 -emit-llvm -target-cpu generic -target-feature +v8.5a %s -o - \
3 // RUN: | FileCheck %s --check-prefix=CHECK
4 // RUN: %clang_cc1 -triple aarch64 -emit-llvm -target-cpu generic -target-feature +v8.5a -mbranch-target-enforce %s -o - \
5 // RUN: | FileCheck %s --check-prefix=CHECK
6 // RUN: %clang_cc1 -triple aarch64 -emit-llvm -target-cpu generic -target-feature +v8.5a -mguarded-control-stack %s -o - \
7 // RUN: | FileCheck %s --check-prefix=CHECK
8 // RUN: %clang_cc1 -triple aarch64 -emit-llvm -target-cpu generic -target-feature +v8.5a -msign-return-address=non-leaf -msign-return-address-key=a_key %s -o - \
9 // RUN: | FileCheck %s --check-prefix=CHECK
10 // RUN: %clang_cc1 -triple aarch64 -emit-llvm -target-cpu generic -target-feature +v8.5a -msign-return-address=all -msign-return-address-key=b_key %s -o - \
11 // RUN: | FileCheck %s --check-prefix=CHECK
12 // RUN: %clang_cc1 -triple aarch64 -emit-llvm -target-cpu generic -target-feature +v8.5a -mbranch-protection-pauth-lr -msign-return-address=all -msign-return-address-key=a_key %s -o - \
13 // RUN: | FileCheck %s --check-prefix=CHECK
14 // RUN: %clang_cc1 -triple aarch64 -emit-llvm -target-cpu generic -target-feature +v8.5a -mguarded-control-stack -mbranch-target-enforce -mbranch-protection-pauth-lr -msign-return-address=all -msign-return-address-key=a_key %s -o - \
15 // RUN: | FileCheck %s --check-prefix=CHECK
17 __attribute__ ((target("branch-protection=none")))
19 // CHECK: define{{.*}} void @none() #[[#NONE:]]
21 __attribute__ ((target("branch-protection=standard")))
23 // CHECK: define{{.*}} void @std() #[[#STD:]]
25 __attribute__ ((target("branch-protection=bti")))
27 // CHECK: define{{.*}} void @btionly() #[[#BTI:]]
29 __attribute__ ((target("branch-protection=pac-ret")))
31 // CHECK: define{{.*}} void @paconly() #[[#PAC:]]
33 __attribute__ ((target("branch-protection=pac-ret+bti")))
35 // CHECK: define{{.*}} void @pacbti0() #[[#PACBTI:]]
37 __attribute__ ((target("branch-protection=bti+pac-ret")))
39 // CHECK: define{{.*}} void @pacbti1() #[[#PACBTI]]
41 __attribute__ ((target("branch-protection=pac-ret+leaf")))
43 // CHECK: define{{.*}} void @leaf() #[[#PACLEAF:]]
45 __attribute__ ((target("branch-protection=pac-ret+b-key")))
47 // CHECK: define{{.*}} void @bkey() #[[#PACBKEY:]]
49 __attribute__ ((target("branch-protection=pac-ret+b-key+leaf")))
51 // CHECK: define{{.*}} void @bkeyleaf0() #[[#PACBKEYLEAF:]]
53 __attribute__ ((target("branch-protection=pac-ret+leaf+b-key")))
55 // CHECK: define{{.*}} void @bkeyleaf1() #[[#PACBKEYLEAF]]
57 __attribute__ ((target("branch-protection=pac-ret+leaf+bti")))
59 // CHECK: define{{.*}} void @btileaf() #[[#BTIPACLEAF:]]
62 __attribute__ ((target("branch-protection=pac-ret+pc")))
64 // CHECK: define{{.*}} void @pauthlr() #[[#PAUTHLR:]]
66 __attribute__ ((target("branch-protection=pac-ret+pc+b-key")))
67 void pauthlr_bkey() {}
68 // CHECK: define{{.*}} void @pauthlr_bkey() #[[#PAUTHLR_BKEY:]]
70 __attribute__ ((target("branch-protection=pac-ret+pc+leaf")))
71 void pauthlr_leaf() {}
72 // CHECK: define{{.*}} void @pauthlr_leaf() #[[#PAUTHLR_LEAF:]]
74 __attribute__ ((target("branch-protection=pac-ret+pc+bti")))
76 // CHECK: define{{.*}} void @pauthlr_bti() #[[#PAUTHLR_BTI:]]
78 __attribute__ ((target("branch-protection=gcs")))
80 // CHECK: define{{.*}} void @gcs() #[[#GCS:]]
82 // CHECK-DAG: attributes #[[#NONE]] = { {{.*}}
84 // CHECK-DAG: attributes #[[#STD]] = { {{.*}} "branch-target-enforcement" "guarded-control-stack" {{.*}} "sign-return-address"="non-leaf" "sign-return-address-key"="a_key"
86 // CHECK-DAG: attributes #[[#BTI]] = { {{.*}} "branch-target-enforcement"
88 // CHECK-DAG: attributes #[[#PAC]] = { {{.*}} "sign-return-address"="non-leaf" "sign-return-address-key"="a_key"
90 // CHECK-DAG: attributes #[[#PACLEAF]] = { {{.*}} "sign-return-address"="all" "sign-return-address-key"="a_key"
92 // CHECK-DAG: attributes #[[#PACBKEY]] = { {{.*}} "sign-return-address"="non-leaf" "sign-return-address-key"="b_key"
94 // CHECK-DAG: attributes #[[#PACBKEYLEAF]] = { {{.*}} "sign-return-address"="all" "sign-return-address-key"="b_key"
96 // CHECK-DAG: attributes #[[#BTIPACLEAF]] = { {{.*}} "branch-target-enforcement" {{.*}}"sign-return-address"="all" "sign-return-address-key"="a_key"
98 // CHECK-DAG: attributes #[[#PAUTHLR]] = { {{.*}} "branch-protection-pauth-lr" {{.*}}"sign-return-address"="non-leaf" "sign-return-address-key"="a_key"
100 // CHECK-DAG: attributes #[[#PAUTHLR_BKEY]] = { {{.*}} "branch-protection-pauth-lr" {{.*}}"sign-return-address"="non-leaf" "sign-return-address-key"="b_key"
102 // CHECK-DAG: attributes #[[#PAUTHLR_LEAF]] = { {{.*}} "branch-protection-pauth-lr" {{.*}}"sign-return-address"="all" "sign-return-address-key"="a_key"
104 // CHECK-DAG: attributes #[[#PAUTHLR_BTI]] = { {{.*}} "branch-protection-pauth-lr" {{.*}}"branch-target-enforcement" {{.*}}"sign-return-address"="non-leaf" "sign-return-address-key"="a_key"
106 // CHECK-DAG: attributes #[[#GCS]] = { {{.*}} "guarded-control-stack"