summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-05-09 18:17:39 -0400
committerBen Gamari <ben@smart-cactus.org>2020-05-09 18:38:46 -0400
commitfdcb8f736e45cdebb8cef2e8675d547263529004 (patch)
tree3914b1f9b4cad3ef99cb7664cfd5915df432498a
parent86c77b36628dcce7bc9b066fc24c8c521fecc3ee (diff)
downloadhaskell-fdcb8f736e45cdebb8cef2e8675d547263529004.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 42a8974b54..369f3282fd 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