panic when compiling SHA

Adam Wick awick at galois.com
Mon Jan 6 22:26:38 UTC 2014


On Jan 6, 2014, at 12:20 AM, Ben Lippmeier <benl at ouroborus.net> wrote:
> On 06/01/2014, at 14:08 , Kazu Yamamoto (山本和彦) <kazu at iij.ad.jp> wrote:
>> Ben,
>> 
>>> Note that removing the flag isn't a "solution" to the underlying
>>> problem of the intermediate code being awful. Switching to the
>>> linear allocator just permits compilation of core code that was
>>> worse than before. Now it needs to spill more registers when
>>> compiling the same source code.
>> 
>> So, would you reopen #5361 by yourself?
>> 
>> 	https://ghc.haskell.org/trac/ghc/ticket/5361
> 
> Not if we just have this one test. I'd be keen to blame excessive use of inline pragmas in the SHA library itself, or excessive optimisation flags. It's not really a bug in GHC until there are two tests that exhibit the same problem.


The SHA library uses SPECIALIZE, INLINE, and bang patterns in fairly standard ways. There’s nothing too exotic in there, I just basically sprinkled hints in places I thought would be useful, and then backed those up with benchmarking.

If GHC simply emitted rotten code in this case, I’d agree: wait for more examples, and put the onus on the developer to make it work better. However, right now, GHC crashes on valid input. Which is a bug. So I’d argue that the ticket should be re-opened. I suppose, alternatively, the documentation on SPECIALIZE, INLINE, and bang patterns could be changed to note that using them is not officially supported.

If the problem is pretty fundamental, then perhaps instead of panicking and dying, GHC should instead default back to a worse register allocator. Perhaps it could print a warning when that happens, but that’s optional. That would be an easier way to fix this bug if there are deeper algorithmic problems, or if fixing it for SHA would simply move the failure line a little further down the field. (Obviously this route opens a performance regression on my end, but hey, that’s my problem.)


- Adam
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2199 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20140106/ffb91b5e/attachment-0001.bin>


More information about the ghc-devs mailing list