Files
swift-mirror/test/SILOptimizer/inline_coroutine.swift
Erik Eckstein 5b7cd4ef71 PerformanceInliner: favor inlining of co-routines
Not inlined co-routines are so expensive that they should be inlined, unless they are really large.
So far co-routines didn't get any special treatment in the inliner, except generic co-routines.
With this change, even non-generic co-routines are treated as high-priority to inline.

rdar://117201823
2023-10-24 10:36:19 +02:00

36 lines
770 B
Swift

// RUN: %target-swift-frontend -primary-file %s -parse-as-library -module-name=test -emit-sil -O | %FileCheck %s
// Check that co-routines are inlined, even if the yielded value is something non-trivial.
struct S {
var i: Int64
var s: String
}
public struct Foo {
final class Box {
var value = S(i: 0, s: "")
}
var storage: Box = .init()
var value: S {
get {
storage.value
}
_modify {
var value = storage.value
defer { storage.value = value }
yield &value
}
}
}
// CHECK-LABEL: sil hidden @$s4test6testit1x3boxys5Int64V_AA3FooVztF :
// CHECK-NOT: begin_apply
// CHECK: } // end sil function '$s4test6testit1x3boxys5Int64V_AA3FooVztF'
func testit(x: Int64, box: inout Foo) {
box.value.i ^= x
}