Debian Codegraph @

clang/test/CodeGenCXX/dso-local-executable.cpp

raw
1 // RUN: %clang_cc1 -triple x86_64-pc-linux -mrelocation-model static -O1 -disable-llvm-passes -emit-llvm %s -o - | FileCheck --check-prefix=STATIC %s
2 // RUN: %clang_cc1 -triple x86_64-pc-linux -mrelocation-model static -fno-plt -O1 -disable-llvm-passes -emit-llvm %s -o - | FileCheck --check-prefix=NOPLT %s
3 // RUN: %clang_cc1 -triple x86_64-w64-mingw32 -O1 -disable-llvm-passes -emit-llvm %s -o - | FileCheck --check-prefix=MINGW %s
4 // RUN: %clang_cc1 -triple x86_64-pc-cygwin -O1 -disable-llvm-passes -emit-llvm %s -o - | FileCheck --check-prefix=MINGW %s
5
6 // STATIC-DAG: @_ZTV1C = linkonce_odr dso_local unnamed_addr constant
7 // STATIC-DAG: @_ZTS1C = linkonce_odr dso_local constant
8 // STATIC-DAG: @_ZTI1C = linkonce_odr dso_local constant
9 // STATIC-DAG: @_ZZ14useStaticLocalvE3obj = linkonce_odr dso_local global
10 // STATIC-DAG: @_ZGVZN5guard1gEvE1a = linkonce_odr dso_local global
11 // STATIC-DAG: define dso_local void @_ZN1CC2Ev(
12 // STATIC-DAG: define dso_local void @_ZN1CC1Ev(
13 // STATIC-DAG: define linkonce_odr dso_local void @_ZN1C3fooEv(
14
15 // NOPLT-DAG: @_ZTV1C = linkonce_odr dso_local unnamed_addr constant
16 // NOPLT-DAG: @_ZTS1C = linkonce_odr dso_local constant
17 // NOPLT-DAG: @_ZTI1C = linkonce_odr dso_local constant
18 // NOPLT-DAG: @_ZZ14useStaticLocalvE3obj = linkonce_odr dso_local global
19 // NOPLT-DAG: @_ZGVZN5guard1gEvE1a = linkonce_odr dso_local global
20 // NOPLT-DAG: define dso_local void @_ZN1CC2Ev(
21 // NOPLT-DAG: define dso_local void @_ZN1CC1Ev(
22 // NOPLT-DAG: define linkonce_odr dso_local void @_ZN1C3fooEv(
23
24 // MINGW-DAG: @_ZTV1C = linkonce_odr dso_local unnamed_addr constant
25 // MINGW-DAG: @_ZTS1C = linkonce_odr dso_local constant
26 // MINGW-DAG: @_ZTI1C = linkonce_odr dso_local constant
27 // MINGW-DAG: @_ZZ14useStaticLocalvE3obj = linkonce_odr dso_local global
28 // MINGW-DAG: @_ZGVZN5guard1gEvE1a = linkonce_odr dso_local global
29 // MINGW-DAG: define dso_local void @_ZN1CC2Ev(
30 // MINGW-DAG: define dso_local void @_ZN1CC1Ev(
31 // MINGW-DAG: define linkonce_odr dso_local void @_ZN1C3fooEv(
32
33 struct C {
34 C();
35 virtual void foo() {}
36 };
37 C::C() {}
38
39 struct HasVTable {
40 virtual void f();
41 };
42 inline HasVTable &useStaticLocal() {
43 static HasVTable obj;
44 return obj;
45 }
46 void useit() {
47 useStaticLocal();
48 }
49
50 namespace guard {
51 int f();
52 inline int g() {
53 static int a = f();
54 return a;
55 }
56 int h() {
57 return g();
58 }
59 } // namespace guard
60
61
62 // STATIC-DAG: @_ZN5test23barIiE1xE = available_externally dso_local constant i32
63 // STATIC-DAG: define available_externally dso_local void @_ZN5test23barIcEC1Ev(
64 // NOPLT-DAG: @_ZN5test23barIiE1xE = available_externally dso_local constant i32
65 // NOPLT-DAG: define available_externally void @_ZN5test23barIcEC1Ev(
66 // MINGW-DAG: @_ZN5test23barIiE1xE = available_externally constant i32
67 // MINGW-DAG: define available_externally dso_local void @_ZN5test23barIcEC1Ev(
68 namespace test2 {
69 void foo();
70 template <typename T>
71 struct bar {
72 virtual void zed();
73 static const int x = 42;
74 bar() { foo(); }
75 };
76 extern template class bar<char>;
77 bar<char> abc;
78 const int *getX() {
79 return &bar<int>::x;
80 }
81 } // namespace test2