From 444c62505e1e9790db08322fea8625dedd81d446 Mon Sep 17 00:00:00 2001 From: Roman Leshchinskiy Date: Thu, 2 Oct 2008 01:20:55 +0000 Subject: [PATCH] Prevent excessive inlining with DPH This adds a new flag -finline-if-enough-args which disables inlining for partially applied functions. It is automatically set by -Odph. This is a temporary hack and should remain undocumented. MERGE TO 6.10 --- compiler/coreSyn/CoreUnfold.lhs | 5 ++++- compiler/main/DynFlags.hs | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/coreSyn/CoreUnfold.lhs b/compiler/coreSyn/CoreUnfold.lhs index 45b8b92..b6706c1 100644 --- a/compiler/coreSyn/CoreUnfold.lhs +++ b/compiler/coreSyn/CoreUnfold.lhs @@ -586,10 +586,13 @@ callSiteInline dflags active_inline id lone_variable arg_infos cont_info -> True | otherwise - -> some_benefit && small_enough + -> some_benefit && small_enough && inline_enough_args where enough_args = n_val_args >= n_vals_wanted + inline_enough_args = + not (dopt Opt_InlineIfEnoughArgs dflags) || enough_args + some_benefit = or arg_infos || really_interesting_cont -- There must be something interesting diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 5a1981d..e6ec50e 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -261,6 +261,7 @@ data DynFlag | Opt_UnboxStrictFields | Opt_MethodSharing | Opt_DictsCheap + | Opt_InlineIfEnoughArgs | Opt_EnableRewriteRules -- Apply rewrite rules during simplification | Opt_Vectorise | Opt_RegsGraph -- do graph coloring register allocation @@ -1545,6 +1546,7 @@ fFlags = [ ( "unbox-strict-fields", Opt_UnboxStrictFields, const Supported ), ( "method-sharing", Opt_MethodSharing, const Supported ), ( "dicts-cheap", Opt_DictsCheap, const Supported ), + ( "inline-if-enough-args", Opt_InlineIfEnoughArgs, const Supported ), ( "excess-precision", Opt_ExcessPrecision, const Supported ), ( "asm-mangling", Opt_DoAsmMangling, const Supported ), ( "print-bind-result", Opt_PrintBindResult, const Supported ), @@ -1908,6 +1910,7 @@ setOptLevel n dflags -- -fmax-simplifier-iterations20 this is necessary sometimes -- -fno-spec-constr-threshold run SpecConstr even for big loops -- -fno-spec-constr-count SpecConstr as much as possible +-- -finline-enough-args hack to prevent excessive inlining -- setDPHOpt :: DynFlags -> DynFlags setDPHOpt dflags = setOptLevel 2 (dflags { maxSimplIterations = 20 @@ -1916,6 +1919,7 @@ setDPHOpt dflags = setOptLevel 2 (dflags { maxSimplIterations = 20 }) `dopt_set` Opt_DictsCheap `dopt_unset` Opt_MethodSharing + `dopt_set` Opt_InlineIfEnoughArgs data DPHBackend = DPHPar | DPHSeq -- 1.7.10.4