blob: ceb649e074a3072bda7abe4833558d96360154c0 [file] [log] [blame]
Rafael Espindola699f5d62018-02-07 22:15:33 +00001// RUN: %clang_cc1 -triple x86_64-pc-linux -mrelocation-model static -O1 -emit-llvm %s -o - | FileCheck --check-prefix=STATIC %s
2// RUN: %clang_cc1 -triple x86_64-pc-linux -mrelocation-model static -fno-plt -O1 -emit-llvm %s -o - | FileCheck --check-prefix=NOPLT %s
Martin Storsjo5ff7a8e2018-08-29 17:26:58 +00003// RUN: %clang_cc1 -triple x86_64-w64-mingw32 -O1 -emit-llvm %s -o - | FileCheck --check-prefix=MINGW %s
Rafael Espindola699f5d62018-02-07 22:15:33 +00004
5// STATIC-DAG: @_ZTV1C = linkonce_odr dso_local unnamed_addr constant
6// STATIC-DAG: @_ZTS1C = linkonce_odr dso_local constant
7// STATIC-DAG: @_ZTI1C = linkonce_odr dso_local constant
8// STATIC-DAG: @_ZZ14useStaticLocalvE3obj = linkonce_odr dso_local global
9// STATIC-DAG: @_ZGVZN5guard1gEvE1a = linkonce_odr dso_local global
10// STATIC-DAG: define dso_local void @_ZN1CC2Ev(
11// STATIC-DAG: define dso_local void @_ZN1CC1Ev(
12// STATIC-DAG: define linkonce_odr dso_local void @_ZN1C3fooEv(
13
14// NOPLT-DAG: @_ZTV1C = linkonce_odr dso_local unnamed_addr constant
15// NOPLT-DAG: @_ZTS1C = linkonce_odr dso_local constant
16// NOPLT-DAG: @_ZTI1C = linkonce_odr dso_local constant
17// NOPLT-DAG: @_ZZ14useStaticLocalvE3obj = linkonce_odr dso_local global
18// NOPLT-DAG: @_ZGVZN5guard1gEvE1a = linkonce_odr dso_local global
19// NOPLT-DAG: define dso_local void @_ZN1CC2Ev(
20// NOPLT-DAG: define dso_local void @_ZN1CC1Ev(
21// NOPLT-DAG: define linkonce_odr dso_local void @_ZN1C3fooEv(
22
Martin Storsjo5ff7a8e2018-08-29 17:26:58 +000023// MINGW-DAG: @_ZTV1C = linkonce_odr dso_local unnamed_addr constant
24// MINGW-DAG: @_ZTS1C = linkonce_odr dso_local constant
25// MINGW-DAG: @_ZTI1C = linkonce_odr dso_local constant
26// MINGW-DAG: @_ZZ14useStaticLocalvE3obj = linkonce_odr dso_local global
27// MINGW-DAG: @_ZGVZN5guard1gEvE1a = linkonce_odr dso_local global
28// MINGW-DAG: define dso_local void @_ZN1CC2Ev(
29// MINGW-DAG: define dso_local void @_ZN1CC1Ev(
30// MINGW-DAG: define linkonce_odr dso_local void @_ZN1C3fooEv(
31
Rafael Espindola699f5d62018-02-07 22:15:33 +000032struct C {
33 C();
34 virtual void foo() {}
35};
36C::C() {}
37
38struct HasVTable {
39 virtual void f();
40};
41inline HasVTable &useStaticLocal() {
42 static HasVTable obj;
43 return obj;
44}
45void useit() {
46 useStaticLocal();
47}
48
49namespace guard {
50int f();
51inline int g() {
52 static int a = f();
53 return a;
54}
55int h() {
56 return g();
57}
58} // namespace guard
59
60
Martin Storsjo5ff7a8e2018-08-29 17:26:58 +000061// STATIC-DAG: @_ZN5test23barIiE1xE = available_externally dso_local constant i32
Rafael Espindola699f5d62018-02-07 22:15:33 +000062// STATIC-DAG: define available_externally dso_local void @_ZN5test23barIcEC1Ev(
Martin Storsjo5ff7a8e2018-08-29 17:26:58 +000063// NOPLT-DAG: @_ZN5test23barIiE1xE = available_externally dso_local constant i32
Rafael Espindola699f5d62018-02-07 22:15:33 +000064// NOPLT-DAG: define available_externally void @_ZN5test23barIcEC1Ev(
Martin Storsjo5ff7a8e2018-08-29 17:26:58 +000065// MINGW-DAG: @_ZN5test23barIiE1xE = available_externally constant i32
66// MINGW-DAG: define available_externally dso_local void @_ZN5test23barIcEC1Ev(
Rafael Espindola699f5d62018-02-07 22:15:33 +000067namespace test2 {
68void foo();
69template <typename T>
70struct bar {
71 virtual void zed();
Martin Storsjo5ff7a8e2018-08-29 17:26:58 +000072 static const int x = 42;
Rafael Espindola699f5d62018-02-07 22:15:33 +000073 bar() { foo(); }
74};
75extern template class bar<char>;
76bar<char> abc;
Martin Storsjo5ff7a8e2018-08-29 17:26:58 +000077const int *getX() {
78 return &bar<int>::x;
79}
Rafael Espindola699f5d62018-02-07 22:15:33 +000080} // namespace test2