Rafael Espindola | 699f5d6 | 2018-02-07 22:15:33 +0000 | [diff] [blame] | 1 | // 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 Storsjo | 5ff7a8e | 2018-08-29 17:26:58 +0000 | [diff] [blame] | 3 | // RUN: %clang_cc1 -triple x86_64-w64-mingw32 -O1 -emit-llvm %s -o - | FileCheck --check-prefix=MINGW %s |
Rafael Espindola | 699f5d6 | 2018-02-07 22:15:33 +0000 | [diff] [blame] | 4 | |
| 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 Storsjo | 5ff7a8e | 2018-08-29 17:26:58 +0000 | [diff] [blame] | 23 | // 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 Espindola | 699f5d6 | 2018-02-07 22:15:33 +0000 | [diff] [blame] | 32 | struct C { |
| 33 | C(); |
| 34 | virtual void foo() {} |
| 35 | }; |
| 36 | C::C() {} |
| 37 | |
| 38 | struct HasVTable { |
| 39 | virtual void f(); |
| 40 | }; |
| 41 | inline HasVTable &useStaticLocal() { |
| 42 | static HasVTable obj; |
| 43 | return obj; |
| 44 | } |
| 45 | void useit() { |
| 46 | useStaticLocal(); |
| 47 | } |
| 48 | |
| 49 | namespace guard { |
| 50 | int f(); |
| 51 | inline int g() { |
| 52 | static int a = f(); |
| 53 | return a; |
| 54 | } |
| 55 | int h() { |
| 56 | return g(); |
| 57 | } |
| 58 | } // namespace guard |
| 59 | |
| 60 | |
Martin Storsjo | 5ff7a8e | 2018-08-29 17:26:58 +0000 | [diff] [blame] | 61 | // STATIC-DAG: @_ZN5test23barIiE1xE = available_externally dso_local constant i32 |
Rafael Espindola | 699f5d6 | 2018-02-07 22:15:33 +0000 | [diff] [blame] | 62 | // STATIC-DAG: define available_externally dso_local void @_ZN5test23barIcEC1Ev( |
Martin Storsjo | 5ff7a8e | 2018-08-29 17:26:58 +0000 | [diff] [blame] | 63 | // NOPLT-DAG: @_ZN5test23barIiE1xE = available_externally dso_local constant i32 |
Rafael Espindola | 699f5d6 | 2018-02-07 22:15:33 +0000 | [diff] [blame] | 64 | // NOPLT-DAG: define available_externally void @_ZN5test23barIcEC1Ev( |
Martin Storsjo | 5ff7a8e | 2018-08-29 17:26:58 +0000 | [diff] [blame] | 65 | // MINGW-DAG: @_ZN5test23barIiE1xE = available_externally constant i32 |
| 66 | // MINGW-DAG: define available_externally dso_local void @_ZN5test23barIcEC1Ev( |
Rafael Espindola | 699f5d6 | 2018-02-07 22:15:33 +0000 | [diff] [blame] | 67 | namespace test2 { |
| 68 | void foo(); |
| 69 | template <typename T> |
| 70 | struct bar { |
| 71 | virtual void zed(); |
Martin Storsjo | 5ff7a8e | 2018-08-29 17:26:58 +0000 | [diff] [blame] | 72 | static const int x = 42; |
Rafael Espindola | 699f5d6 | 2018-02-07 22:15:33 +0000 | [diff] [blame] | 73 | bar() { foo(); } |
| 74 | }; |
| 75 | extern template class bar<char>; |
| 76 | bar<char> abc; |
Martin Storsjo | 5ff7a8e | 2018-08-29 17:26:58 +0000 | [diff] [blame] | 77 | const int *getX() { |
| 78 | return &bar<int>::x; |
| 79 | } |
Rafael Espindola | 699f5d6 | 2018-02-07 22:15:33 +0000 | [diff] [blame] | 80 | } // namespace test2 |