[Git][ghc/ghc][master] User guide: Clarify phase control on INLINEABLE[foo] pragmas.
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d3690ae8 by Andreas Klebinger at 2026-03-11T15:04:31-04:00 User guide: Clarify phase control on INLINEABLE[foo] pragmas. Fixes #26851 - - - - - 2 changed files: - docs/users_guide/exts/pragmas.rst - docs/users_guide/exts/rewrite_rules.rst Changes: ===================================== docs/users_guide/exts/pragmas.rst ===================================== @@ -570,6 +570,12 @@ optionally specify a phase number, thus: - "``NOINLINE[~k] f``" means: be willing to inline ``f`` until phase ``k``, but from phase ``k`` onwards do not inline it. +- "``INLINEABLE[k] f``" means: do not inline ``f`` until phase ``k``, but + from phase ``k`` onwards GHC is free to inline it. + +- "``INLINEABLE[~k] f``" means: GHC is free to inline ``f`` until phase + ``k``, but from phase ``k`` onwards do not inline it. + The same information is summarised here: .. code-block:: none @@ -579,6 +585,8 @@ The same information is summarised here: {-# INLINE [~2] f #-} -- Yes No {-# NOINLINE [2] f #-} -- No Maybe {-# NOINLINE [~2] f #-} -- Maybe No + {-# INLINEABLE [2] f #-} -- No Maybe + {-# INLINEABLE [~2] f #-} -- Maybe No {-# INLINE f #-} -- Yes Yes {-# NOINLINE f #-} -- No No ===================================== docs/users_guide/exts/rewrite_rules.rst ===================================== @@ -293,6 +293,16 @@ its :pragma:`RULES` have had a chance to fire. The warning flag :ghc-flag:`-Winline-rule-shadowing` (see :ref:`options-sanity`) warns about this situation. +All of this applies similarly to :pragma:`INLINABLE` (also accepted as +``INLINABLE``; see :ref:`inline-noinline-pragma`). As with +the other pragmas, you can use explicit :ref:`phase-control` to delay +inlining so that a :pragma:`RULES` rewrite has an opportunity to match first. + +The key difference from :pragma:`INLINE` (see :ref:`inline-pragma`) is that +:pragma:`INLINABLE` does not guarantee inlining, leaving the inlining decision +to GHC's usual heuristics. Use :pragma:`INLINE` when your RULE setup relies +on inlining happening reliably, and :pragma:`INLINABLE` otherwise. + .. _conlike: How rules interact with ``CONLIKE`` pragmas @@ -528,4 +538,3 @@ Controlling what's going on in rewrite rules see how to write rules that will do fusion and yet give an efficient program even if fusion doesn't happen. More rules in ``GHC/List.hs``. - View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d3690ae808d75f63a2f682bb44a7af87... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d3690ae808d75f63a2f682bb44a7af87... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)