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.
28 lines
947 B
C++
28 lines
947 B
C++
// RUN: %clang_cc1 -emit-llvm -triple=x86_64-apple-darwin10 -o - %s | FileCheck -check-prefix=WITH-TSS %s
|
|
// RUN: %clang_cc1 -emit-llvm -triple=x86_64-apple-darwin10 -o - %s -fno-threadsafe-statics | FileCheck -check-prefix=NO-TSS %s
|
|
|
|
int f();
|
|
|
|
// WITH-TSS: @_ZZ1gvE1a = internal global i32 0, align 4
|
|
// WITH-TSS: @_ZGVZ1gvE1a = internal global i64 0
|
|
|
|
// WITH-TSS: define{{.*}} void @_Z1gv() [[NUW:#[0-9]+]]
|
|
// WITH-TSS: call i32 @__cxa_guard_acquire
|
|
// WITH-TSS: call void @__cxa_guard_release
|
|
// WITH-TSS: ret void
|
|
void g() {
|
|
static int a = f();
|
|
}
|
|
|
|
// NO-TSS: @_ZZ1gvE1a = internal global i32 0, align 4
|
|
// NO-TSS: @_ZGVZ1gvE1a = internal global i8 0
|
|
|
|
// NO-TSS: define{{.*}} void @_Z1gv() [[NUW:#[0-9]+]]
|
|
// NO-TSS-NOT: call i32 @__cxa_guard_acquire
|
|
// NO-TSS-NOT: call void @__cxa_guard_release
|
|
// NO-TSS: ret void
|
|
|
|
// WITH-TSS: attributes [[NUW]] = { noinline nounwind{{.*}} }
|
|
|
|
// NO-TSS: attributes [[NUW]] = { noinline nounwind{{.*}} }
|