Files
swift-mirror/test/IRGen/sil_linkage.sil
Erik Eckstein d25b1ed834 Optimizer: Replace the MandatoryCombine pass with a Simplification pass, which is implemented in Swift
The Swift Simplification pass can do more than the old MandatoryCombine pass: simplification of more instruction types and dead code elimination.
The result is a better -Onone performance while still keeping debug info consistent.

Currently following code patterns are simplified:
* `struct` -> `struct_extract`
* `enum` -> `unchecked_enum_data`
* `partial_apply` -> `apply`
* `br` to a 1:1 related block
* `cond_br` with a constant condition
* `isConcrete` and `is_same_metadata` builtins

More simplifications can be added in the future.

rdar://96708429
rdar://104562580
2023-02-09 06:50:05 +01:00

146 lines
6.7 KiB
Plaintext

// RUN: %target-swift-frontend -Xllvm -sil-disable-pass=simplification -emit-ir %s | %FileCheck %s --check-prefix=WMO --check-prefix=CHECK
// RUN: %target-swift-frontend -Xllvm -sil-disable-pass=simplification -emit-ir -primary-file %s | %FileCheck %s --check-prefix=PRIMARY --check-prefix=CHECK
sil_stage canonical
// CHECK: define{{( dllexport)?}}{{( protected)?}} swiftcc void @public_fragile_function_test() {{.*}} {
// CHECK: define{{( dllexport)?}}{{( protected)?}} swiftcc void @public_transparent_fragile_function_test() {{.*}} {
// CHECK: define{{( dllexport)?}}{{( protected)?}} swiftcc void @public_transparent_function_test() {{.*}} {
// PRIMARY: define weak_odr hidden swiftcc void @public_non_abi_function_test() {{.*}} {
// WMO: define linkonce_odr hidden swiftcc void @public_non_abi_function_test() {{.*}} {
// CHECK: define linkonce_odr hidden swiftcc void @shared_fragile_function_test() {{.*}} {
// Public external functions are not emitted into clients.
// CHECK: declare{{( dllimport)?}} swiftcc void @public_external_fragile_function_def_test()
// CHECK: define{{( protected)?}}{{( dllexport)?}} swiftcc void @public_resilient_function_test() {{.*}} {
// CHECK: define hidden swiftcc void @hidden_resilient_function_test() {{.*}} {
// CHECK: define linkonce_odr hidden swiftcc void @shared_resilient_function_test() {{.*}} {
// CHECK: define internal swiftcc void @private_resilient_function_test() {{.*}}{
// Public external functions are not emitted into clients.
// CHECK: declare{{( dllimport)?}} swiftcc void @public_external_resilient_function_def_test()
sil public [serialized] @public_fragile_function_test : $@convention(thin) () -> () {
%0 = tuple()
return %0 : $()
}
sil public [transparent] [serialized] @public_transparent_fragile_function_test : $@convention(thin) () -> () {
%0 = tuple()
return %0 : $()
}
sil public [transparent] @public_transparent_function_test : $@convention(thin) () -> () {
%0 = tuple()
return %0 : $()
}
sil non_abi [serialized] @public_non_abi_function_test : $@convention(thin) () -> () {
%0 = tuple()
return %0 : $()
}
sil shared [serialized] @shared_fragile_function_test : $@convention(thin) () -> () {
%0 = tuple()
return %0 : $()
}
sil public_external [serialized] @public_external_fragile_function_def_test : $@convention(thin) () -> () {
%0 = tuple()
return %0 : $()
}
sil public_external [serialized] @public_external_fragile_function_decl_test : $@convention(thin) () -> ()
sil hidden_external [serialized] @hidden_external_fragile_function_decl_test : $@convention(thin) () -> ()
// 'shared' should always be a definition.
// sil shared_external [serialized] @shared_external_fragile_function_decl_test : $@convention(thin) () -> ()
// 'private' should always be a definition.
// sil private_external [serialized] @private_external_fragile_function_decl_test : $@convention(thin) () -> ()
sil public @public_resilient_function_test : $@convention(thin) () -> () {
%0 = tuple()
return %0 : $()
}
sil hidden @hidden_resilient_function_test : $@convention(thin) () -> () {
%0 = tuple()
return %0 : $()
}
sil shared @shared_resilient_function_test : $@convention(thin) () -> () {
%0 = tuple()
return %0 : $()
}
sil private @private_resilient_function_test : $@convention(thin) () -> () {
%0 = tuple()
return %0 : $()
}
sil public_external [serialized] @public_external_resilient_function_def_test : $@convention(thin) () -> () {
%0 = tuple()
return %0 : $()
}
// 'private_external' should always be fragile.
// sil private_external @private_external_resilient_function_def_test : $@convention(thin) () -> () {
// %0 = tuple()
// return %0 : $()
// }
sil public_external @public_external_resilient_function_decl_test : $@convention(thin) () -> ()
sil hidden_external @hidden_external_resilient_function_decl_test : $@convention(thin) () -> ()
// 'shared' should always be a definition.
// sil shared_external @shared_external_resilient_function_decl_test : $@convention(thin) () -> ()
// 'private' should always be a definition.
// sil private_external @private_external_resilient_function_decl_test : $@convention(thin) () -> ()
sil public @use_all_symbols : $@convention(thin) () -> () {
%0 = function_ref @public_fragile_function_test : $@convention(thin) () -> ()
%t0 = function_ref @public_transparent_fragile_function_test : $@convention(thin) () -> ()
%t1 = function_ref @public_transparent_function_test : $@convention(thin) () -> ()
%t2 = function_ref @public_non_abi_function_test : $@convention(thin) () -> ()
%2 = function_ref @shared_fragile_function_test : $@convention(thin) () -> ()
%4 = function_ref @public_external_fragile_function_def_test : $@convention(thin) () -> ()
%8 = function_ref @public_external_fragile_function_decl_test : $@convention(thin) () -> ()
%9 = function_ref @hidden_external_fragile_function_decl_test : $@convention(thin) () -> ()
// %10 = function_ref @shared_external_fragile_function_decl_test : $@convention(thin) () -> ()
// %11 = function_ref @private_external_fragile_function_decl_test : $@convention(thin) () -> ()
%12 = function_ref @public_resilient_function_test : $@convention(thin) () -> ()
%13 = function_ref @hidden_resilient_function_test : $@convention(thin) () -> ()
%14 = function_ref @shared_resilient_function_test : $@convention(thin) () -> ()
%15 = function_ref @private_resilient_function_test : $@convention(thin) () -> ()
%16 = function_ref @public_external_resilient_function_def_test : $@convention(thin) () -> ()
// %19 = function_ref @private_external_resilient_function_def_test : $@convention(thin) () -> ()
%20 = function_ref @public_external_resilient_function_decl_test : $@convention(thin) () -> ()
%21 = function_ref @hidden_external_resilient_function_decl_test : $@convention(thin) () -> ()
// %22 = function_ref @shared_external_resilient_function_decl_test : $@convention(thin) () -> ()
// %23 = function_ref @private_external_resilient_function_decl_test : $@convention(thin) () -> ()
apply %0() : $@convention(thin) () -> ()
apply %2() : $@convention(thin) () -> ()
apply %4() : $@convention(thin) () -> ()
apply %8() : $@convention(thin) () -> ()
apply %9() : $@convention(thin) () -> ()
// apply %10() : $@convention(thin) () -> ()
// apply %11() : $@convention(thin) () -> ()
apply %12() : $@convention(thin) () -> ()
apply %13() : $@convention(thin) () -> ()
apply %14() : $@convention(thin) () -> ()
apply %15() : $@convention(thin) () -> ()
apply %16() : $@convention(thin) () -> ()
// apply %19() : $@convention(thin) () -> ()
apply %20() : $@convention(thin) () -> ()
apply %21() : $@convention(thin) () -> ()
// apply %22() : $@convention(thin) () -> ()
// apply %23() : $@convention(thin) () -> ()
%24 = tuple()
return %24 : $()
}