Rafael Espindola | fa9874c | 2018-02-07 19:16:49 +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 |
| 3 | |
| 4 | // STATIC-DAG: @_ZTV1C = linkonce_odr dso_local unnamed_addr constant |
| 5 | // STATIC-DAG: @_ZTS1C = linkonce_odr dso_local constant |
| 6 | // STATIC-DAG: @_ZTI1C = linkonce_odr dso_local constant |
| 7 | // STATIC-DAG: @_ZZ14useStaticLocalvE3obj = linkonce_odr dso_local global |
| 8 | // STATIC-DAG: @_ZGVZN5guard1gEvE1a = linkonce_odr dso_local global |
| 9 | // STATIC-DAG: define dso_local void @_ZN1CC2Ev( |
| 10 | // STATIC-DAG: define dso_local void @_ZN1CC1Ev( |
| 11 | // STATIC-DAG: define linkonce_odr dso_local void @_ZN1C3fooEv( |
| 12 | |
| 13 | // NOPLT-DAG: @_ZTV1C = linkonce_odr dso_local unnamed_addr constant |
| 14 | // NOPLT-DAG: @_ZTS1C = linkonce_odr dso_local constant |
| 15 | // NOPLT-DAG: @_ZTI1C = linkonce_odr dso_local constant |
| 16 | // NOPLT-DAG: @_ZZ14useStaticLocalvE3obj = linkonce_odr dso_local global |
| 17 | // NOPLT-DAG: @_ZGVZN5guard1gEvE1a = linkonce_odr dso_local global |
| 18 | // NOPLT-DAG: define dso_local void @_ZN1CC2Ev( |
| 19 | // NOPLT-DAG: define dso_local void @_ZN1CC1Ev( |
| 20 | // NOPLT-DAG: define linkonce_odr dso_local void @_ZN1C3fooEv( |
| 21 | |
| 22 | struct C { |
| 23 | C(); |
| 24 | virtual void foo() {} |
| 25 | }; |
| 26 | C::C() {} |
| 27 | |
| 28 | struct HasVTable { |
| 29 | virtual void f(); |
| 30 | }; |
| 31 | inline HasVTable &useStaticLocal() { |
| 32 | static HasVTable obj; |
| 33 | return obj; |
| 34 | } |
| 35 | void useit() { |
| 36 | useStaticLocal(); |
| 37 | } |
| 38 | |
| 39 | namespace guard { |
| 40 | int f(); |
| 41 | inline int g() { |
| 42 | static int a = f(); |
| 43 | return a; |
| 44 | } |
| 45 | int h() { |
| 46 | return g(); |
| 47 | } |
| 48 | } // namespace guard |
| 49 | |
| 50 | |
| 51 | // STATIC-DAG: define available_externally dso_local void @_ZN5test23barIcEC1Ev( |
| 52 | // NOPLT-DAG: define available_externally void @_ZN5test23barIcEC1Ev( |
| 53 | namespace test2 { |
| 54 | void foo(); |
| 55 | template <typename T> |
| 56 | struct bar { |
| 57 | virtual void zed(); |
| 58 | bar() { foo(); } |
| 59 | }; |
| 60 | extern template class bar<char>; |
| 61 | bar<char> abc; |
| 62 | } // namespace test2 |