summaryrefslogtreecommitdiff
path: root/compiler/coreSyn
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/coreSyn')
-rw-r--r--compiler/coreSyn/CoreSyn.hs2
-rw-r--r--compiler/coreSyn/CoreUtils.hs5
2 files changed, 7 insertions, 0 deletions
diff --git a/compiler/coreSyn/CoreSyn.hs b/compiler/coreSyn/CoreSyn.hs
index 27a4c99539..68bf676fb1 100644
--- a/compiler/coreSyn/CoreSyn.hs
+++ b/compiler/coreSyn/CoreSyn.hs
@@ -405,6 +405,8 @@ It is important to note that top-level primitive string literals cannot be
wrapped in Ticks, as is otherwise done with lifted bindings. CoreToStg expects
to see just a plain (Lit (MachStr ...)) expression on the RHS of primitive
string bindings; anything else and things break. CoreLint checks this invariant.
+To ensure that ticks don't sneak in CoreUtils.mkTick refuses to wrap any
+primitve string expression with a tick.
Also see Note [Compilation plan for top-level string literals].
diff --git a/compiler/coreSyn/CoreUtils.hs b/compiler/coreSyn/CoreUtils.hs
index 3d5f4bcb5a..ca67e24ca3 100644
--- a/compiler/coreSyn/CoreUtils.hs
+++ b/compiler/coreSyn/CoreUtils.hs
@@ -305,6 +305,11 @@ mkTick t orig_expr = mkTick' id id orig_expr
-> CoreExpr
mkTick' top rest expr = case expr of
+ -- Never tick primitive string literals. These should ultimately float up to
+ -- the top-level where they must be unadorned. See Note
+ -- [CoreSyn top-level string literals] for details.
+ _ | exprIsLiteralString expr -> expr
+
-- Cost centre ticks should never be reordered relative to each
-- other. Therefore we can stop whenever two collide.
Tick t2 e