regression: out of memory with -O2 -ddump-hi on a complex INLINE function
Summary:
Unlike GHC 7.10.2, when GHC 8.0.1 tries to compile a certain complex INLINE function with -O2 -ddump-hi, it runs out of memory. Dropping either -O2 or -ddump-hi enables successful compilation.
Oddly enough, triggering the issue requires using the function argument indirectly through a variable bound by a "where" clause, even though it is obvious to a human reader that the indirection is trivial.
(Even after simplifying the original code to work around the out of memory issue, that indirection greatly increases the size of the ".dump-hi" file. It might be that the "out of memory" would not happen if one had sufficient RAM.)
Using INLINABLE instead of INLINE seems to result in a much smaller RHS being recorded for the function in question, and does not trigger the problem. (Perhaps INLINABLE records a more optimized RHS than does INLINE, though that is not obvious to me from the GHC User's Guide.)
The attached files contain a reduced version of the original code that still triggers the problem. (Of course, the reduced version is rather artificial and pointless, other than to demonstrate the problem.) Probably someone with sufficient understanding could shrink the example further.
Please note that I have worked around the issue, and so I am not blocked by this problem, at least not currently.
Attachments:
-
crash.bash
-
Crash.hs
Observed behavior:
On 64-bit x86 Ubuntu 16.04 LTS, with the attached files in the current directory, GHC 7.10.2 succeeds:
$ ./crash.bash
The Glorious Glasgow Haskell Compilation System, version 7.10.2
[1 of 1] Compiling Crash ( Crash.hs, Crash.o )
whereas GHC 8.0.1 runs out of memory (or wedges my system if I comment out both "ulimit" commands in the script):
$ ./crash.bash
The Glorious Glasgow Haskell Compilation System, version 8.0.1
[1 of 1] Compiling Crash ( Crash.hs, Crash.o )
ghc: out of memory
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (CodeGen) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |