| // RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil -enable-sil-verify-all %s -caller-analysis-printer -o /dev/null | %FileCheck --check-prefix=CHECK %s |
| |
| // CHECK: Function dead_func has caller: false, partial applied args = 0 |
| // CHECK: Function call_top has caller: false, partial applied args = 0 |
| // CHECK: Function call_middle has caller: true, partial applied args = 0 |
| // CHECK: Function call_bottom has caller: true, partial applied args = 0 |
| // CHECK: Function self_recursive_func has caller: true, partial applied args = 0 |
| // CHECK: Function mutual_recursive_func1 has caller: true, partial applied args = 0 |
| // CHECK: Function mutual_recursive_func2 has caller: true, partial applied args = 0 |
| // CHECK: Function multi_called has caller: true, partial applied args = 0 |
| // CHECK: Function multi_calles has caller: false, partial applied args = 0 |
| // CHECK: Function multi_callers has caller: true, partial applied args = 0 |
| // CHECK: Function multi_caller1 has caller: false, partial applied args = 0 |
| // CHECK: Function multi_caller2 has caller: false, partial applied args = 0 |
| // CHECK: Function closure1 has caller: false, partial applied args = 1 |
| // CHECK: Function closure2 has caller: false, partial applied args = 2 |
| // CHECK: Function partial_apply_one_arg has caller: false, partial applied args = 0 |
| // CHECK: Function partial_apply_two_args1 has caller: false, partial applied args = 0 |
| // CHECK: Function partial_apply_two_args2 has caller: false, partial applied args = 0 |
| |
| sil_stage canonical |
| |
| import Builtin |
| |
| sil hidden @dead_func : $@convention(thin) () -> () { |
| %2 = tuple () |
| return %2 : $() |
| } |
| |
| sil hidden @call_top : $@convention(thin) () -> () { |
| bb0: |
| %0 = function_ref @call_middle : $@convention(thin) () -> () |
| %1 = apply %0() : $@convention(thin) () -> () |
| %2 = tuple () |
| return %2 : $() |
| } |
| |
| sil hidden @call_middle : $@convention(thin) () -> () { |
| bb0: |
| %0 = function_ref @call_bottom : $@convention(thin) () -> () |
| %1 = apply %0() : $@convention(thin) () -> () |
| %2 = tuple () |
| return %2 : $() |
| } |
| |
| sil hidden @call_bottom : $@convention(thin) () -> () { |
| bb0: |
| %0 = tuple () |
| return %0 : $() |
| } |
| |
| sil hidden @self_recursive_func : $@convention(thin) () -> () { |
| bb0: |
| %0 = function_ref @self_recursive_func : $@convention(thin) () -> () |
| %1 = apply %0() : $@convention(thin) () -> () |
| %2 = tuple () |
| return %2 : $() |
| } |
| |
| sil hidden @mutual_recursive_func1 : $@convention(thin) () -> () { |
| bb0: |
| %0 = function_ref @mutual_recursive_func2 : $@convention(thin) () -> () |
| %1 = apply %0() : $@convention(thin) () -> () |
| %2 = tuple () |
| return %2 : $() |
| } |
| |
| sil hidden @mutual_recursive_func2 : $@convention(thin) () -> () { |
| bb0: |
| %0 = function_ref @mutual_recursive_func1 : $@convention(thin) () -> () |
| %1 = apply %0() : $@convention(thin) () -> () |
| %2 = tuple () |
| return %2 : $() |
| } |
| |
| sil hidden @multi_called : $@convention(thin) () -> () { |
| bb0: |
| %2 = tuple () |
| return %2 : $() |
| } |
| |
| sil hidden @multi_calles : $@convention(thin) () -> () { |
| bb0: |
| %0 = function_ref @multi_called : $@convention(thin) () -> () |
| %1 = apply %0() : $@convention(thin) () -> () |
| cond_br undef, bb1, bb2 |
| bb1: |
| %2 = apply %0() : $@convention(thin) () -> () |
| br bb3 |
| bb2: |
| %3 = apply %0() : $@convention(thin) () -> () |
| br bb3 |
| bb3: |
| %4 = tuple () |
| return %4 : $() |
| } |
| |
| sil hidden @multi_callers : $@convention(thin) () -> () { |
| bb0: |
| %2 = tuple () |
| return %2 : $() |
| } |
| |
| sil hidden @multi_caller1 : $@convention(thin) () -> () { |
| bb0: |
| %0 = function_ref @multi_callers : $@convention(thin) () -> () |
| %1 = apply %0() : $@convention(thin) () -> () |
| %2 = tuple () |
| return %2 : $() |
| } |
| |
| sil hidden @multi_caller2 : $@convention(thin) () -> () { |
| bb0: |
| %0 = function_ref @multi_callers : $@convention(thin) () -> () |
| %1 = apply %0() : $@convention(thin) () -> () |
| %2 = tuple () |
| return %2 : $() |
| } |
| |
| sil @closure1 : $@convention(thin) (Builtin.Int32, Builtin.Int32) -> Builtin.Int32 { |
| bb0(%0 : $Builtin.Int32, %1 : $Builtin.Int32): |
| return %0 : $Builtin.Int32 |
| } |
| |
| sil @closure2 : $@convention(thin) (Builtin.Int32, Builtin.Int32) -> Builtin.Int32 { |
| bb0(%0 : $Builtin.Int32, %1 : $Builtin.Int32): |
| return %0 : $Builtin.Int32 |
| } |
| |
| sil @partial_apply_one_arg : $@convention(thin) (Builtin.Int32) -> @owned @callee_owned (Builtin.Int32) -> Builtin.Int32 { |
| bb0(%0 : $Builtin.Int32): |
| %1 = function_ref @closure1 : $@convention(thin) (Builtin.Int32, Builtin.Int32) -> Builtin.Int32 |
| %2 = partial_apply %1(%0) : $@convention(thin) (Builtin.Int32, Builtin.Int32) -> Builtin.Int32 |
| return %2 : $@callee_owned (Builtin.Int32) -> Builtin.Int32 |
| } |
| |
| sil @partial_apply_two_args1 : $@convention(thin) (Builtin.Int32) -> @owned @callee_owned () -> Builtin.Int32 { |
| bb0(%0 : $Builtin.Int32): |
| %1 = function_ref @closure1 : $@convention(thin) (Builtin.Int32, Builtin.Int32) -> Builtin.Int32 |
| %2 = partial_apply %1(%0, %0) : $@convention(thin) (Builtin.Int32, Builtin.Int32) -> Builtin.Int32 |
| return %2 : $@callee_owned () -> Builtin.Int32 |
| } |
| |
| sil @partial_apply_two_args2 : $@convention(thin) (Builtin.Int32) -> @owned @callee_owned () -> Builtin.Int32 { |
| bb0(%0 : $Builtin.Int32): |
| %1 = function_ref @closure2 : $@convention(thin) (Builtin.Int32, Builtin.Int32) -> Builtin.Int32 |
| %2 = partial_apply %1(%0, %0) : $@convention(thin) (Builtin.Int32, Builtin.Int32) -> Builtin.Int32 |
| return %2 : $@callee_owned () -> Builtin.Int32 |
| } |