Files
swift-mirror/test/SILOptimizer/set.swift
Erik Eckstein c8e74b8393 Generic specialization: change the mangling for dropped metatype arguments
Instead of adding a "flag" (`m` in `...Tgm5`) make it more generic to allow to drop any unused argument.
Add all dropped arguments with a `t<n-1>` (where `<n-1>` is empty for n === 0). For example `...Ttt2g5`.
2024-08-26 10:43:15 +02:00

33 lines
1.5 KiB
Swift

// RUN: %target-swift-frontend -parse-as-library -primary-file %s -O -sil-verify-all -module-name=test -Xllvm -sil-disable-pass=function-signature-opts -emit-sil | %FileCheck %s
// RUN: %target-swift-frontend -parse-as-library -primary-file %s -Osize -sil-verify-all -module-name=test -Xllvm -sil-disable-pass=function-signature-opts -emit-sil | %FileCheck %s
// REQUIRES: swift_stdlib_no_asserts,optimized_stdlib
// REQUIRES: swift_in_compiler
// Test optimal code generation for creating empty sets.
// CHECK-LABEL: sil {{.*}}@$s4test30createEmptySetFromArrayLiteralShySiGyF
// CHECK: global_addr @_swiftEmptySetSingleton
// CHECK-NOT: apply
// CHECK: } // end sil function '$s4test30createEmptySetFromArrayLiteralShySiGyF'
public func createEmptySetFromArrayLiteral() -> Set<Int> {
return []
}
// CHECK-LABEL: sil {{.*}}@$s4test29createEmptySetWithInitializerShySiGyF
// CHECK: global_addr @_swiftEmptySetSingleton
// CHECK-NOT: apply
// CHECK: } // end sil function '$s4test29createEmptySetWithInitializerShySiGyF'
public func createEmptySetWithInitializer() -> Set<Int> {
return Set<Int>()
}
// CHECK-LABEL: sil {{.*}}@$s4test17createNonEmptySetShySiGyF
// CHECK: global_value
// CHECK: [[F:%[0-9]+]] = function_ref @$sSh21_nonEmptyArrayLiteralShyxGSayxG_tcfCSi_Tt0g5
// CHECK: apply [[F]]
// CHECK: } // end sil function '$s4test17createNonEmptySetShySiGyF'
public func createNonEmptySet() -> Set<Int> {
return [1, 2, 3]
}