From 5b7c931a5d2fba99d30873b458ec6686e59c07bf Mon Sep 17 00:00:00 2001 From: simonpj Date: Thu, 20 Feb 2003 13:00:25 +0000 Subject: [PATCH] [project @ 2003-02-20 13:00:24 by simonpj] Eliminate bogus string-literal duplication --- ghc/compiler/basicTypes/Literal.lhs | 15 ++++++++++++--- ghc/compiler/coreSyn/CoreUtils.lhs | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ghc/compiler/basicTypes/Literal.lhs b/ghc/compiler/basicTypes/Literal.lhs index f2d09f3..b8e28d8 100644 --- a/ghc/compiler/basicTypes/Literal.lhs +++ b/ghc/compiler/basicTypes/Literal.lhs @@ -8,7 +8,8 @@ module Literal ( Literal(..) -- Exported to ParseIface , mkMachInt, mkMachWord , mkMachInt64, mkMachWord64 - , isLitLitLit, maybeLitLit, litSize, litIsDupable, + , isLitLitLit, maybeLitLit, litSize + , litIsDupable, litIsTrivial , literalType, literalPrimRep , hashLiteral @@ -282,9 +283,17 @@ isLitLitLit _ = False maybeLitLit (MachLitLit s t) = Just (s,t) maybeLitLit _ = Nothing +litIsTrivial :: Literal -> Bool +-- True if there is absolutely no penalty to duplicating the literal +-- c.f. CoreUtils.exprIsTrivial +-- False principally of strings +litIsTrivial (MachStr _) = False +litIsTrivial other = True + litIsDupable :: Literal -> Bool - -- True if code space does not go bad if we duplicate this literal - -- False principally of strings +-- True if code space does not go bad if we duplicate this literal +-- c.f. CoreUtils.exprIsDupable +-- Currently we treat it just like litIsTrivial litIsDupable (MachStr _) = False litIsDupable other = True diff --git a/ghc/compiler/coreSyn/CoreUtils.lhs b/ghc/compiler/coreSyn/CoreUtils.lhs index 9de9bf1..537f85b 100644 --- a/ghc/compiler/coreSyn/CoreUtils.lhs +++ b/ghc/compiler/coreSyn/CoreUtils.lhs @@ -45,7 +45,7 @@ import PprCore ( pprCoreExpr ) import Var ( Var, isId, isTyVar ) import VarEnv import Name ( hashName ) -import Literal ( hashLiteral, literalType, litIsDupable, isZeroLit ) +import Literal ( hashLiteral, literalType, litIsDupable, litIsTrivial, isZeroLit ) import DataCon ( DataCon, dataConRepArity, dataConArgTys, isExistentialDataCon, dataConTyCon ) import PrimOp ( PrimOp(..), primOpOkForSpeculation, primOpIsCheap ) import Id ( Id, idType, globalIdDetails, idNewStrictness, @@ -326,7 +326,7 @@ saturating them. \begin{code} exprIsTrivial (Var v) = True -- See notes above exprIsTrivial (Type _) = True -exprIsTrivial (Lit lit) = True +exprIsTrivial (Lit lit) = litIsTrivial lit exprIsTrivial (App e arg) = not (isRuntimeArg arg) && exprIsTrivial e exprIsTrivial (Note _ e) = exprIsTrivial e exprIsTrivial (Lam b body) = not (isRuntimeVar b) && exprIsTrivial body -- 1.7.10.4