Skip to content

Instantly share code, notes, and snippets.

@hoc081098
Last active March 11, 2023 17:31
Show Gist options
  • Save hoc081098/b1d0a0eaa91a7d45b842a998b777ce25 to your computer and use it in GitHub Desktop.
Save hoc081098/b1d0a0eaa91a7d45b842a998b777ce25 to your computer and use it in GitHub Desktop.
import Foundation
func getData1() async throws -> Int {
try await Task.sleep(nanoseconds: 2_000_000_000)
return 1
}
func getData2() async throws -> Int {
try await Task.sleep(nanoseconds: 2_000_000_000)
return 2
}
func test() {
Task {
async let i1 = try await getData1()
async let i2 = try await getData2()
let sum = (try await i1) + (try await i2)
}
}
swiftc -emit-sil async_let.swift
async_let.swift:25:9: warning: initialization of immutable value 'sum' was never used; consider replacing with assignment to '_' or removing it
let sum = (try await i1) + (try await i2)
~~~~^~~
_
sil_stage canonical
import Builtin
import Swift
import SwiftShims
import Foundation
func getData1() async throws -> Int
func getData2() async throws -> Int
func test()
// main
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
%2 = integer_literal $Builtin.Int32, 0 // user: %3
%3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4
return %3 : $Int32 // id: %4
} // end sil function 'main'
// getData1()
sil hidden @$s9async_let8getData1SiyYaKF : $@convention(thin) @async () -> (Int, @error Error) {
bb0:
debug_value undef : $Error, var, name "$error", argno 1 // id: %0
%1 = metatype $@thin Task<Never, Never>.Type // user: %5
%2 = integer_literal $Builtin.Int64, 2000000000 // user: %3
%3 = struct $UInt64 (%2 : $Builtin.Int64) // user: %5
// function_ref static Task<>.sleep(nanoseconds:)
%4 = function_ref @$sScTss5NeverORszABRs_rlE5sleep11nanosecondsys6UInt64V_tYaKFZ : $@convention(method) @async (UInt64, @thin Task<Never, Never>.Type) -> @error Error // user: %5
try_apply %4(%3, %1) : $@convention(method) @async (UInt64, @thin Task<Never, Never>.Type) -> @error Error, normal bb1, error bb2 // id: %5
bb1(%6 : $()): // Preds: bb0
%7 = integer_literal $Builtin.Int64, 1 // user: %8
%8 = struct $Int (%7 : $Builtin.Int64) // user: %9
return %8 : $Int // id: %9
// %10 // user: %11
bb2(%10 : $Error): // Preds: bb0
throw %10 : $Error // id: %11
} // end sil function '$s9async_let8getData1SiyYaKF'
// UInt64.init(_builtinIntegerLiteral:)
sil public_external [transparent] @$ss6UInt64V22_builtinIntegerLiteralABBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin UInt64.Type) -> UInt64 {
// %0 // user: %2
bb0(%0 : $Builtin.IntLiteral, %1 : $@thin UInt64.Type):
%2 = builtin "s_to_u_checked_trunc_IntLiteral_Int64"(%0 : $Builtin.IntLiteral) : $(Builtin.Int64, Builtin.Int1) // user: %3
%3 = tuple_extract %2 : $(Builtin.Int64, Builtin.Int1), 0 // user: %4
%4 = struct $UInt64 (%3 : $Builtin.Int64) // user: %5
return %4 : $UInt64 // id: %5
} // end sil function '$ss6UInt64V22_builtinIntegerLiteralABBI_tcfC'
// static Task<>.sleep(nanoseconds:)
sil [available 12.0.0] @$sScTss5NeverORszABRs_rlE5sleep11nanosecondsys6UInt64V_tYaKFZ : $@convention(method) @async (UInt64, @thin Task<Never, Never>.Type) -> @error Error
// Int.init(_builtinIntegerLiteral:)
sil public_external [transparent] @$sSi22_builtinIntegerLiteralSiBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int {
// %0 // user: %2
bb0(%0 : $Builtin.IntLiteral, %1 : $@thin Int.Type):
%2 = builtin "s_to_s_checked_trunc_IntLiteral_Int64"(%0 : $Builtin.IntLiteral) : $(Builtin.Int64, Builtin.Int1) // user: %3
%3 = tuple_extract %2 : $(Builtin.Int64, Builtin.Int1), 0 // user: %4
%4 = struct $Int (%3 : $Builtin.Int64) // user: %5
return %4 : $Int // id: %5
} // end sil function '$sSi22_builtinIntegerLiteralSiBI_tcfC'
// getData2()
sil hidden @$s9async_let8getData2SiyYaKF : $@convention(thin) @async () -> (Int, @error Error) {
bb0:
debug_value undef : $Error, var, name "$error", argno 1 // id: %0
%1 = metatype $@thin Task<Never, Never>.Type // user: %5
%2 = integer_literal $Builtin.Int64, 2000000000 // user: %3
%3 = struct $UInt64 (%2 : $Builtin.Int64) // user: %5
// function_ref static Task<>.sleep(nanoseconds:)
%4 = function_ref @$sScTss5NeverORszABRs_rlE5sleep11nanosecondsys6UInt64V_tYaKFZ : $@convention(method) @async (UInt64, @thin Task<Never, Never>.Type) -> @error Error // user: %5
try_apply %4(%3, %1) : $@convention(method) @async (UInt64, @thin Task<Never, Never>.Type) -> @error Error, normal bb1, error bb2 // id: %5
bb1(%6 : $()): // Preds: bb0
%7 = integer_literal $Builtin.Int64, 2 // user: %8
%8 = struct $Int (%7 : $Builtin.Int64) // user: %9
return %8 : $Int // id: %9
// %10 // user: %11
bb2(%10 : $Error): // Preds: bb0
throw %10 : $Error // id: %11
} // end sil function '$s9async_let8getData2SiyYaKF'
// test()
sil hidden @$s9async_let4testyyF : $@convention(thin) () -> () {
bb0:
%0 = metatype $@thin Task<(), Error>.Type // user: %9
%1 = alloc_stack $Optional<TaskPriority> // users: %10, %9, %2
inject_enum_addr %1 : $*Optional<TaskPriority>, #Optional.none!enumelt // id: %2
// function_ref closure #1 in test()
%3 = function_ref @$s9async_let4testyyFyyYaYbKcfU_ : $@convention(thin) @Sendable @async () -> @error Error // user: %4
%4 = thin_to_thick_function %3 : $@convention(thin) @Sendable @async () -> @error Error to $@Sendable @async @callee_guaranteed () -> @error Error // user: %6
// function_ref thunk for @escaping @callee_guaranteed @Sendable @async () -> (@error @owned Error)
%5 = function_ref @$ss5Error_pIeghHzo_ytsAA_pIeghHrzo_TR : $@convention(thin) @Sendable @async (@guaranteed @Sendable @async @callee_guaranteed () -> @error Error) -> (@out (), @error Error) // user: %6
%6 = partial_apply [callee_guaranteed] %5(%4) : $@convention(thin) @Sendable @async (@guaranteed @Sendable @async @callee_guaranteed () -> @error Error) -> (@out (), @error Error) // user: %7
%7 = convert_function %6 : $@Sendable @async @callee_guaranteed () -> (@out (), @error Error) to $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <()> // user: %9
// function_ref Task<>.init(priority:operation:)
%8 = function_ref @$sScTss5Error_pRs_rlE8priority9operationScTyxsAA_pGScPSg_xyYaYbKcntcfC : $@convention(method) <τ_0_0, τ_0_1 where τ_0_1 == Error> (@in Optional<TaskPriority>, @owned @Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <τ_0_0>, @thin Task<τ_0_0, Error>.Type) -> @owned Task<τ_0_0, Error> // user: %9
%9 = apply %8<(), Error>(%1, %7, %0) : $@convention(method) <τ_0_0, τ_0_1 where τ_0_1 == Error> (@in Optional<TaskPriority>, @owned @Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <τ_0_0>, @thin Task<τ_0_0, Error>.Type) -> @owned Task<τ_0_0, Error> // user: %11
dealloc_stack %1 : $*Optional<TaskPriority> // id: %10
release_value %9 : $Task<(), Error> // id: %11
%12 = tuple () // user: %13
return %12 : $() // id: %13
} // end sil function '$s9async_let4testyyF'
// closure #1 in test()
sil private @$s9async_let4testyyFyyYaYbKcfU_ : $@convention(thin) @Sendable @async () -> @error Error {
bb0:
debug_value undef : $Error, var, name "$error", argno 1 // id: %0
%1 = alloc_stack $Int // users: %26, %49, %76, %64, %2
%2 = address_to_pointer %1 : $*Int to $Builtin.RawPointer // users: %46, %73, %24, %61, %11
%3 = enum $Optional<Builtin.RawPointer>, #Optional.none!enumelt // user: %11
// function_ref implicit closure #1 in closure #1 in test()
%4 = function_ref @$s9async_let4testyyFyyYaYbKcfU_SiyYaYbKcfu_ : $@convention(thin) @Sendable @async () -> (Int, @error Error) // user: %5
%5 = thin_to_thick_function %4 : $@convention(thin) @Sendable @async () -> (Int, @error Error) to $@Sendable @async @callee_guaranteed () -> (Int, @error Error) // user: %7
// function_ref thunk for @escaping @callee_guaranteed @Sendable @async () -> (@unowned Int, @error @owned Error)
%6 = function_ref @$sSis5Error_pIeghHdzo_SisAA_pIegHrzo_TR : $@convention(thin) @async (@guaranteed @Sendable @async @callee_guaranteed () -> (Int, @error Error)) -> (@out Int, @error Error) // user: %7
%7 = partial_apply [callee_guaranteed] %6(%5) : $@convention(thin) @async (@guaranteed @Sendable @async @callee_guaranteed () -> (Int, @error Error)) -> (@out Int, @error Error) // user: %8
%8 = convert_function %7 : $@async @callee_guaranteed () -> (@out Int, @error Error) to $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Int> // users: %79, %75, %63, %51, %48, %10, %9
strong_retain %8 : $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Int> // id: %9
%10 = convert_escape_to_noescape %8 : $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Int> to $@noescape @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Int> // user: %11
%11 = builtin "startAsyncLetWithLocalBuffer"<Int>(%3 : $Optional<Builtin.RawPointer>, %10 : $@noescape @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Int>, %2 : $Builtin.RawPointer) : $Builtin.RawPointer // users: %47, %46, %74, %73, %24, %62, %61
%12 = alloc_stack $Int // users: %30, %44, %71, %59, %13
%13 = address_to_pointer %12 : $*Int to $Builtin.RawPointer // users: %41, %28, %68, %56, %22
%14 = enum $Optional<Builtin.RawPointer>, #Optional.none!enumelt // user: %22
// function_ref implicit closure #2 in closure #1 in test()
%15 = function_ref @$s9async_let4testyyFyyYaYbKcfU_SiyYaYbKcfu0_ : $@convention(thin) @Sendable @async () -> (Int, @error Error) // user: %16
%16 = thin_to_thick_function %15 : $@convention(thin) @Sendable @async () -> (Int, @error Error) to $@Sendable @async @callee_guaranteed () -> (Int, @error Error) // user: %18
// function_ref thunk for @escaping @callee_guaranteed @Sendable @async () -> (@unowned Int, @error @owned Error)
%17 = function_ref @$sSis5Error_pIeghHdzo_SisAA_pIegHrzo_TR : $@convention(thin) @async (@guaranteed @Sendable @async @callee_guaranteed () -> (Int, @error Error)) -> (@out Int, @error Error) // user: %18
%18 = partial_apply [callee_guaranteed] %17(%16) : $@convention(thin) @async (@guaranteed @Sendable @async @callee_guaranteed () -> (Int, @error Error)) -> (@out Int, @error Error) // user: %19
%19 = convert_function %18 : $@async @callee_guaranteed () -> (@out Int, @error Error) to $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Int> // users: %80, %70, %58, %52, %43, %21, %20
strong_retain %19 : $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Int> // id: %20
%21 = convert_escape_to_noescape %19 : $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Int> to $@noescape @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Int> // user: %22
%22 = builtin "startAsyncLetWithLocalBuffer"<Int>(%14 : $Optional<Builtin.RawPointer>, %21 : $@noescape @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Int>, %13 : $Builtin.RawPointer) : $Builtin.RawPointer // users: %42, %41, %28, %69, %68, %57, %56
// function_ref swift_asyncLet_get_throwing
%23 = function_ref @swift_asyncLet_get_throwing : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> (Builtin.RawPointer, @error Error) // user: %24
try_apply %23(%11, %2) : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> (Builtin.RawPointer, @error Error), normal bb1, error bb3 // id: %24
bb1(%25 : $Builtin.RawPointer): // Preds: bb0
%26 = load %1 : $*Int // user: %31
// function_ref swift_asyncLet_get_throwing
%27 = function_ref @swift_asyncLet_get_throwing : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> (Builtin.RawPointer, @error Error) // user: %28
try_apply %27(%22, %13) : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> (Builtin.RawPointer, @error Error), normal bb2, error bb4 // id: %28
bb2(%29 : $Builtin.RawPointer): // Preds: bb1
%30 = load %12 : $*Int // user: %32
%31 = struct_extract %26 : $Int, #Int._value // user: %34
%32 = struct_extract %30 : $Int, #Int._value // user: %34
%33 = integer_literal $Builtin.Int1, -1 // user: %34
%34 = builtin "sadd_with_overflow_Int64"(%31 : $Builtin.Int64, %32 : $Builtin.Int64, %33 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1) // users: %36, %35
%35 = tuple_extract %34 : $(Builtin.Int64, Builtin.Int1), 0 // user: %38
%36 = tuple_extract %34 : $(Builtin.Int64, Builtin.Int1), 1 // user: %37
cond_fail %36 : $Builtin.Int1, "arithmetic overflow" // id: %37
%38 = struct $Int (%35 : $Builtin.Int64) // user: %39
debug_value %38 : $Int, let, name "sum" // id: %39
// function_ref swift_asyncLet_finish
%40 = function_ref @swift_asyncLet_finish : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> () // user: %41
%41 = apply %40(%22, %13) : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> ()
%42 = builtin "endAsyncLetLifetime"(%22 : $Builtin.RawPointer) : $()
strong_release %19 : $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Int> // id: %43
dealloc_stack %12 : $*Int // id: %44
// function_ref swift_asyncLet_finish
%45 = function_ref @swift_asyncLet_finish : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> () // user: %46
%46 = apply %45(%11, %2) : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> ()
%47 = builtin "endAsyncLetLifetime"(%11 : $Builtin.RawPointer) : $()
strong_release %8 : $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Int> // id: %48
dealloc_stack %1 : $*Int // id: %49
%50 = tuple () // user: %53
strong_release %8 : $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Int> // id: %51
strong_release %19 : $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Int> // id: %52
return %50 : $() // id: %53
// %54 // user: %65
bb3(%54 : $Error): // Preds: bb0
// function_ref swift_asyncLet_finish
%55 = function_ref @swift_asyncLet_finish : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> () // user: %56
%56 = apply %55(%22, %13) : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> ()
%57 = builtin "endAsyncLetLifetime"(%22 : $Builtin.RawPointer) : $()
strong_release %19 : $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Int> // id: %58
dealloc_stack %12 : $*Int // id: %59
// function_ref swift_asyncLet_finish
%60 = function_ref @swift_asyncLet_finish : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> () // user: %61
%61 = apply %60(%11, %2) : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> ()
%62 = builtin "endAsyncLetLifetime"(%11 : $Builtin.RawPointer) : $()
strong_release %8 : $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Int> // id: %63
dealloc_stack %1 : $*Int // id: %64
br bb5(%54 : $Error) // id: %65
// %66 // user: %77
bb4(%66 : $Error): // Preds: bb1
// function_ref swift_asyncLet_finish
%67 = function_ref @swift_asyncLet_finish : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> () // user: %68
%68 = apply %67(%22, %13) : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> ()
%69 = builtin "endAsyncLetLifetime"(%22 : $Builtin.RawPointer) : $()
strong_release %19 : $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Int> // id: %70
dealloc_stack %12 : $*Int // id: %71
// function_ref swift_asyncLet_finish
%72 = function_ref @swift_asyncLet_finish : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> () // user: %73
%73 = apply %72(%11, %2) : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> ()
%74 = builtin "endAsyncLetLifetime"(%11 : $Builtin.RawPointer) : $()
strong_release %8 : $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Int> // id: %75
dealloc_stack %1 : $*Int // id: %76
br bb5(%66 : $Error) // id: %77
// %78 // user: %81
bb5(%78 : $Error): // Preds: bb4 bb3
strong_release %8 : $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Int> // id: %79
strong_release %19 : $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Int> // id: %80
throw %78 : $Error // id: %81
} // end sil function '$s9async_let4testyyFyyYaYbKcfU_'
// implicit closure #1 in closure #1 in test()
sil private @$s9async_let4testyyFyyYaYbKcfU_SiyYaYbKcfu_ : $@convention(thin) @Sendable @async () -> (Int, @error Error) {
bb0:
debug_value undef : $Error, var, name "$error", argno 1 // id: %0
// function_ref getData1()
%1 = function_ref @$s9async_let8getData1SiyYaKF : $@convention(thin) @async () -> (Int, @error Error) // user: %2
try_apply %1() : $@convention(thin) @async () -> (Int, @error Error), normal bb1, error bb2 // id: %2
// %3 // user: %4
bb1(%3 : $Int): // Preds: bb0
return %3 : $Int // id: %4
// %5 // user: %6
bb2(%5 : $Error): // Preds: bb0
throw %5 : $Error // id: %6
} // end sil function '$s9async_let4testyyFyyYaYbKcfU_SiyYaYbKcfu_'
// thunk for @escaping @callee_guaranteed @Sendable @async () -> (@unowned Int, @error @owned Error)
sil shared [transparent] [reabstraction_thunk] @$sSis5Error_pIeghHdzo_SisAA_pIegHrzo_TR : $@convention(thin) @async (@guaranteed @Sendable @async @callee_guaranteed () -> (Int, @error Error)) -> (@out Int, @error Error) {
// %0 // user: %4
// %1 // user: %2
bb0(%0 : $*Int, %1 : $@Sendable @async @callee_guaranteed () -> (Int, @error Error)):
try_apply %1() : $@Sendable @async @callee_guaranteed () -> (Int, @error Error), normal bb1, error bb2 // id: %2
// %3 // user: %4
bb1(%3 : $Int): // Preds: bb0
store %3 to %0 : $*Int // id: %4
%5 = tuple () // user: %6
return %5 : $() // id: %6
// %7 // user: %8
bb2(%7 : $Error): // Preds: bb0
throw %7 : $Error // id: %8
} // end sil function '$sSis5Error_pIeghHdzo_SisAA_pIegHrzo_TR'
// implicit closure #2 in closure #1 in test()
sil private @$s9async_let4testyyFyyYaYbKcfU_SiyYaYbKcfu0_ : $@convention(thin) @Sendable @async () -> (Int, @error Error) {
bb0:
debug_value undef : $Error, var, name "$error", argno 1 // id: %0
// function_ref getData2()
%1 = function_ref @$s9async_let8getData2SiyYaKF : $@convention(thin) @async () -> (Int, @error Error) // user: %2
try_apply %1() : $@convention(thin) @async () -> (Int, @error Error), normal bb1, error bb2 // id: %2
// %3 // user: %4
bb1(%3 : $Int): // Preds: bb0
return %3 : $Int // id: %4
// %5 // user: %6
bb2(%5 : $Error): // Preds: bb0
throw %5 : $Error // id: %6
} // end sil function '$s9async_let4testyyFyyYaYbKcfU_SiyYaYbKcfu0_'
// swift_asyncLet_get_throwing
sil [available 12.0.0] @swift_asyncLet_get_throwing : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> (Builtin.RawPointer, @error Error)
// swift_asyncLet_finish
sil [available 12.0.0] @swift_asyncLet_finish : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> ()
// static Int.+ infix(_:_:)
sil public_external [transparent] @$sSi1poiyS2i_SitFZ : $@convention(method) (Int, Int, @thin Int.Type) -> Int {
// %0 // user: %3
// %1 // user: %4
bb0(%0 : $Int, %1 : $Int, %2 : $@thin Int.Type):
%3 = struct_extract %0 : $Int, #Int._value // user: %6
%4 = struct_extract %1 : $Int, #Int._value // user: %6
%5 = integer_literal $Builtin.Int1, -1 // user: %6
%6 = builtin "sadd_with_overflow_Int64"(%3 : $Builtin.Int64, %4 : $Builtin.Int64, %5 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1) // users: %8, %7
%7 = tuple_extract %6 : $(Builtin.Int64, Builtin.Int1), 0 // user: %10
%8 = tuple_extract %6 : $(Builtin.Int64, Builtin.Int1), 1 // user: %9
cond_fail %8 : $Builtin.Int1, "arithmetic overflow" // id: %9
%10 = struct $Int (%7 : $Builtin.Int64) // user: %11
return %10 : $Int // id: %11
} // end sil function '$sSi1poiyS2i_SitFZ'
// thunk for @escaping @callee_guaranteed @Sendable @async () -> (@error @owned Error)
sil shared [transparent] [reabstraction_thunk] @$ss5Error_pIeghHzo_ytsAA_pIeghHrzo_TR : $@convention(thin) @Sendable @async (@guaranteed @Sendable @async @callee_guaranteed () -> @error Error) -> (@out (), @error Error) {
// %1 // user: %2
bb0(%0 : $*(), %1 : $@Sendable @async @callee_guaranteed () -> @error Error):
try_apply %1() : $@Sendable @async @callee_guaranteed () -> @error Error, normal bb1, error bb2 // id: %2
bb1(%3 : $()): // Preds: bb0
%4 = tuple () // user: %5
return %4 : $() // id: %5
// %6 // user: %7
bb2(%6 : $Error): // Preds: bb0
throw %6 : $Error // id: %7
} // end sil function '$ss5Error_pIeghHzo_ytsAA_pIeghHrzo_TR'
// Task<>.init(priority:operation:)
sil shared_external [available 12.0.0] @$sScTss5Error_pRs_rlE8priority9operationScTyxsAA_pGScPSg_xyYaYbKcntcfC : $@convention(method) <Success, Failure where Failure == Error> (@in Optional<TaskPriority>, @owned @Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Success>, @thin Task<Success, Error>.Type) -> @owned Task<Success, Error> {
// %0 // users: %21, %4
// %1 // user: %22
bb0(%0 : $*Optional<TaskPriority>, %1 : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Success>, %2 : $@thin Task<Success, Error>.Type):
%3 = alloc_stack $Optional<TaskPriority> // users: %17, %9, %6, %5, %4
copy_addr %0 to [initialization] %3 : $*Optional<TaskPriority> // id: %4
switch_enum_addr %3 : $*Optional<TaskPriority>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb1 // id: %5
bb1: // Preds: bb0
destroy_addr %3 : $*Optional<TaskPriority> // id: %6
%7 = integer_literal $Builtin.Int64, 0 // user: %8
br bb3(%7 : $Builtin.Int64) // id: %8
bb2: // Preds: bb0
%9 = unchecked_take_enum_data_addr %3 : $*Optional<TaskPriority>, #Optional.some!enumelt // users: %12, %11
// function_ref TaskPriority.rawValue.getter
%10 = function_ref @$sScP8rawValues5UInt8Vvg : $@convention(method) (@in_guaranteed TaskPriority) -> UInt8 // user: %11
%11 = apply %10(%9) : $@convention(method) (@in_guaranteed TaskPriority) -> UInt8 // user: %13
destroy_addr %9 : $*TaskPriority // id: %12
%13 = struct_extract %11 : $UInt8, #UInt8._value // user: %14
%14 = builtin "zextOrBitCast_Int8_Int64"(%13 : $Builtin.Int8) : $Builtin.Int64 // user: %15
br bb3(%14 : $Builtin.Int64) // id: %15
// %16 // user: %19
bb3(%16 : $Builtin.Int64): // Preds: bb2 bb1
dealloc_stack %3 : $*Optional<TaskPriority> // id: %17
%18 = integer_literal $Builtin.Int64, 7168 // user: %19
%19 = builtin "or_Int64"(%16 : $Builtin.Int64, %18 : $Builtin.Int64) : $Builtin.Int64 // user: %20
%20 = struct $Int (%19 : $Builtin.Int64) // user: %25
destroy_addr %0 : $*Optional<TaskPriority> // id: %21
%22 = convert_function %1 : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Success> to $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Success> // user: %25
%23 = metatype $@thick Success.Type // user: %24
%24 = init_existential_metatype %23 : $@thick Success.Type, $@thick Any.Type // user: %25
%25 = builtin "createAsyncTask"<Success>(%20 : $Int, %24 : $@thick Any.Type, %22 : $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <Success>) : $(Builtin.NativeObject, Builtin.RawPointer) // user: %26
%26 = tuple_extract %25 : $(Builtin.NativeObject, Builtin.RawPointer), 0 // user: %27
%27 = struct $Task<Success, Error> (%26 : $Builtin.NativeObject) // user: %28
return %27 : $Task<Success, Error> // id: %28
} // end sil function '$sScTss5Error_pRs_rlE8priority9operationScTyxsAA_pGScPSg_xyYaYbKcntcfC'
// TaskPriority.rawValue.getter
sil [available 12.0.0] @$sScP8rawValues5UInt8Vvg : $@convention(method) (@in_guaranteed TaskPriority) -> UInt8
// Mappings from '#fileID' to '#filePath':
// 'async_let/async_let.swift' => 'async_let.swift'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment