INLINE breaks rewrite rules when '-g' is used
The bug is found when building conduit-1.2.4.2 package with '-O2 -g' options. The distilled sample looks like that:
{-# LANGUAGE BangPatterns #-}
module RewriteBug (bug) where
bug :: () -> ()
bug () = bug ()
{-# NOINLINE bug #-}
a2 :: ()
a2 = ()
{-# INLINE[1] a2 #-}
{-# RULES "bug a2" [0] bug a2 = () #-}
{-
Crashes as:
$ inplace/bin/ghc-stage2 -c -O1 -fforce-recomp RewriteBug.hs -g
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 7.11.20150721 for x86_64-unknown-linux):
Tick in rule ()
-}
My theory of sequence of actions is the following:
- rewrite rule gets read as-is by GHC (gentle phase)
- a2 INLINE changes LHS of rewrite rule (phase 1)
- when time comes to apply 'bug a2' rule GHC detects INLINE problem (phase 0)
In real code it happened across multiple files.
The bug is reproducible in both ghc-7.10.2-rc2 and today's HEAD.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.10.2-rc2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (CodeGen) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | scpmw, simonpj |
| Operating system | |
| Architecture |