DataCon wrappers get in the way of rules
This is a spin-off of #12618##12689:
Simon writes there:
Actually this is already a problem today. It's just rendered more prominent now that even (:) has a wrapper. Consider
data T = MkT {-# UNPACK #-} !Int
{-# RULES
"fT" f MkT = True
"gT" forall x. g (MkT x) = x
#-}
f :: (Int -> T) -> Bool
{-# NOINLINE f #-}
f x = True
g :: T -> Int
{-# NOINLINE g #-}
g (MkT x) = x+1
yields
Foo.hs:9:1: warning: [-Winline-rule-shadowing]
Rule "fT" may never fire because 'Foo.$WMkT' might inline first
Probable fix: add an INLINE[n] or NOINLINE[n] pragma for 'Foo.$WMkT'
Foo.hs:10:1: warning: [-Winline-rule-shadowing]
Rule "gT" may never fire because 'Foo.$WMkT' might inline first
Probable fix: add an INLINE[n] or NOINLINE[n] pragma for 'Foo.$WMkT'
What to do? If we are to match these rules, we really must delay inlining the wrapper for MkT (after inlining we get a mess of unboxing etc). So either we must allow you to add a NOINLINE pragma to MkT; or we must add one automatically (e.g. NOINLINE [1]).
Delaying all consructor-wrapper inlining to phase 1 is potentially quite drastic, because case-of-known-constructor wouldn't happen until the wrappers are inlined. Maybe that's ok; I'm not sure. Worth trying I think.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |