mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-09 17:36:05 +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.
60 lines
1.6 KiB
C++
60 lines
1.6 KiB
C++
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 -mconstructor-aliases -O1 -disable-llvm-passes | FileCheck %s
|
|
|
|
struct Member {
|
|
~Member();
|
|
};
|
|
|
|
struct A {
|
|
virtual ~A();
|
|
};
|
|
|
|
struct B : A {
|
|
Member m;
|
|
virtual ~B();
|
|
};
|
|
|
|
// Complete dtor: just an alias because there are no virtual bases.
|
|
// CHECK: @_ZN1BD1Ev ={{.*}} unnamed_addr alias {{.*}} @_ZN1BD2Ev
|
|
|
|
// (aliases from C)
|
|
// CHECK: @_ZN1CD2Ev ={{.*}} unnamed_addr alias {{.*}}, bitcast {{.*}} @_ZN1BD2Ev
|
|
// CHECK: @_ZN1CD1Ev ={{.*}} unnamed_addr alias {{.*}} @_ZN1CD2Ev
|
|
|
|
// Base dtor: actually calls A's base dtor.
|
|
// CHECK-LABEL: define{{.*}} void @_ZN1BD2Ev(%struct.B* {{[^,]*}} %this) unnamed_addr
|
|
// CHECK: call void @_ZN6MemberD1Ev
|
|
// CHECK: call void @_ZN1AD2Ev
|
|
|
|
// Deleting dtor: defers to the complete dtor.
|
|
// CHECK-LABEL: define{{.*}} void @_ZN1BD0Ev(%struct.B* {{[^,]*}} %this) unnamed_addr
|
|
// CHECK: call void @_ZN1BD1Ev
|
|
// CHECK: call void @_ZdlPv
|
|
|
|
B::~B() { }
|
|
|
|
struct C : B {
|
|
~C();
|
|
};
|
|
|
|
C::~C() { }
|
|
|
|
// Complete dtor: just an alias (checked above).
|
|
|
|
// Deleting dtor: defers to the complete dtor.
|
|
// CHECK-LABEL: define{{.*}} void @_ZN1CD0Ev(%struct.C* {{[^,]*}} %this) unnamed_addr
|
|
// CHECK: call void @_ZN1CD1Ev
|
|
// CHECK: call void @_ZdlPv
|
|
|
|
// Base dtor: just an alias to B's base dtor.
|
|
|
|
namespace PR12798 {
|
|
// A qualified call to a base class destructor should not undergo virtual
|
|
// dispatch. Template instantiation used to lose the qualifier.
|
|
struct A { virtual ~A(); };
|
|
template<typename T> void f(T *p) { p->A::~A(); }
|
|
|
|
// CHECK: define {{.*}} @_ZN7PR127981fINS_1AEEEvPT_(
|
|
// CHECK: call void @_ZN7PR127981AD1Ev(
|
|
template void f(A*);
|
|
}
|