mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-10 02:36: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.
34 lines
910 B
C++
34 lines
910 B
C++
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fapple-kext -emit-llvm -o - %s | FileCheck %s
|
|
|
|
struct Base {
|
|
virtual ~Base();
|
|
} ;
|
|
|
|
struct Derived : Base {
|
|
void operator delete(void *) { }
|
|
Derived();
|
|
};
|
|
|
|
void foo() {
|
|
Derived d1; // ok
|
|
}
|
|
|
|
// CHECK-LABEL: define internal i32 @_Z1fj(
|
|
inline unsigned f(unsigned n) { return n == 0 ? 0 : n + f(n-1); }
|
|
|
|
unsigned g(unsigned n) { return f(n); }
|
|
|
|
// rdar://problem/10133200: give explicit instantiations external linkage in kernel mode
|
|
// CHECK-LABEL: define{{.*}} void @_Z3barIiEvv()
|
|
template <typename T> void bar() {}
|
|
template void bar<int>();
|
|
|
|
// CHECK-LABEL: define internal i32 @_Z5identIiET_S0_(
|
|
template <typename X> X ident(X x) { return x; }
|
|
|
|
int foo(int n) { return ident(n); }
|
|
|
|
// CHECK-LABEL: define internal void @_ZN7DerivedD1Ev(
|
|
// CHECK-LABEL: define internal void @_ZN7DerivedD0Ev(
|
|
// CHECK-LABEL: define internal void @_ZN7DeriveddlEPv(
|