'GHC.Magic.noinline <var>' should not float out
While working on #15155 (closed), I discovered that the magic function GHC.Magic.noinline
tricked the float-out transformation into performing undesirable operations:
Looking at the Core produced:
{ ghc-prim-0.5.3:GHC.Types.I# x_azMX [Dmd=<S,U>] ->
case x_azMX of {
__DEFAULT -> jump $j_sMly;
3674937295934324920# ->
src<compiler/typecheck/TcTyClsDecls.hs:3561:9-35>
check_ty_roles_sLb3
(src<compiler/typecheck/TcTyClsDecls.hs:3561:24-26> env_aqfK)
(src<compiler/typecheck/TcTyClsDecls.hs:3561:28-31> role_aqfL)
(ghc-prim-0.5.3:GHC.Magic.noinline @ Kind liftedTypeKind)
}
}
After simplification we end up with a toplevel variable basically redirecting to an imported variable.
-- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0}
lvl330_r12qn :: Kind
[GblId]
lvl330_r12qn
= ghc-prim-0.5.3:GHC.Magic.noinline @ Kind liftedTypeKind
This would cause IND_STATIC
s when eventually emitted as assembly.
IIRC GHC.Magic.noinline
was introduced with GHC v8.2. This probably regressed the float-out optimisation.
I have a patch to reclassify noinline <some-var>
as cheap, so that it won't be floated out.
N.B.: for more details, see: https://github.com/ghc/ghc/pull/224
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |