Files
swift-mirror/test/SILOptimizer/capture_promotion_ownership.swift
Michael Gottesman 3ebd8df493 [gardening] Remove unnecessary -enable-sil-ownership from tests that now just get it from their pattern.
This just eliminates -enable-sil-ownership from all target-swift-frontend and
target-swift-emit-silgen RUN lines. Both of those now include
enable-sil-ownership in their expansion.
2019-03-12 20:39:18 -07:00

33 lines
830 B
Swift

// RUN: %target-swift-frontend %s -emit-sil -o - | %FileCheck %s
class Foo {
func foo() -> Int {
return 1
}
}
class Bar {
}
struct Baz {
var bar = Bar()
var x = 42
}
// CHECK: sil hidden @$s27capture_promotion_ownership05test_a1_B0SiycyF
func test_capture_promotion() -> () -> Int {
var x : Int = 1; x = 1
var y : Foo = Foo(); y = Foo()
var z : Baz = Baz(); z = Baz()
// CHECK-NOT: alloc_box
// CHECK: [[CLOSURE0_PROMOTE0:%.*]] = function_ref @$s27capture_promotion_ownership05test_a1_B0SiycyFSiycfU_Tf2iii_n
// CHECK: partial_apply [callee_guaranteed] [[CLOSURE0_PROMOTE0]]({{%[0-9]*}}, {{%[0-9]*}}, {{%[0-9]*}})
return { x + y.foo() + z.x }
}
// CHECK: sil private @$s27capture_promotion_ownership05test_a1_B0SiycyFSiycfU_Tf2iii_n : $@convention(thin) (Int, @guaranteed Foo, @guaranteed Baz) -> Int