// RUN: %target-sil-opt -enable-sil-verify-all -inline %s | %FileCheck %s // Check cloning of instructions. sil_stage canonical import Builtin class X { } sil [always_inline] @callee_alloc_ref_stack : $@convention(thin) () -> () { bb0: %0 = alloc_ref [stack] $X dealloc_stack_ref %0 : $X %r = tuple () return %r : $() } // CHECK-LABEL: sil @caller_alloc_ref_stack : $@convention(thin) () -> () // CHECK: [[X:%[0-9]+]] = alloc_ref [stack] $X // CHECK: dealloc_stack_ref [[X]] : $X sil @caller_alloc_ref_stack : $@convention(thin) () -> () { bb0: %0 = function_ref @callee_alloc_ref_stack : $@convention(thin) () -> () %1 = apply %0() : $@convention(thin) () -> () %2 = tuple () return %2 : $() } sil [ossa] [always_inline] @callee_begin_borrow_lexical : $@convention(thin) () -> () { %instance = alloc_ref $X %guaranteed_c = begin_borrow [lexical] %instance : $X end_borrow %guaranteed_c : $X destroy_value %instance : $X %res = tuple () return %res : $() } // CHECK-LABEL: sil [ossa] @caller_begin_borrow_lexical // CHECK: begin_borrow [lexical] // CHECK-LABEL: } // end sil function 'caller_begin_borrow_lexical' sil [ossa] @caller_begin_borrow_lexical : $@convention(thin) () -> () { %callee_begin_borrow_lexical = function_ref @callee_begin_borrow_lexical : $@convention(thin) () -> () %res = apply %callee_begin_borrow_lexical() : $@convention(thin) () -> () return %res : $() } sil [ossa] @callee_alloc_stack : $@convention(thin) () -> () { %instance = alloc_stack $Builtin.NativeObject dealloc_stack %instance : $*Builtin.NativeObject %instance2 = alloc_stack [dynamic_lifetime] $Builtin.NativeObject dealloc_stack %instance2 : $*Builtin.NativeObject %instance3 = alloc_stack [lexical] $Builtin.NativeObject dealloc_stack %instance3 : $*Builtin.NativeObject %instance4 = alloc_stack [dynamic_lifetime] [lexical] $Builtin.NativeObject dealloc_stack %instance4 : $*Builtin.NativeObject %res = tuple () return %res : $() } // CHECK-LABEL: sil [ossa] @caller_alloc_stack_lexical // CHECK: alloc_stack // CHECK: alloc_stack [dynamic_lifetime] // CHECK: alloc_stack [lexical] // CHECK: alloc_stack [dynamic_lifetime] [lexical] // CHECK-LABEL: } // end sil function 'caller_alloc_stack_lexical' sil [ossa] @caller_alloc_stack_lexical : $@convention(thin) () -> () { %callee_alloc_stack = function_ref @callee_alloc_stack : $@convention(thin) () -> () %res = apply %callee_alloc_stack() : $@convention(thin) () -> () return %res : $() } sil [ossa] @callee_move_value : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject { entry(%0 : @owned $Builtin.NativeObject): %1 = move_value %0 : $Builtin.NativeObject %2 = move_value [allows_diagnostics] %1 : $Builtin.NativeObject %3 = move_value [lexical] %2 : $Builtin.NativeObject %4 = move_value [allows_diagnostics] [lexical] %3 : $Builtin.NativeObject return %4 : $Builtin.NativeObject } // CHECK-LABEL: sil [ossa] @caller_move_value {{.*}} { // CHECK: {{bb[0-9]+}}([[REGISTER_0:%[^,]+]] : // CHECK: [[REGISTER_1:%[^,]+]] = move_value [[REGISTER_0]] // CHECK: [[REGISTER_2:%[^,]+]] = move_value [allows_diagnostics] [[REGISTER_1]] // CHECK: [[REGISTER_3:%[^,]+]] = move_value [lexical] [[REGISTER_2]] // CHECK: [[REGISTER_4:%[^,]+]] = move_value [allows_diagnostics] [lexical] [[REGISTER_3]] // CHECK: return [[REGISTER_4]] // CHECK-LABEL: } // end sil function 'caller_move_value' sil [ossa] @caller_move_value : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject { entry(%0 : @owned $Builtin.NativeObject): %callee_move_value = function_ref @callee_move_value : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject %res = apply %callee_move_value(%0) : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject return %res : $Builtin.NativeObject } sil [ossa] @callee_debug_value : $@convention(thin) (@owned X) -> @owned X { entry(%0 : @owned $X): debug_value [trace] %0 : $X return %0 : $X } sil [ossa] @caller_debug_value : $@convention(thin) (@owned X) -> @owned X { entry(%0 : @owned $X): %callee_debug_value = function_ref @callee_debug_value : $@convention(thin) (@owned X) -> @owned X %res = apply %callee_debug_value(%0) : $@convention(thin) (@owned X) -> @owned X return %res : $X } // CHECK-LABEL: sil [ossa] @caller_test_specification : {{.*}} { // CHECK: test_specification "foo bar baz" // CHECK-LABEL: } // end sil function 'caller_test_specification' sil [always_inline] [ossa] @callee_test_specification : $@convention(thin) () -> () { entry: test_specification "foo bar baz" %retval = tuple () return %retval : $() } sil [ossa] @caller_test_specification : $@convention(thin) () -> () { %callee = function_ref @callee_test_specification : $@convention(thin) () -> () %retval = apply %callee() : $@convention(thin) () -> () return %retval : $() }