Fangrui Song 6b3351792c [test] Add {{.*}} to make tests immune to dso_local/dso_preemptable/(none) differences
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.
2020-12-30 20:52:01 -08:00

51 lines
1.3 KiB
Plaintext

// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -disable-llvm-passes -o - %s | FileCheck %s
// rdar://18249673
@class MyObject;
struct base {
~base() = default;
};
struct derived : public base {
MyObject *myobject;
};
void test1() {
derived d1;
}
// CHECK-LABEL: define{{.*}} void @_Z5test1v()
// CHECK: call void @_ZN7derivedC1Ev
// CHECK: call void @_ZN7derivedD1Ev
void test2() {
derived *d2 = new derived;
delete d2;
}
// CHECK-LABEL: define{{.*}} void @_Z5test2v()
// CHECK: call void @_ZN7derivedC1Ev
// CHECK: call void @_ZN7derivedD1Ev
template <typename T>
struct tderived : public base {
MyObject *myobject;
};
void test3() {
tderived<int> d1;
}
// CHECK-LABEL: define{{.*}} void @_Z5test3v()
// CHECK: call void @_ZN8tderivedIiEC1Ev
// CHECK: call void @_ZN8tderivedIiED1Ev
void test4() {
tderived<int> *d2 = new tderived<int>;
delete d2;
}
// CHECK-LABEL: define{{.*}} void @_Z5test4v()
// CHECK: call void @_ZN8tderivedIiEC1Ev
// CHECK: call void @_ZN8tderivedIiED1Ev
// CHECK-LABEL: define linkonce_odr void @_ZN7derivedD2Ev
// CHECK: call void @llvm.objc.storeStrong(i8** {{.*}}, i8* null)
// CHECK-LABEL: define linkonce_odr void @_ZN8tderivedIiED2Ev
// CHECK: call void @llvm.objc.storeStrong(i8** {{.*}}, i8* null)