<div dir="ltr"><div>Hi Christiaan,</div><div><br></div><div>Wow, the whole OPAQUE pragma proposal and implementation completely slipped my attention.</div><div>I left a comment on the proposal about GHC.Exts.{lazy,noinline}.</div><div><br></div><div>Regarding the reboxing problem: You might want to wait for <a href="https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5790">!5790</a>, which represents boxity explicitly in the demand lattice, allowing you to get rid of all boxity info in the demand signature of an OPAQUE function around the call to `mkDmdTypeForArity`.</div><div>In the meantime, your best bet is to get rid of any strict product demands in the demand signature, which at the moment says "unbox this thing, because it is used unboxed".</div><div><br></div><div>Either way, you shouldn't even need to touch WW if you simply degrade the (demand and CPR) signatures in that way, and it's more compositional, too, because the analysis is able to propagate the "don't unbox" info to callers, whereas it's too late to have non-local impact on callers of the OPAQUE function when WW runs.</div><div><br></div><div>I enabled notifications for !5562, so feel free to continue the discussion there.</div><div><br></div><div>Sebastian<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Am Do., 24. Juni 2021 um 11:57 Uhr schrieb Christiaan Baaij <<a href="mailto:christiaan.baaij@gmail.com">christiaan.baaij@gmail.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi Ghc-Devs,</div><div><br></div><div>I believe I've mostly finished the implementation of GHC proposal 0415 [1], the OPAQUE pragma, over at: <a href="https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5562" target="_blank">https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5562</a></div><div><br></div><div>The only remaining issue is that I'm unsure whether there's a way to prevent reboxing of worker arguments as witnessed here: <a href="https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5562/diffs#29ad02619a9f318d67c6cd19648917dbb17354e9_0_134" target="_blank">https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5562/diffs#29ad02619a9f318d67c6cd19648917dbb17354e9_0_134</a></div><div><br></div><div>Note that the reboxing doesn't happen in the worker of the OPAQUE-annotated bindings, because OPAQUE-annotated bindings aren't W/W-transformed, but in a worker of a function that calls the OPAQUE-annotated binding.<br></div><div>This reboxing was the reason behind the descision to W/W transform NOINLINE-annotated bindings in: <a href="https://gitlab.haskell.org/ghc/ghc/-/commit/b572aadb20c2e41e2f6d7b48401bd0b4239ce9f8" target="_blank">https://gitlab.haskell.org/ghc/ghc/-/commit/b572aadb20c2e41e2f6d7b48401bd0b4239ce9f8</a></div><div><br></div><div>But the whole idea behind OPAQUE is not to change calls to the annotated binding f by some call of a name-mangled version of f; so W/W transforming OPAQUE-annoted binders is not an option.<br></div><div><br></div><div>Any hints on how to avoid the reboxing (if possible) would be appreciated, like:</div><div>* Do I need to change something in GHC.Core.Opt.WorkWrap? or</div><div>* Do I need to change the demand/strictness signature of OPAQUE-annoted bindings?</div><div>* or something else?</div><div><br></div><div>Thanks,</div><div><br></div><div>Christiaan<br></div><div><br></div><div>[1] <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0415-opaque-pragma.rst" target="_blank">https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0415-opaque-pragma.rst</a></div></div>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div>