Wired-in data-constructors with UNPACKed fields
Herbert Valerio Riedel
hvriedel at gmail.com
Tue Aug 19 09:23:46 UTC 2014
Hello Simon,
On 2014-08-19 at 00:01:17 +0200, Simon Peyton Jones wrote:
[...]
> But you can probably write the code in such a way as to be mostly
> independent (eg explicit UNPACK rather than rely on
> -funbox-strict-fields), or assume that some things won't happen
> (e.g. souce module will not be compiled with
> -fomit-interface-pragmas). See MkId.mkDataConRep.
I was under the impression that even -O0 vs -O1+ makes a huge
difference:
As given the following program,
{-# LANGUAGE MagicHash #-}
module M where
import GHC.Exts
data T0 = C0 ByteArray#
data T1 = C1 {-# UNPACK #-} !T0
| C2 {-# UNPACK #-} !Int
| C3 !Int
| C4 Int
compilation with
$ ../inplace/bin/ghc-stage2 -fforce-recomp -ddump-types -O1 -c M.hs
TYPE SIGNATURES
TYPE CONSTRUCTORS
data T0 = C0 ByteArray#
data T1
= C1 {-# UNPACK #-}T0
| C2 {-# UNPACK #-}Int
| C3 {-# UNPACK #-}Int
| C4 Int
COERCION AXIOMS
Dependent modules: []
Dependent packages: [base, ghc-prim, integer-gmp2]
has everything but C4 unpacked as expected, but when using -O0, nothing
is UNPACKed at all:
$ ../inplace/bin/ghc-stage2 -fforce-recomp -ddump-types -O0 -c M.hs
TYPE SIGNATURES
TYPE CONSTRUCTORS
data T0 = C0 ByteArray#
data T1 = C1 !T0 | C2 !Int | C3 !Int | C4 Int
COERCION AXIOMS
Dependent modules: []
Dependent packages: [base, ghc-prim, integer-gmp2]
...am I interpreting the output `-ddump-types` incorrectly?
PS: adding a '!' in front of the 'ByteArray#' field in `T0` is not
supposed to have any effect on primitive types, is it? If so, should
GHC warn about the redundant '!'?
Cheers,
hvr
More information about the ghc-devs
mailing list