| 1 |
// RUN: %clang_cc1 -triple thumbv8.1m.main-none-eabi -target-feature +pacbti -fcxx-exceptions -fexceptions -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-PACBTI |
| 2 |
// RUN: %clang_cc1 -triple thumbv8.1m.main-none-eabi -target-feature -pacbti -fcxx-exceptions -fexceptions -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-NOPACBTI |
| 3 |
|
| 4 |
// Check that functions generated by clang have the correct attributes |
| 5 |
|
| 6 |
class Example { |
| 7 |
public: |
| 8 |
Example(); |
| 9 |
int fn(); |
| 10 |
}; |
| 11 |
|
| 12 |
// Initialization of var1 causes __cxx_global_var_init and __tls_init to be generated |
| 13 |
thread_local Example var1; |
| 14 |
extern thread_local Example var2; |
| 15 |
extern void fn(); |
| 16 |
|
| 17 |
int testfn() noexcept { |
| 18 |
// Calling fn in a noexcept function causes __clang_call_terminate to be generated |
| 19 |
fn(); |
| 20 |
// Use of var1 and var2 causes TLS wrapper functions to be generated |
| 21 |
return var1.fn() + var2.fn(); |
| 22 |
} |
| 23 |
|
| 24 |
// CHECK: define {{.*}} @__cxx_global_var_init() [[ATTR1:#[0-9]+]] |
| 25 |
// CHECK: define {{.*}} @__clang_call_terminate({{.*}}) [[ATTR2:#[0-9]+]] |
| 26 |
// CHECK: define {{.*}} @_ZTW4var1() [[ATTR1]] |
| 27 |
// CHECK: define {{.*}} @_ZTW4var2() [[ATTR1]] |
| 28 |
// CHECK: define {{.*}} @__tls_init() [[ATTR1]] |
| 29 |
|
| 30 |
// CHECK-PACBTI: attributes [[ATTR1]] = { {{.*}}"target-features"="+armv8.1-m.main,+pacbti,+thumb-mode"{{.*}} } |
| 31 |
// CHECK-PACBTI: attributes [[ATTR2]] = { {{.*}}"target-features"="+armv8.1-m.main,+pacbti,+thumb-mode"{{.*}} } |
| 32 |
|
| 33 |
// CHECK-NOPACBTI: attributes [[ATTR1]] = { {{.*}}"target-features"="+armv8.1-m.main,+thumb-mode,-pacbti"{{.*}} } |
| 34 |
// CHECK-NOPACBTI: attributes [[ATTR2]] = { {{.*}}"target-features"="+armv8.1-m.main,+thumb-mode,-pacbti"{{.*}} } |