Debian Codegraph @

clang/test/CodeGen/AArch64/branch-protection-attr.c

raw
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
16
17 __attribute__ ((target("branch-protection=none")))
18 void none() {}
19 // CHECK: define{{.*}} void @none() #[[#NONE:]]
20
21 __attribute__ ((target("branch-protection=standard")))
22 void std() {}
23 // CHECK: define{{.*}} void @std() #[[#STD:]]
24
25 __attribute__ ((target("branch-protection=bti")))
26 void btionly() {}
27 // CHECK: define{{.*}} void @btionly() #[[#BTI:]]
28
29 __attribute__ ((target("branch-protection=pac-ret")))
30 void paconly() {}
31 // CHECK: define{{.*}} void @paconly() #[[#PAC:]]
32
33 __attribute__ ((target("branch-protection=pac-ret+bti")))
34 void pacbti0() {}
35 // CHECK: define{{.*}} void @pacbti0() #[[#PACBTI:]]
36
37 __attribute__ ((target("branch-protection=bti+pac-ret")))
38 void pacbti1() {}
39 // CHECK: define{{.*}} void @pacbti1() #[[#PACBTI]]
40
41 __attribute__ ((target("branch-protection=pac-ret+leaf")))
42 void leaf() {}
43 // CHECK: define{{.*}} void @leaf() #[[#PACLEAF:]]
44
45 __attribute__ ((target("branch-protection=pac-ret+b-key")))
46 void bkey() {}
47 // CHECK: define{{.*}} void @bkey() #[[#PACBKEY:]]
48
49 __attribute__ ((target("branch-protection=pac-ret+b-key+leaf")))
50 void bkeyleaf0() {}
51 // CHECK: define{{.*}} void @bkeyleaf0() #[[#PACBKEYLEAF:]]
52
53 __attribute__ ((target("branch-protection=pac-ret+leaf+b-key")))
54 void bkeyleaf1() {}
55 // CHECK: define{{.*}} void @bkeyleaf1() #[[#PACBKEYLEAF]]
56
57 __attribute__ ((target("branch-protection=pac-ret+leaf+bti")))
58 void btileaf() {}
59 // CHECK: define{{.*}} void @btileaf() #[[#BTIPACLEAF:]]
60
61
62 __attribute__ ((target("branch-protection=pac-ret+pc")))
63 void pauthlr() {}
64 // CHECK: define{{.*}} void @pauthlr() #[[#PAUTHLR:]]
65
66 __attribute__ ((target("branch-protection=pac-ret+pc+b-key")))
67 void pauthlr_bkey() {}
68 // CHECK: define{{.*}} void @pauthlr_bkey() #[[#PAUTHLR_BKEY:]]
69
70 __attribute__ ((target("branch-protection=pac-ret+pc+leaf")))
71 void pauthlr_leaf() {}
72 // CHECK: define{{.*}} void @pauthlr_leaf() #[[#PAUTHLR_LEAF:]]
73
74 __attribute__ ((target("branch-protection=pac-ret+pc+bti")))
75 void pauthlr_bti() {}
76 // CHECK: define{{.*}} void @pauthlr_bti() #[[#PAUTHLR_BTI:]]
77
78 __attribute__ ((target("branch-protection=gcs")))
79 void gcs() {}
80 // CHECK: define{{.*}} void @gcs() #[[#GCS:]]
81
82 // CHECK-DAG: attributes #[[#NONE]] = { {{.*}}
83
84 // CHECK-DAG: attributes #[[#STD]] = { {{.*}} "branch-target-enforcement" "guarded-control-stack" {{.*}} "sign-return-address"="non-leaf" "sign-return-address-key"="a_key"
85
86 // CHECK-DAG: attributes #[[#BTI]] = { {{.*}} "branch-target-enforcement"
87
88 // CHECK-DAG: attributes #[[#PAC]] = { {{.*}} "sign-return-address"="non-leaf" "sign-return-address-key"="a_key"
89
90 // CHECK-DAG: attributes #[[#PACLEAF]] = { {{.*}} "sign-return-address"="all" "sign-return-address-key"="a_key"
91
92 // CHECK-DAG: attributes #[[#PACBKEY]] = { {{.*}} "sign-return-address"="non-leaf" "sign-return-address-key"="b_key"
93
94 // CHECK-DAG: attributes #[[#PACBKEYLEAF]] = { {{.*}} "sign-return-address"="all" "sign-return-address-key"="b_key"
95
96 // CHECK-DAG: attributes #[[#BTIPACLEAF]] = { {{.*}} "branch-target-enforcement" {{.*}}"sign-return-address"="all" "sign-return-address-key"="a_key"
97
98 // CHECK-DAG: attributes #[[#PAUTHLR]] = { {{.*}} "branch-protection-pauth-lr" {{.*}}"sign-return-address"="non-leaf" "sign-return-address-key"="a_key"
99
100 // CHECK-DAG: attributes #[[#PAUTHLR_BKEY]] = { {{.*}} "branch-protection-pauth-lr" {{.*}}"sign-return-address"="non-leaf" "sign-return-address-key"="b_key"
101
102 // CHECK-DAG: attributes #[[#PAUTHLR_LEAF]] = { {{.*}} "branch-protection-pauth-lr" {{.*}}"sign-return-address"="all" "sign-return-address-key"="a_key"
103
104 // CHECK-DAG: attributes #[[#PAUTHLR_BTI]] = { {{.*}} "branch-protection-pauth-lr" {{.*}}"branch-target-enforcement" {{.*}}"sign-return-address"="non-leaf" "sign-return-address-key"="a_key"
105
106 // CHECK-DAG: attributes #[[#GCS]] = { {{.*}} "guarded-control-stack"