When specialising recursive functions, mark the specialised function NOINLINE
authorSimon Peyton Jones <simonpj@microsoft.com>
Thu, 21 Jul 2011 11:45:51 +0000 (12:45 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Thu, 21 Jul 2011 11:45:51 +0000 (12:45 +0100)
This fixes Trac #4903.  See Note [Specialising imported functions] in OccurAnal.

compiler/deSugar/DsBinds.lhs
compiler/specialise/Specialise.lhs

index 39e7e29..a878e74 100644 (file)
@@ -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
 
index c192b3f..7cd4934 100644 (file)
@@ -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 }