Files
clang-p2996/clang/test/CodeGenObjC/terminate.m
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

32 lines
1.5 KiB
Objective-C

// RUN: %clang_cc1 -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.8 -emit-llvm -fexceptions -fobjc-exceptions -o - %s | FileCheck %s -check-prefix=CHECK-WITH
// RUN: %clang_cc1 -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.7 -emit-llvm -fexceptions -fobjc-exceptions -o - %s | FileCheck %s -check-prefix=CHECK-WITHOUT
void destroy(void**);
// rdar://problem/9519113
void test0(void) {
void test0_helper(void);
void *ptr __attribute__((cleanup(destroy)));
test0_helper();
// CHECK-WITH-LABEL: define{{.*}} void @test0()
// CHECK-WITH-SAME: personality i8* bitcast (i32 (...)* @__gcc_personality_v0 to i8*)
// CHECK-WITH: [[PTR:%.*]] = alloca i8*,
// CHECK-WITH: call void @destroy(i8** [[PTR]])
// CHECK-WITH-NEXT: ret void
// CHECK-WITH: invoke void @destroy(i8** [[PTR]])
// CHECK-WITH: landingpad { i8*, i32 }
// CHECK-WITH-NEXT: catch i8* null
// CHECK-WITH-NEXT: call void @objc_terminate()
// CHECK-WITHOUT-LABEL: define{{.*}} void @test0()
// CHECK-WITHOUT-SAME: personality i8* bitcast (i32 (...)* @__gcc_personality_v0 to i8*)
// CHECK-WITHOUT: [[PTR:%.*]] = alloca i8*,
// CHECK-WITHOUT: call void @destroy(i8** [[PTR]])
// CHECK-WITHOUT-NEXT: ret void
// CHECK-WITHOUT: invoke void @destroy(i8** [[PTR]])
// CHECK-WITHOUT: landingpad { i8*, i32 }
// CHECK-WITHOUT-NEXT: catch i8* null
// CHECK-WITHOUT-NEXT: call void @abort()
}