Files
swift-mirror/test/SILOptimizer/capture_promotion.swift
Erik Eckstein 1d3724666f tests: convert about 400 tests to the new mangling by using the -new-mangling-for-tests option
When the new mangling is enabled permanently, the option can be removed from the RUN command lines again.
2017-01-24 15:27:45 -08:00

33 lines
811 B
Swift

// RUN: %target-swift-frontend -Xllvm -new-mangling-for-tests %s -emit-sil -o - -verify | %FileCheck %s
class Foo {
func foo() -> Int {
return 1
}
}
class Bar {
}
struct Baz {
var bar = Bar()
var x = 42
}
// CHECK: sil hidden @_T017capture_promotion05test_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 @_T017capture_promotion05test_a1_B0SiycyFSiycfU_Tf2iii_n
// CHECK: partial_apply [[CLOSURE0_PROMOTE0]]({{%[0-9]*}}, {{%[0-9]*}}, {{%[0-9]*}})
return { x + y.foo() + z.x }
}
// CHECK: sil shared @_T017capture_promotion05test_a1_B0SiycyFSiycfU_Tf2iii_n : $@convention(thin) (Int, @owned Foo, @owned Baz) -> Int