dso-local-executable.cpp 1.9 KB

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