Skip to content

Commit aae81eb

Browse files
committed
IRGen: Adjust tests for upstreaming of _stdlib_isOSVersionAtLeast_AEIC().
1 parent 51373ba commit aae81eb

File tree

3 files changed

+69
-1
lines changed

3 files changed

+69
-1
lines changed

test/IRGen/availability.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// RUN: %target-swift-frontend -primary-file %s -emit-ir | %FileCheck %s
22
// RUN: %target-swift-frontend -primary-file %s -O -emit-ir | %FileCheck %s --check-prefix=OPT
33

4-
// REQUIRES: objc_interop
4+
// On iOS stdlib_isOSVersionAtLeast() is @_transparent, which affects optimization.
5+
// REQUIRES: OS=macosx || OS=tvos || OS=watchos || OS=xros
56

67
import Foundation
78

test/IRGen/availability_ios.swift

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// RUN: %target-swift-frontend -primary-file %s -emit-ir | %FileCheck %s
2+
// RUN: %target-swift-frontend -primary-file %s -O -emit-ir | %FileCheck %s --check-prefix=OPT
3+
4+
// On iOS _stdlib_isOSVersionAtLeast() is @_transparent, which affects optimization.
5+
// See IRGen/availability.swift for other Apple platforms.
6+
// REQUIRES: OS=ios
7+
8+
import Foundation
9+
10+
// We mustn't hoist the alloc_stack for measurement out of the availability
11+
// guard.
12+
13+
// CHECK-LABEL: define{{.*}} @{{.*}}dontHoist
14+
// CHECK-NOT: s10Foundation11MeasurementVySo17NSUnitTemperature
15+
// CHECK: call swiftcc i1 @"$ss31_stdlib_isOSVersionAtLeast_AEICyBi1_Bw_BwBwtF"(
16+
// CHECK: s10Foundation11MeasurementVySo17NSUnitTemperature
17+
18+
// OPT-LABEL: define{{.*}} @{{.*}}dontHoist
19+
// OPT-NOT: S10Foundation11MeasurementVySo17NSUnitTemperature
20+
// OPT: call {{.*}} @__isPlatformVersionAtLeast(
21+
// OPT: s10Foundation11MeasurementVySo17NSUnitTemperature
22+
23+
public func dontHoist() {
24+
if #available(macOS 51.0, iOS 54.0, watchOS 57.0, tvOS 54.0, visionOS 51.1, *) {
25+
let measurement = Measurement<UnitTemperature>(value: Double(42), unit: .celsius)
26+
print("\(measurement)")
27+
} else {
28+
print("Not measurement")
29+
}
30+
}
31+
32+
33+
// Now that _isOSVersionAtLeast is no longer inlinable, we do still
34+
// mark it as _effects(readnone).
35+
// This means that unlike in the past the optimizer can now only coalesce
36+
// availability checks with the same availability. It does not determine,
37+
// for example, that a check for iOS 10 is sufficient to guarantee that a check
38+
// for iOS 9 will also succeed.
39+
40+
// With optimizations on, multiple #availability checks should generate only
41+
// a single call into _isOSVersionAtLeast, which after inlining will be a
42+
// call to __isPlatformVersionAtLeast.
43+
44+
// CHECK-LABEL: define{{.*}} @{{.*}}multipleAvailabilityChecks
45+
// CHECK: call swiftcc i1 @"$ss31_stdlib_isOSVersionAtLeast_AEICyBi1_Bw_BwBwtF"(
46+
// CHECK: call swiftcc i1 @"$ss31_stdlib_isOSVersionAtLeast_AEICyBi1_Bw_BwBwtF"(
47+
// CHECK: call swiftcc i1 @"$ss31_stdlib_isOSVersionAtLeast_AEICyBi1_Bw_BwBwtF"(
48+
// CHECK: ret void
49+
50+
// OPT-LABEL: define{{.*}} @{{.*}}multipleAvailabilityChecks
51+
// OPT: call {{.*}} @__isPlatformVersionAtLeast
52+
// OPT-NOT: call {{.*}} @$__isPlatformVersionAtLeast
53+
// OPT: ret void
54+
public func multipleAvailabilityChecks() {
55+
if #available(macOS 51.0, iOS 54.0, watchOS 57.0, tvOS 54.0, visionOS 51.1, *) {
56+
print("test one")
57+
}
58+
if #available(macOS 51.0, iOS 54.0, watchOS 57.0, tvOS 54.0, visionOS 51.1, *) {
59+
print("test two")
60+
}
61+
if #available(macOS 51.0, iOS 54.0, watchOS 57.0, tvOS 54.0, visionOS 51.1, *) {
62+
print("test three")
63+
}
64+
}

test/IRGen/temporary_allocation/codegen_very_large_allocation.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
// this function.
88
// UNSUPPORTED: OS=xros
99

10+
// On iOS _stdlib_isOSVersionAtLeast() is @_transparent, which affects codegen.
11+
// UNSUPPORTED: OS=ios
12+
1013
@_silgen_name("blackHole")
1114
func blackHole(_ value: UnsafeMutableRawPointer?) -> Void
1215

0 commit comments

Comments
 (0)