sil_stage canonical /* *** RLE on function: testNumber12345 *** *** RLE on function: buz *** *** RLE on function: bad *** *** RLE on function: bar *** LSLocation #0 %1 = global_addr @MyIntStorage : $*Int // users: %12, %11, %7, %6, %4 Projection Path [$*Int Field: var _value: Int64 of: $*Builtin.Int64] PROCESS bb0 for RLE. WRITE alloc_global @MyIntStorage // id: %0 WRITE %6 = apply %5(%1) : $@convention(thin) (@in_guaranteed Int) -> () FORWARD %3 = struct $Int (%2 : $Builtin.Int64) // user: %4 to %7 = load %1 : $*Int // user: %9 WRITE %9 = apply %8(%7) : $@convention(thin) (Int) -> () // user: %14 WRITE %11 = apply %10(%1) : $@convention(thin) (@in_guaranteed Int) -> () WRITE %13 = apply %8(%12) : $@convention(thin) (Int) -> () Replacing %7 = load %1 : $*Int // user: %9 With %3 = struct $Int (%2 : $Builtin.Int64) // user: %4 *** RLE on function: main *** */ import Builtin import Swift import SwiftShims // MyIntStorage sil_global hidden [let] @MyIntStorage : $Int // testNumber12345 sil hidden [noinline] @testNumber12345 : $@convention(thin) (Int) -> () { // %0 // users: %3, %1 bb0(%0 : $Int): debug_value %0 : $Int, let, name "a", argno 1 // id: %1 %2 = integer_literal $Builtin.Int64, 12345 // user: %4 %3 = struct_extract %0 : $Int, #Int._value // user: %4 %4 = builtin "cmp_eq_Int64"(%3 : $Builtin.Int64, %2 : $Builtin.Int64) : $Builtin.Int1 // user: %6 %5 = integer_literal $Builtin.Int1, -1 // user: %6 %6 = builtin "xor_Int1"(%4 : $Builtin.Int1, %5 : $Builtin.Int1) : $Builtin.Int1 // user: %7 cond_fail %6 : $Builtin.Int1 // id: %7 %8 = tuple () // user: %9 return %8 : $() // id: %9 } // end sil function 'testNumber12345' // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer>>): // function_ref bar %2 = function_ref @bar : $@convention(thin) () -> () // user: %3 %3 = apply %2() : $@convention(thin) () -> () %4 = integer_literal $Builtin.Int32, 0 // user: %5 %5 = struct $Int32 (%4 : $Builtin.Int32) // user: %6 return %5 : $Int32 // id: %6 } // end sil function 'main' // bar sil hidden @bar : $@convention(thin) () -> () { bb0: alloc_global @MyIntStorage // id: %0 %1 = global_addr @MyIntStorage : $*Int // users: %11, %10, %6, %4 %2 = integer_literal $Builtin.Int64, 42 // user: %3 %3 = struct $Int (%2 : $Builtin.Int64) // users: %8, %4 store %3 to %1 : $*Int // id: %4 // function_ref buz %5 = function_ref @buz : $@convention(thin) (@in_guaranteed Int) -> () // user: %6 %6 = apply %5(%1) : $@convention(thin) (@in_guaranteed Int) -> () // function_ref testNumber12345 %7 = function_ref @testNumber12345 : $@convention(thin) (Int) -> () // users: %12, %8 %8 = apply %7(%3) : $@convention(thin) (Int) -> () // user: %13 // function_ref bad %9 = function_ref @bad : $@convention(thin) (@in_guaranteed Int) -> () // user: %10 %10 = apply %9(%1) : $@convention(thin) (@in_guaranteed Int) -> () %11 = load %1 : $*Int // user: %12 %12 = apply %7(%11) : $@convention(thin) (Int) -> () return %8 : $() // id: %13 } // end sil function 'bar' // buz sil hidden @buz : $@convention(thin) (@in_guaranteed Int) -> () { // %0 // user: %1 bb0(%0 : $*Int): %1 = load %0 : $*Int // user: %3 // function_ref testNumber12345 %2 = function_ref @testNumber12345 : $@convention(thin) (Int) -> () // user: %3 %3 = apply %2(%1) : $@convention(thin) (Int) -> () // user: %4 return %3 : $() // id: %4 } // end sil function 'buz' // bad sil hidden @bad : $@convention(thin) (@in_guaranteed Int) -> () { // %0 // user: %3 bb0(%0 : $*Int): %1 = integer_literal $Builtin.Int64, 23 // user: %2 %2 = struct $Int (%1 : $Builtin.Int64) // user: %3 store %2 to %0 : $*Int // id: %3 %4 = tuple () // user: %5 return %4 : $() // id: %5 } // end sil function 'bad'