diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2017-03-19 11:53:01 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-02-04 00:02:33 -0500 |
commit | 260f547fda14842b8891f365e3dba3ba234b6edc (patch) | |
tree | 70eeab91a05e9f4d97a54821452f2da9ddda4cac /compiler/simplCore/FloatOut.hs | |
parent | 1b442ed42b875cfc0b75ff0e8e431e671be071f8 (diff) | |
download | haskell-wip/libdw-prof.tar.gz |
Never tick primitive string literalswip/libdw-prof
This is a more aggressive approach to the problem initially solved in
f5b275a239d2554c4da0b7621211642bf3b10650, where top-level primitive string
literals were being wrapped by ticks. This breaks the Core invariant descirbed
in Note [CoreSyn top-level string literals]. However, the previous approach was
incomplete and left several places where inappropriate ticks could sneak in.
This commit kills the problem at the source: we simply never tick any primitive
string literal expression. The assumption here is that these expressions are
destined for the top-level, where they cannot be ticked, anyways. So even if
they haven't been floated out yet there is no reason to tick them.
This partially reverts commit f5b275a239d2554c4da0b7621211642bf3b10650.
Test Plan: Validate with `-g`
Reviewers: austin, scpmw, simonpj, simonmar, dfeuer
Subscribers: dfeuer, simonmar, thomie
Differential Revision: https://phabricator.haskell.org/D3063
Diffstat (limited to 'compiler/simplCore/FloatOut.hs')
-rw-r--r-- | compiler/simplCore/FloatOut.hs | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/compiler/simplCore/FloatOut.hs b/compiler/simplCore/FloatOut.hs index a8223b47b9..25a4e53a77 100644 --- a/compiler/simplCore/FloatOut.hs +++ b/compiler/simplCore/FloatOut.hs @@ -23,7 +23,7 @@ import DynFlags import ErrUtils ( dumpIfSet_dyn ) import Id ( Id, idArity, idType, isBottomingId, isJoinId, isJoinId_maybe ) -import BasicTypes ( TopLevelFlag(..), isTopLevel ) +import Var ( Var ) import SetLevels import UniqSupply ( UniqSupply ) import Bag @@ -737,26 +737,19 @@ atJoinCeiling (fs, floats, expr') wrapTick :: Tickish Id -> FloatBinds -> FloatBinds wrapTick t (FB tops ceils defns) - = FB (mapBag (wrap_bind TopLevel) tops) - (wrap_defns NotTopLevel ceils) - (M.map (M.map (wrap_defns NotTopLevel)) defns) + = FB (mapBag wrap_bind tops) (wrap_defns ceils) + (M.map (M.map wrap_defns) defns) where - wrap_defns toplvl = mapBag (wrap_one toplvl) - - wrap_bind toplvl (NonRec binder rhs) = NonRec binder (maybe_tick toplvl rhs) - wrap_bind toplvl (Rec pairs) = Rec (mapSnd (maybe_tick toplvl) pairs) - - wrap_one toplvl (FloatLet bind) = FloatLet (wrap_bind toplvl bind) - wrap_one toplvl (FloatCase e b c bs) = FloatCase (maybe_tick toplvl e) b c bs - - maybe_tick :: TopLevelFlag -> CoreExpr -> CoreExpr - maybe_tick toplvl e - -- We must take care not to tick top-level literal - -- strings as this violated the Core invariants. See Note [CoreSyn - -- top-level string literals]. - | isTopLevel toplvl && exprIsLiteralString e = e - | exprIsHNF e = tickHNFArgs t e - | otherwise = mkTick t e + wrap_defns = mapBag wrap_one + + wrap_bind (NonRec binder rhs) = NonRec binder (maybe_tick rhs) + wrap_bind (Rec pairs) = Rec (mapSnd maybe_tick pairs) + + wrap_one (FloatLet bind) = FloatLet (wrap_bind bind) + wrap_one (FloatCase e b c bs) = FloatCase (maybe_tick e) b c bs + + maybe_tick e | exprIsHNF e = tickHNFArgs t e + | otherwise = mkTick t e -- we don't need to wrap a tick around an HNF when we float it -- outside a tick: that is an invariant of the tick semantics -- Conversely, inlining of HNFs inside an SCC is allowed, and |