Files
swift-mirror/test/IRGen/cold_split.swift
T
2026-03-31 06:37:19 -07:00

47 lines
1.4 KiB
Swift

// RUN: %target-swift-frontend %s -module-name=test -emit-assembly \
// RUN: -enable-throws-prediction -O -enable-split-cold-code \
// RUN: | %FileCheck --check-prefix CHECK-ENABLED %s
//// Test disabling just the pass doesn't yield a split.
// RUN: %target-swift-frontend %s -module-name=test -emit-assembly \
// RUN: -enable-throws-prediction -O -disable-split-cold-code \
// RUN: | %FileCheck --check-prefix CHECK-DISABLED %s
//// Test using -Osize doesn't yield a split.
// RUN: %target-swift-frontend %s -module-name=test -emit-assembly \
// RUN: -enable-throws-prediction -Osize -enable-split-cold-code \
// RUN: | %FileCheck --check-prefix CHECK-DISABLED %s
//// Test disabling optimization entirely doesn't yield a split.
// RUN: %target-swift-frontend %s -module-name=test -emit-assembly \
// RUN: -enable-throws-prediction -enable-split-cold-code \
// RUN: | %FileCheck --check-prefix CHECK-DISABLED %s
// CHECK-ENABLED: .cold
// CHECK-DISABLED-NOT: .cold
enum MyError: Error { case err }
func reportError() -> Never {
fatalError()
}
func getRandom(_ b: Bool) throws -> Int {
if b {
return Int.random(in: 0..<1024)
} else {
throw MyError.err
}
}
public func numberWithLogging(_ b: Bool) -> Int {
do {
return try getRandom(b)
} catch {
print("Log: random number generator failed with b=\(b)")
reportError()
}
}