From 410e4850f38f275db6e3556d18885bfe4c259121 Mon Sep 17 00:00:00 2001 From: simonpj Date: Fri, 8 Nov 2002 15:21:28 +0000 Subject: [PATCH] [project @ 2002-11-08 15:21:27 by simonpj] -------------------------------- Expression simplification for TH -------------------------------- Simplify expressions without any inlining in SimplCore.simplifyExpr. simplifyExpr is used to simplify a TH splice before running the code, and simplifyExpr was using (SimplPhase 0) which allows inlining. Unfortunately, when -O is on (which can happen when compiling a program with some splices with -O) some inlining can happen which then confuses the byte-code generator. (Unboxed tuples.) --- ghc/compiler/simplCore/SimplCore.lhs | 7 ++++++- ghc/compiler/simplCore/SimplMonad.lhs | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ghc/compiler/simplCore/SimplCore.lhs b/ghc/compiler/simplCore/SimplCore.lhs index 9acfd81..ad30c81 100644 --- a/ghc/compiler/simplCore/SimplCore.lhs +++ b/ghc/compiler/simplCore/SimplCore.lhs @@ -118,7 +118,7 @@ simplifyExpr dflags expr ; us <- mkSplitUniqSupply 's' - ; let env = emptySimplEnv (SimplPhase 0) [] emptyVarSet + ; let env = emptySimplEnv SimplGently [] emptyVarSet (expr', _counts) = initSmpl dflags us (simplExprGently env expr) ; dumpIfSet_dyn dflags Opt_D_dump_simpl "Simplified expression" @@ -362,6 +362,11 @@ simplExprGently :: SimplEnv -> CoreExpr -> SimplM CoreExpr -- alone leaves tons of crud. -- Used (a) for user expressions typed in at the interactive prompt -- (b) the LHS and RHS of a RULE +-- +-- The name 'Gently' suggests that the SimplifierMode is SimplGently, +-- and in fact that is so.... but the 'Gently' in simplExprGently doesn't +-- enforce that; it just simplifies the expression twice + simplExprGently env expr = simplExpr env (occurAnalyseGlobalExpr expr) `thenSmpl` \ expr1 -> simplExpr env (occurAnalyseGlobalExpr expr1) diff --git a/ghc/compiler/simplCore/SimplMonad.lhs b/ghc/compiler/simplCore/SimplMonad.lhs index fe43c6d..5edfd2c 100644 --- a/ghc/compiler/simplCore/SimplMonad.lhs +++ b/ghc/compiler/simplCore/SimplMonad.lhs @@ -682,6 +682,8 @@ settings: SimplGently (a) Simplifying before specialiser/full laziness (b) Simplifiying inside INLINE pragma (c) Simplifying the LHS of a rule + (d) Simplifying a GHCi expression or Template + Haskell splice SimplPhase n Used at all other times @@ -693,6 +695,12 @@ because doing so inhibits floating ==> ...(case x of I# x# -> case fw x# of ...)... and now the redex (f x) isn't floatable any more. +The no-inling thing is also important for Template Haskell. You might be +compiling in one-shot mode with -O2; but when TH compiles a splice before +running it, we don't want to use -O2. Indeed, we don't want to inline +anything, because the byte-code interpreter might get confused about +unboxed tuples and suchlike. + INLINE pragmas ~~~~~~~~~~~~~~ SimplGently is also used as the mode to simplify inside an InlineMe note. -- 1.7.10.4