Commit 98e9096c authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

When specialising recursive functions, mark the specialised function NOINLINE

This fixes Trac #4903.  See Note [Specialising imported functions] in OccurAnal.
parent e815d4b1
......@@ -517,8 +517,11 @@ dsSpec mb_poly_rhs (L loc (SpecPrag poly_id spec_co spec_inl))
; let spec_id = mkLocalId spec_name spec_ty
`setInlinePragma` inl_prag
`setIdUnfolding` spec_unf
inl_prag | isDefaultInlinePragma spec_inl = idInlinePragma poly_id
| otherwise = spec_inl
inl_prag | not (isDefaultInlinePragma spec_inl) = spec_inl
| not is_local_id -- See Note [Specialising imported functions]
-- in OccurAnal
, isStrongLoopBreaker (idOccInfo poly_id) = neverInlinePragma
| otherwise = idInlinePragma poly_id
-- Get the INLINE pragma from SPECIALISE declaration, or,
-- failing that, from the original Id
......
......@@ -1138,6 +1138,9 @@ specCalls subst rules_for_me calls_for_me fn rhs
-- Add a suitable unfolding if the spec_inl_prag says so
-- See Note [Inline specialisations]
spec_inl_prag
| not is_local && isStrongLoopBreaker (idOccInfo fn)
= neverInlinePragma -- See Note [Specialising imported functions] in OccurAnal
| otherwise
= case inl_prag of
InlinePragma { inl_inline = Inlinable }
-> inl_prag { inl_inline = EmptyInlineSpec }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment