summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/dso-local-executable.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2018-02-02 17:17:39 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2018-02-02 17:17:39 +0000
commit7e34a308ff8d9270d2654ce0e8ed9e1600676afb (patch)
tree927ab52990faf9c3743ace3cfdd9582c9e150dca /clang/test/CodeGenCXX/dso-local-executable.cpp
parente538fc74d4c0d30f8c652c3f4e46375339e9d27b (diff)
downloadbcm5719-llvm-7e34a308ff8d9270d2654ce0e8ed9e1600676afb.tar.gz
bcm5719-llvm-7e34a308ff8d9270d2654ce0e8ed9e1600676afb.zip
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: 324107
Diffstat (limited to 'clang/test/CodeGenCXX/dso-local-executable.cpp')
-rw-r--r--clang/test/CodeGenCXX/dso-local-executable.cpp38
1 files changed, 38 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..cd8a0a72973
--- /dev/null
+++ b/clang/test/CodeGenCXX/dso-local-executable.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -mrelocation-model static -emit-llvm %s -o - | FileCheck --check-prefix=STATIC %s
+
+// STATIC: @_ZTV1C = linkonce_odr dso_local unnamed_addr constant
+// STATIC: @_ZTS1C = linkonce_odr dso_local constant
+// STATIC: @_ZTI1C = linkonce_odr dso_local constant
+// STATIC: @_ZZ14useStaticLocalvE3obj = linkonce_odr dso_local global
+// STATIC: @_ZGVZN5guard1gEvE1a = linkonce_odr dso_local global
+// STATIC: define dso_local void @_ZN1CC2Ev(
+// STATIC: define dso_local void @_ZN1CC1Ev(
+// STATIC: 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
OpenPOWER on IntegriCloud