You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Catfish-Man opened this issue
Dec 7, 2018
· 4 comments
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfruntimeThe Swift Runtime
Given the attached test case, I would not expect test2 to do any refcounting (and indeed, if I call it directly rather than indirecting through test3, it does not do any refcounting). SIL attached as well for convenience.
// test2<A>(_:_:)silhidden [noinline] @$S8refcount5test2ySbyXl_xtlF : $@convention(thin) <T> (@guaranteedAnyObject, @in_guaranteedT) -> Bool {
// %0 // users: %6, %4, %2bb0(%0 : $AnyObject, %1 : $*T):
debug_value %0 : $AnyObject, let, name "x", argno1// id: %2
%3 = alloc_stack$AnyObject// users: %4, %15, %7store %0to %3 : $*AnyObject// id: %4
%5 = alloc_stack$T// users: %14, %9, %7// ===> This retain is a store strong into %3 which is needed b/c $AnyObject is coming in at +0 and we are casting at +1.strong_retain %0 : $AnyObject// id: %6// ===> This either destroys %3 /or/ performs a move of %3 into %5.checked_cast_addr_brtake_alwaysAnyObjectin %3 : $*AnyObjecttoTin %5 : $*T, bb1, bb2// id: %7bb1: // Preds: bb0// ===> This is the success case, so there is a live value in %5 that we need to destroy.
%8 = integer_literal$Builtin.Int1, -1// user: %10destroy_addr %5 : $*T// id: %9brbb3(%8 : $Builtin.Int1) // id: %10bb2: // Preds: bb0// ===> This is the failure case, so the cast destroyed the value for us.
%11 = integer_literal$Builtin.Int1, 0// user: %12brbb3(%11 : $Builtin.Int1) // id: %12// %13 // user: %16bb3(%13 : $Builtin.Int1): // Preds: bb2 bb1dealloc_stack %5 : $*T// id: %14dealloc_stack %3 : $*AnyObject// id: %15
%16 = struct$Bool (%13 : $Builtin.Int1) // user: %17return %16 : $Bool// id: %17
} // end sil function '$S8refcount5test2ySbyXl_xtlF'
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfruntimeThe Swift Runtime
Attachment: Download
Additional Detail from JIRA
md5: 7dbc17c32ac03e0687b76fc3bcfdeb31
Issue Description:
Given the attached test case, I would not expect test2 to do any refcounting (and indeed, if I call it directly rather than indirecting through test3, it does not do any refcounting). SIL attached as well for convenience.
refcount.sil
main.swift
The text was updated successfully, but these errors were encountered: