Commits

Arnold Schwaighofer committed bdaea9be273
Add Builtin.unsafeGuaranteed and Builtin.unsafeGuaranteedEnd These builtins can be used to denote a scope over which the parameter passed to unsafeGuaranteed can be assume to be @guaranteed: That is there is another reference that keeps the value alive. // Scope begin strong_retain %0 : $Foo %2 = builtin "unsafeGuaranteed"<Foo>(%0 : $Foo) : $(Foo, Builtin.Int8) %3 = tuple_extract %2 : $(Foo, Builtin.Int8), 0 %4 = tuple_extract %2 : $(Foo, Builtin.Int8), 1 %5 = class_method %3 : $Foo, #Foo.beep!1 : (Foo) -> () -> () %6 = apply %5(%3) : $@convention(method) (@guaranteed Foo) -> () strong_release %3 : $Foo %8 = builtin "unsafeGuaranteedEnd"(%4 : $Builtin.Int8) : $( // Scope end is semantically equivalent to: sil @guaranteed_lifetime : $@convention(method) (@guaranteed Foo) -> () { bb(%3: $Foo): %5 = class_method %3 : $Foo, #Foo.beep!1 : (Foo) -> () -> () %6 = apply %5(%3) : $@convention(method) (@guaranteed Foo) -> () } ... // Scope begin apply @guaranteed_lifetime(%0) // Scope end