X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2FcoreSyn%2FCoreUtils.lhs;h=270d44de15b673eba64a9c41d9ca41a7160e6a87;hb=ef5b4b146aa172d8ac10f39b5eb3d7a0f948d8f1;hp=440365d7d3fa7bd0d6b755fdca40b50cbae04a40;hpb=1f8b341a88b6b60935b0ce80b59ed6e356b8cfbf;p=ghc-hetmet.git diff --git a/ghc/compiler/coreSyn/CoreUtils.lhs b/ghc/compiler/coreSyn/CoreUtils.lhs index 440365d..270d44d 100644 --- a/ghc/compiler/coreSyn/CoreUtils.lhs +++ b/ghc/compiler/coreSyn/CoreUtils.lhs @@ -43,7 +43,9 @@ import CoreSyn import PprCore ( pprCoreExpr ) import Var ( Var, isId, isTyVar ) import VarEnv -import Name ( hashName, isDllName ) +import Name ( hashName ) +import Packages ( isDllName ) +import CmdLineOpts ( DynFlags ) import Literal ( hashLiteral, literalType, litIsDupable, litIsTrivial, isZeroLit, Literal( MachLabel ) ) import DataCon ( DataCon, dataConRepArity, dataConArgTys, @@ -1171,7 +1173,7 @@ If this happens we simply make the RHS into an updatable thunk, and 'exectute' it rather than allocating it statically. \begin{code} -rhsIsStatic :: CoreExpr -> Bool +rhsIsStatic :: DynFlags -> CoreExpr -> Bool -- This function is called only on *top-level* right-hand sides -- Returns True if the RHS can be allocated statically, with -- no thunks involved at all. @@ -1230,33 +1232,33 @@ rhsIsStatic :: CoreExpr -> Bool -- When opt_RuntimeTypes is on, we keep type lambdas and treat -- them as making the RHS re-entrant (non-updatable). -rhsIsStatic rhs = is_static False rhs - -is_static :: Bool -- True <=> in a constructor argument; must be atomic - -> CoreExpr -> Bool - -is_static False (Lam b e) = isRuntimeVar b || is_static False e - -is_static in_arg (Note (SCC _) e) = False -is_static in_arg (Note _ e) = is_static in_arg e - -is_static in_arg (Lit lit) - = case lit of - MachLabel _ _ -> False - other -> True - -- A MachLabel (foreign import "&foo") in an argument - -- prevents a constructor application from being static. The - -- reason is that it might give rise to unresolvable symbols - -- in the object file: under Linux, references to "weak" - -- symbols from the data segment give rise to "unresolvable - -- relocation" errors at link time This might be due to a bug - -- in the linker, but we'll work around it here anyway. - -- SDM 24/2/2004 - -is_static in_arg other_expr = go other_expr 0 +rhsIsStatic dflags rhs = is_static False rhs where + is_static :: Bool -- True <=> in a constructor argument; must be atomic + -> CoreExpr -> Bool + + is_static False (Lam b e) = isRuntimeVar b || is_static False e + + is_static in_arg (Note (SCC _) e) = False + is_static in_arg (Note _ e) = is_static in_arg e + + is_static in_arg (Lit lit) + = case lit of + MachLabel _ _ -> False + other -> True + -- A MachLabel (foreign import "&foo") in an argument + -- prevents a constructor application from being static. The + -- reason is that it might give rise to unresolvable symbols + -- in the object file: under Linux, references to "weak" + -- symbols from the data segment give rise to "unresolvable + -- relocation" errors at link time This might be due to a bug + -- in the linker, but we'll work around it here anyway. + -- SDM 24/2/2004 + + is_static in_arg other_expr = go other_expr 0 + where go (Var f) n_val_args - | not (isDllName (idName f)) + | not (isDllName dflags (idName f)) = saturated_data_con f n_val_args || (in_arg && n_val_args == 0) -- A naked un-applied variable is *not* deemed a static RHS