categorifier icon indicating copy to clipboard operation
categorifier copied to clipboard

Perform Prim.checkForUnboxedVars only when appropriate

Open zliu41 opened this issue 3 years ago • 0 comments

This happened way back is no longer reproducible, but this is what happened back then:


[Ziyang Liu] [Jan 15th, 2021 at 1:57 PM] I think I found the cause of the "unexpected Word#" error in Biquad. Fortunately it seems to be fixable

[Ziyang Liu] [1 year ago] When biquad2T is inlined, clampMaybe has not yet been inlined (possibly because it is in a different module; if I move clampMaybe to the same module then the error goes away), and as a result, its Typeable (Native Bool) instance becomes

case $tcBool of { TyCon ww1 ww2 ww3 ww4 ww5 ww6 ->
             case $wmkTrCon ww1 ww2 ww3 ww4 ww5 ww6 [] of
             { (# ww8, ww9, ww10, ww11, ww12 #) ->
             (mkTrApp $dTypeable_slKI (TrTyCon ww8 ww9 ww10 ww11 ww12))
             `cast` <Co:6>
             }

Those wws are primitive variables, and can't be eliminated by replacePrimOps.

[Ziyang Liu] [1 year ago] So, I guess the simpliest (but not necessarily desirable) solution is to just ignore that error, because things will be OK once clampMaybe is inlined

[Ziyang Liu] [1 year ago] I just added a FIXME for now Rather than simply disabling checkForUnboxedVars altogether, a potentially better approach is to only ignore primitives in arguments to a not-yet-inlined function.

(Extricated from https://kitty-hawk.atlassian.net/browse/SW-3416)

zliu41 avatar Feb 24 '22 00:02 zliu41