X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2FstgSyn%2FCoreToStg.lhs;h=994b900960a31be65937f6656212b3ed600b1af0;hp=31837b904362416695b1ca620058eabbcd0e5ca3;hb=8100cd4395e46ae747be4298c181a4730d6206bc;hpb=fb38b8bab2b531ca7ac4ea28ad5b259a00e3759b diff --git a/compiler/stgSyn/CoreToStg.lhs b/compiler/stgSyn/CoreToStg.lhs index 31837b9..994b900 100644 --- a/compiler/stgSyn/CoreToStg.lhs +++ b/compiler/stgSyn/CoreToStg.lhs @@ -16,7 +16,6 @@ import CoreUtils ( rhsIsStatic, manifestArity, exprType, findDefault ) import StgSyn import Type -import Coercion ( mkUnsafeCoercion ) import TyCon ( isAlgTyCon ) import Id import Var ( Var, globalIdDetails, idType ) @@ -318,6 +317,11 @@ coreToStgExpr (Note (SCC cc) expr) = coreToStgExpr expr `thenLne` ( \ (expr2, fvs, escs) -> returnLne (StgSCC cc expr2, fvs, escs) ) +coreToStgExpr (Case (Var id) _bndr ty [(DEFAULT,[],expr)]) + | Just (TickBox m n) <- isTickBoxOp_maybe id + = coreToStgExpr expr `thenLne` ( \ (expr2, fvs, escs) -> + returnLne (StgTick m n expr2, fvs, escs) ) + coreToStgExpr (Note other_note expr) = coreToStgExpr expr @@ -443,6 +447,7 @@ coreToStgApp -> [CoreArg] -- Arguments -> LneM (StgExpr, FreeVarsInfo, EscVarsSet) + coreToStgApp maybe_thunk_body f args = coreToStgArgs args `thenLne` \ (args', args_fvs) -> lookupVarLne f `thenLne` \ how_bound -> @@ -496,10 +501,11 @@ coreToStgApp maybe_thunk_body f args res_ty = exprType (mkApps (Var f) args) app = case globalIdDetails f of DataConWorkId dc | saturated -> StgConApp dc args' - PrimOpId op -> ASSERT( saturated ) - StgOpApp (StgPrimOp op) args' res_ty + PrimOpId op -> ASSERT( saturated ) + StgOpApp (StgPrimOp op) args' res_ty FCallId call -> ASSERT( saturated ) StgOpApp (StgFCallOp call (idUnique f)) args' res_ty + TickBoxOpId {} -> pprPanic "coreToStg TickBox" $ ppr (f,args') _other -> StgApp f args' in @@ -540,6 +546,21 @@ coreToStgArgs (arg : args) -- Non-type argument StgLit lit -> StgLitArg lit _ -> pprPanic "coreToStgArgs" (ppr arg) in + -- WARNING: what if we have an argument like (v `cast` co) + -- where 'co' changes the representation type? + -- (This really only happens if co is unsafe.) + -- Then all the getArgAmode stuff in CgBindery will set the + -- cg_rep of the CgIdInfo based on the type of v, rather + -- than the type of 'co'. + -- This matters particularly when the function is a primop + -- or foreign call. + -- Wanted: a better solution than this hacky warning + let + arg_ty = exprType arg + stg_arg_ty = stgArgType stg_arg + in + WARN( isUnLiftedType arg_ty /= isUnLiftedType stg_arg_ty, + ptext SLIT("Dangerous-looking argument. Probable cause: bad unsafeCoerce#") $$ ppr arg) returnLne (stg_arg : stg_args, fvs)