summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-05-09 18:17:39 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-05-28 16:23:21 -0400
commit28deee2872d2501a781ae5b89f1db3dbf796ee74 (patch)
tree2e3fa197406e0816427d9c714ab1300b757ed990
parentd6203f24cf421749616a247c047a9b44192f963a (diff)
downloadhaskell-28deee2872d2501a781ae5b89f1db3dbf796ee74.tar.gz
GHC.Core.Unfold: Refactor traceInline
This reduces duplication as well as fixes a bug wherein -dinlining-check would override -ddump-inlinings. Moreover, the new variant
-rw-r--r--compiler/GHC/Core/Unfold.hs19
1 files changed, 10 insertions, 9 deletions
diff --git a/compiler/GHC/Core/Unfold.hs b/compiler/GHC/Core/Unfold.hs
index 78cda980cc..0c0b1d8116 100644
--- a/compiler/GHC/Core/Unfold.hs
+++ b/compiler/GHC/Core/Unfold.hs
@@ -1277,16 +1277,17 @@ callSiteInline dflags id active_unfolding lone_variable arg_infos cont_info
OtherCon {} -> Nothing
DFunUnfolding {} -> Nothing -- Never unfold a DFun
+-- | Report the inlining of an identifier's RHS to the user, if requested.
traceInline :: DynFlags -> Id -> String -> SDoc -> a -> a
-traceInline dflags inline_id str doc result
- | Just prefix <- inlineCheck dflags
- = if prefix `isPrefixOf` occNameString (getOccName inline_id)
- then traceAction dflags str doc result
- else result
- | dopt Opt_D_dump_inlinings dflags && dopt Opt_D_verbose_core2core dflags
- = traceAction dflags str doc result
- | otherwise
- = result
+traceInline dflags inline_id str doc result =
+ | enable = traceAction dflags str doc result
+ | otherwise = result
+ where
+ enable
+ | dopt Opt_D_dump_inlinings dflags && dopt Opt_D_verbose_core2core dflags
+ = True
+ | Just prefix <- inlineCheck dflags
+ = prefix `isPrefixOf` occNameString (getOccName inline_id)
tryUnfolding :: DynFlags -> Id -> Bool -> [ArgSummary] -> CallCtxt
-> CoreExpr -> Bool -> Bool -> UnfoldingGuidance