-mkWwBodies fun_ty demands res_info one_shots
- = mkWWargs fun_ty demands one_shots' `thenUs` \ (wrap_args, wrap_fn_args, work_fn_args, res_ty) ->
- mkWWstr wrap_args `thenUs` \ (work_args, wrap_fn_str, work_fn_str) ->
- let
- (work_lam_args, work_call_args) = mkWorkerArgs work_args res_ty
- in
- -- Don't do CPR if the worker doesn't have any value arguments
- -- Then the worker is just a constant, so we don't want to unbox it.
- (if any isId work_args then
- mkWWcpr res_ty res_info
- else
- returnUs (id, id, res_ty)
- ) `thenUs` \ (wrap_fn_cpr, work_fn_cpr, _cpr_res_ty) ->
-
- returnUs ([idNewDemandInfo v | v <- work_args, isId v],
- Note InlineMe . wrap_fn_args . wrap_fn_cpr . wrap_fn_str . applyToVars work_call_args . Var,
- mkLams work_lam_args. work_fn_str . work_fn_cpr . work_fn_args)
- -- We use an INLINE unconditionally, even if the wrapper turns out to be
- -- something trivial like
- -- fw = ...
- -- f = __inline__ (coerce T fw)
- -- The point is to propagate the coerce to f's call sites, so even though
- -- f's RHS is now trivial (size 1) we still want the __inline__ to prevent
- -- fw from being inlined into f's RHS
+mkWwBodies fun_ty demands res_info one_shots = do
+ (wrap_args, wrap_fn_args, work_fn_args, res_ty) <- mkWWargs fun_ty demands one_shots'
+ (work_args, wrap_fn_str, work_fn_str) <- mkWWstr wrap_args
+ let (work_lam_args, work_call_args) = mkWorkerArgs work_args res_ty
+ -- Don't do CPR if the worker doesn't have any value arguments
+ -- Then the worker is just a constant, so we don't want to unbox it.
+ (wrap_fn_cpr, work_fn_cpr, _cpr_res_ty)
+ <- if any isIdVar work_args then
+ mkWWcpr res_ty res_info
+ else
+ return (id, id, res_ty)
+
+ return ([idNewDemandInfo v | v <- work_call_args, isIdVar v],
+ Note InlineMe . wrap_fn_args . wrap_fn_cpr . wrap_fn_str . applyToVars work_call_args . Var,
+ mkLams work_lam_args. work_fn_str . work_fn_cpr . work_fn_args)
+ -- We use an INLINE unconditionally, even if the wrapper turns out to be
+ -- something trivial like
+ -- fw = ...
+ -- f = __inline__ (coerce T fw)
+ -- The point is to propagate the coerce to f's call sites, so even though
+ -- f's RHS is now trivial (size 1) we still want the __inline__ to prevent
+ -- fw from being inlined into f's RHS