mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-27 08:16:06 +00:00

For a definition (of most linkage types), dso_local is set for ELF -fno-pic/-fpie and COFF, but not for Mach-O. This nuance causes unneeded binary format differences. This patch replaces (function) `define ` with `define{{.*}} `, (variable/constant/alias) `= ` with `={{.*}} `, or inserts appropriate `{{.*}} ` if there is an explicit linkage. * Clang will set dso_local for Mach-O, which is currently implied by TargetMachine.cpp. This will make COFF/Mach-O and executable ELF similar. * Eventually I hope we can make dso_local the textual LLVM IR default (write explicit "dso_preemptable" when applicable) and -fpic ELF will be similar to everything else. This patch helps move toward that goal.
85 lines
1.4 KiB
C++
85 lines
1.4 KiB
C++
// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin9 -o - %s | FileCheck %s
|
|
|
|
struct C {
|
|
void f();
|
|
void g(int, ...);
|
|
};
|
|
|
|
// CHECK-LABEL: define{{.*}} void @_ZN1C1fEv
|
|
void C::f() {
|
|
}
|
|
|
|
// CHECK-LABEL: define{{.*}} void @_Z5test1v
|
|
void test1() {
|
|
C c;
|
|
|
|
// CHECK: call void @_ZN1C1fEv
|
|
c.f();
|
|
|
|
// CHECK: call void (%struct.C*, i32, ...) @_ZN1C1gEiz
|
|
c.g(1, 2, 3);
|
|
}
|
|
|
|
|
|
struct S {
|
|
inline S() { }
|
|
inline ~S() { }
|
|
|
|
void f_inline1() { }
|
|
inline void f_inline2() { }
|
|
|
|
static void g() { }
|
|
static void f();
|
|
|
|
virtual void v() {}
|
|
};
|
|
|
|
// CHECK-LABEL: define{{.*}} void @_ZN1S1fEv
|
|
void S::f() {
|
|
}
|
|
|
|
void test2() {
|
|
S s;
|
|
|
|
s.f_inline1();
|
|
s.f_inline2();
|
|
|
|
S::g();
|
|
}
|
|
|
|
// S::S()
|
|
// CHECK: define linkonce_odr void @_ZN1SC1Ev{{.*}} unnamed_addr
|
|
|
|
// S::f_inline1()
|
|
// CHECK-LABEL: define linkonce_odr void @_ZN1S9f_inline1Ev
|
|
|
|
// S::f_inline2()
|
|
// CHECK-LABEL: define linkonce_odr void @_ZN1S9f_inline2Ev
|
|
|
|
// S::g()
|
|
// CHECK-LABEL: define linkonce_odr void @_ZN1S1gEv
|
|
|
|
// S::~S()
|
|
// CHECK: define linkonce_odr void @_ZN1SD1Ev{{.*}} unnamed_addr
|
|
|
|
struct T {
|
|
T operator+(const T&);
|
|
};
|
|
|
|
// CHECK-LABEL: define{{.*}} void @_Z5test3v
|
|
void test3() {
|
|
T t1, t2;
|
|
|
|
// CHECK: call void @_ZN1TplERKS_
|
|
T result = t1 + t2;
|
|
}
|
|
|
|
// S::S()
|
|
// CHECK: define linkonce_odr void @_ZN1SC2Ev{{.*}} unnamed_addr
|
|
|
|
// S::v()
|
|
// CHECK: define linkonce_odr void @_ZN1S1vEv{{.*}}unnamed_addr
|
|
|
|
// S::~S()
|
|
// CHECK: define linkonce_odr void @_ZN1SD2Ev{{.*}} unnamed_addr
|