summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/dso-local-executable.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2018-02-07 22:15:33 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2018-02-07 22:15:33 +0000
commit699f5d6bbc43fbd62e60f913379565bd86c6df8c (patch)
treed960a41f09b97d96b0eea7e8c5b7881b8bfa24a5 /clang/test/CodeGenCXX/dso-local-executable.cpp
parent9bc04e98c5bd429cd49790ebf0a799c6a71427c5 (diff)
downloadbcm5719-llvm-699f5d6bbc43fbd62e60f913379565bd86c6df8c.tar.gz
bcm5719-llvm-699f5d6bbc43fbd62e60f913379565bd86c6df8c.zip
Recommit r324107 again.
The difference from the previous try is that we no longer directly access function declarations from position independent executables. It should work, but currently doesn't with some linkers. It now includes a fix to not mark available_externally definitions as dso_local. Original message: Start setting dso_local in clang. This starts adding dso_local to clang. The hope is to eventually have TargetMachine::shouldAssumeDsoLocal go away. My objective for now is to move enough of it to clang to remove the need for the TargetMachine one to handle PIE copy relocations and -fno-plt. With that it should then be easy to implement a -fno-copy-reloc in clang. This patch just adds the cases where we assume a symbol to be local based on the file being compiled for an executable or a shared library. llvm-svn: 324535
Diffstat (limited to 'clang/test/CodeGenCXX/dso-local-executable.cpp')
-rw-r--r--clang/test/CodeGenCXX/dso-local-executable.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/dso-local-executable.cpp b/clang/test/CodeGenCXX/dso-local-executable.cpp
new file mode 100644
index 00000000000..cc8d50f09c9
--- /dev/null
+++ b/clang/test/CodeGenCXX/dso-local-executable.cpp
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux -mrelocation-model static -O1 -emit-llvm %s -o - | FileCheck --check-prefix=STATIC %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux -mrelocation-model static -fno-plt -O1 -emit-llvm %s -o - | FileCheck --check-prefix=NOPLT %s
+
+// STATIC-DAG: @_ZTV1C = linkonce_odr dso_local unnamed_addr constant
+// STATIC-DAG: @_ZTS1C = linkonce_odr dso_local constant
+// STATIC-DAG: @_ZTI1C = linkonce_odr dso_local constant
+// STATIC-DAG: @_ZZ14useStaticLocalvE3obj = linkonce_odr dso_local global
+// STATIC-DAG: @_ZGVZN5guard1gEvE1a = linkonce_odr dso_local global
+// STATIC-DAG: define dso_local void @_ZN1CC2Ev(
+// STATIC-DAG: define dso_local void @_ZN1CC1Ev(
+// STATIC-DAG: define linkonce_odr dso_local void @_ZN1C3fooEv(
+
+// NOPLT-DAG: @_ZTV1C = linkonce_odr dso_local unnamed_addr constant
+// NOPLT-DAG: @_ZTS1C = linkonce_odr dso_local constant
+// NOPLT-DAG: @_ZTI1C = linkonce_odr dso_local constant
+// NOPLT-DAG: @_ZZ14useStaticLocalvE3obj = linkonce_odr dso_local global
+// NOPLT-DAG: @_ZGVZN5guard1gEvE1a = linkonce_odr dso_local global
+// NOPLT-DAG: define dso_local void @_ZN1CC2Ev(
+// NOPLT-DAG: define dso_local void @_ZN1CC1Ev(
+// NOPLT-DAG: define linkonce_odr dso_local void @_ZN1C3fooEv(
+
+struct C {
+ C();
+ virtual void foo() {}
+};
+C::C() {}
+
+struct HasVTable {
+ virtual void f();
+};
+inline HasVTable &useStaticLocal() {
+ static HasVTable obj;
+ return obj;
+}
+void useit() {
+ useStaticLocal();
+}
+
+namespace guard {
+int f();
+inline int g() {
+ static int a = f();
+ return a;
+}
+int h() {
+ return g();
+}
+} // namespace guard
+
+
+// STATIC-DAG: define available_externally dso_local void @_ZN5test23barIcEC1Ev(
+// NOPLT-DAG: define available_externally void @_ZN5test23barIcEC1Ev(
+namespace test2 {
+void foo();
+template <typename T>
+struct bar {
+ virtual void zed();
+ bar() { foo(); }
+};
+extern template class bar<char>;
+bar<char> abc;
+} // namespace test2
OpenPOWER on IntegriCloud