[Git][ghc/ghc][wip/T24359] Add no-op warning

Simon Peyton Jones (@simonpj) gitlab at gitlab.haskell.org
Tue Nov 26 17:41:45 UTC 2024



Simon Peyton Jones pushed to branch wip/T24359 at Glasgow Haskell Compiler / GHC


Commits:
718eb687 by Simon Peyton Jones at 2024-11-26T17:40:12+00:00
Add no-op warning

- - - - -


1 changed file:

- compiler/GHC/HsToCore/Binds.hs


Changes:

=====================================
compiler/GHC/HsToCore/Binds.hs
=====================================
@@ -926,6 +926,10 @@ finishSpecPrag poly_rhs rule_bndrs poly_id rule_args
        ; return Nothing  }  -- Function is NOINLINE, and the specialisation inherits that
                             -- See Note [Activation pragmas for SPECIALISE]
 
+  | all is_nop_arg rule_args
+  = do { diagnosticDs (DsUselessSpecialiseForNoInlineFunction poly_id)
+       ; return Nothing  }  -- Specialisation does nothing
+
   | otherwise
   -- The RULE looks like
   --    RULE "USPEC" forall rule_bndrs. f rule_args = $sf spec_bndrs
@@ -981,6 +985,13 @@ finishSpecPrag poly_rhs rule_bndrs poly_id rule_args
     rule_act | no_act_spec = inl_prag_act    -- Inherit
              | otherwise   = spec_prag_act   -- Specified by user
 
+    is_nop_arg (Type {})     = True
+    is_nop_arg (Coercion {}) = True
+    is_nop_arg (Cast e _)    = is_nop_arg e
+    is_nop_arg (Tick _ e)    = is_nop_arg e
+    is_nop_arg (Var x)       = x `elem` spec_bndrs
+    is_nop_arg _             = False
+
 specFunInlinePrag :: Id -> InlinePragma
                   -> InlinePragma -> InlinePragma
 -- See Note [Activation pragmas for SPECIALISE]



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/718eb6876511a9aa2262ce897f562b5642975e1a

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/718eb6876511a9aa2262ce897f562b5642975e1a
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20241126/007ce57f/attachment-0001.html>


More information about the ghc-commits mailing list