[Git][ghc/ghc][wip/T16740] PrelRules: Ensure that string unpack/append rule fires with source notes
Ben Gamari
gitlab at gitlab.haskell.org
Wed Jun 5 12:07:05 UTC 2019
Ben Gamari pushed to branch wip/T16740 at Glasgow Haskell Compiler / GHC
Commits:
3b3d5716 by Ben Gamari at 2019-06-05T12:06:56Z
PrelRules: Ensure that string unpack/append rule fires with source notes
Previously the precence of source notes could hide nested applications
of `unpackFoldrCString#` from our constant folding logic. This caused
the `str_rules` testcase to fail when `base` was built with `-g3`.
Fixes #16740.
- - - - -
1 changed file:
- compiler/prelude/PrelRules.hs
Changes:
=====================================
compiler/prelude/PrelRules.hs
=====================================
@@ -41,7 +41,7 @@ import TyCon ( tyConDataCons_maybe, isAlgTyCon, isEnumerationTyCon
, isNewTyCon, unwrapNewTyCon_maybe, tyConDataCons
, tyConFamilySize )
import DataCon ( dataConTagZ, dataConTyCon, dataConWorkId )
-import CoreUtils ( cheapEqExpr, exprIsHNF, exprType )
+import CoreUtils ( cheapEqExpr, exprIsHNF, exprType, stripTicksTopE, mkTicks )
import CoreUnfold ( exprIsConApp_maybe )
import Type
import OccName ( occNameFS )
@@ -1368,20 +1368,24 @@ match_append_lit _ id_unf _
[ Type ty1
, lit1
, c1
- , Var unpk `App` Type ty2
- `App` lit2
- `App` c2
- `App` n
+ , e2
]
- | unpk `hasKey` unpackCStringFoldrIdKey &&
- c1 `cheapEqExpr` c2
+ -- N.B. Ensure that we strip off any ticks (e.g. source notes) from the argument, lest
+ -- this may fail to fire when building with -g3. See #16740.
+ | (strTicks, Var unpk `App` Type ty2
+ `App` lit2
+ `App` c2
+ `App` n) <- stripTicksTopE tickishFloatable e2
+ , unpk `hasKey` unpackCStringFoldrIdKey
+ , c1 `cheapEqExpr` c2
, Just (LitString s1) <- exprIsLiteral_maybe id_unf lit1
, Just (LitString s2) <- exprIsLiteral_maybe id_unf lit2
= ASSERT( ty1 `eqType` ty2 )
- Just (Var unpk `App` Type ty1
- `App` Lit (LitString (s1 `BS.append` s2))
- `App` c1
- `App` n)
+ Just $ mkTicks strTicks
+ $ Var unpk `App` Type ty1
+ `App` Lit (LitString (s1 `BS.append` s2))
+ `App` c1
+ `App` n
match_append_lit _ _ _ _ = Nothing
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/3b3d5716870d023e3df46e59e3f080ee1e035906
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/3b3d5716870d023e3df46e59e3f080ee1e035906
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/20190605/b97d6ddd/attachment-0001.html>
More information about the ghc-commits
mailing list