Files
swift-mirror/test/embedded/optionset2.swift
Erik Eckstein bd7db677ed MandatoryPerformanceOptimizations: perform function signature optimization to remove metatype arguments
Generic specialization already takes care of removing metatype arguments of generic functions.
But sometimes non-generic functions have metatype arguments which must be removed.
We need handle this case with a function signature optimization.

This enables, for example, to use `OptionSet` in embedded swift.

rdar://121206953
2024-01-31 17:16:18 +01:00

30 lines
771 B
Swift

// RUN: %target-swift-frontend -target armv7-apple-none-macho -Xcc -D__MACH__ -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s
// RUN: %target-swift-frontend -target arm64-apple-none-macho -Xcc -D__MACH__ -Xcc -D__arm64__ -Xcc -D__APPLE__ -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s
// REQUIRES: swift_in_compiler
// REQUIRES: optimized_stdlib
// REQUIRES: CODEGENERATOR=ARM
protocol MyOptionSet: Equatable {
init(rawValue: Int)
init()
}
extension MyOptionSet {
var isEmpty: Bool {
return self == Self()
}
init() {
self.init(rawValue: 0)
}
}
struct ShippingOptions: MyOptionSet {
let rawValue: Int
}
var s = ShippingOptions(rawValue: 42)
print(s.isEmpty)
// CHECK: define {{.*}}i32 @main(i32 %0, ptr %1)