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
Our activity analysis is just plain wrong for class arguments. In particular, the usefullness analysis is not quite prepared for such values. Currently the inouts are treated in such a way, that the argument is marked as a result and usefullness is propagated backwards from results to instruction operands. This works for usual inouts and even for struct self arguments simply because there is a "last store" to inout argument that allows usefulness to propagate back. This is not quite so in case of classes. And it could be seen even in a simple case with just plain setter call:
@_silgen_name("inout_setting")func inoutSetting(_ c:inoutClass, x :Float){
c.x = x
}func foo(_ x:Float)->Float{varc=Class(x)inoutSetting(&c, x: x)return c.x
}
yeilds:
[AD] Activity info for inout_setting at parameter indices (0, 1) and result indices (0):
bb0:
[ACTIVE] %0 = argument of bb0 : $*Class // users: %4, %2
[VARIED] %1 = argument of bb0 : $Float // users: %8, %3
[ACTIVE] %4 = begin_access [read] [static] %0 : $*Class // users: %6, %5
[VARIED] %5 = load [copy] %4 : $*Class // users: %9, %8, %7
[VARIED] %7 = class_method %5 : $Class, #Class.x!setter : (Class) -> (Float) -> (), $@convention(method) (Float, @guaranteed Class) -> () // user: %8
[NONE] %8 = apply %7(%1, %5) : $@convention(method) (Float, @guaranteed Class) -> ()
[NONE] %10 = tuple () // user: %11
End activity info for inout_setting
There is a special case in usefullness calculation (propagateUsefulThroughAddress) that makes %4 active here (essentially for addresses and class-valued arguments we propagate useful similar to how we're propagating varied – looking into users, but this is only done for projections, this is why %5 is not marked as active here).
Additional Detail from JIRA
md5: 52c4e7292d358396a625c0c7b20dc52c
Parent-Task:
_read
and_modify
accessor differentiationIssue Description:
The issue is in
inoutMutating
, which callsClass.x.modify
. The modify accessor application is not active:The text was updated successfully, but these errors were encountered: