File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -2030,6 +2030,9 @@ static void getTrivialDefaultFunctionAttributes(
20302030 std::tie (Var, Value) = Attr.split (' =' );
20312031 FuncAttrs.addAttribute (Var, Value);
20322032 }
2033+
2034+ TargetInfo::BranchProtectionInfo BPI (LangOpts);
2035+ TargetCodeGenInfo::setBranchProtectionFnAttributes (BPI, FuncAttrs);
20332036}
20342037
20352038// / Merges `target-features` from \TargetOpts and \F, and sets the result in
Original file line number Diff line number Diff line change 1+ // RUN: %clang_cc1 -triple aarch64 -mbranch-target-enforce -msign-return-address=all -fcxx-exceptions -fexceptions -emit-llvm %s -o - | FileCheck %s
2+
3+ // Check that functions generated by clang have the correct attributes
4+
5+ class Example {
6+ public:
7+ Example ();
8+ int fn ();
9+ };
10+
11+ // Initialization of var1 causes __cxx_global_var_init and __tls_init to be generated
12+ thread_local Example var1;
13+ extern thread_local Example var2;
14+ extern void fn ();
15+
16+ int testfn () noexcept {
17+ // Calling fn in a noexcept function causes __clang_call_terminate to be generated
18+ fn ();
19+ // Use of var1 and var2 causes TLS wrapper functions to be generated
20+ return var1.fn () + var2.fn ();
21+ }
22+
23+ // CHECK: define {{.*}} @__cxx_global_var_init() [[ATTR1:#[0-9]+]]
24+ // CHECK: define {{.*}} @__clang_call_terminate({{.*}}) [[ATTR2:#[0-9]+]]
25+ // CHECK: define {{.*}} @_ZTW4var1() [[ATTR1]]
26+ // CHECK: define {{.*}} @_ZTW4var2() [[ATTR1]]
27+ // CHECK: define {{.*}} @__tls_init() [[ATTR1]]
28+
29+ // CHECK: attributes [[ATTR1]] = { {{.*}}"branch-target-enforcement" {{.*}}"sign-return-address"="all" "sign-return-address-key"="a_key"
30+ // CHECK: attributes [[ATTR2]] = { {{.*}}"branch-target-enforcement" {{.*}}"sign-return-address"="all" "sign-return-address-key"="a_key"
You can’t perform that action at this time.
0 commit comments