diff --git a/src/Compiler/Optimize/InnerLambdasToTopLevelFuncs.fs b/src/Compiler/Optimize/InnerLambdasToTopLevelFuncs.fs index f03db8f5e6f..fba91722c10 100644 --- a/src/Compiler/Optimize/InnerLambdasToTopLevelFuncs.fs +++ b/src/Compiler/Optimize/InnerLambdasToTopLevelFuncs.fs @@ -196,8 +196,8 @@ module Pass1_DetermineTLRAndArities = let arity = Operators.min nFormals nMaxApplied if atTopLevel then Some (f, arity) - elif g.realsig then - None + //elif g.realsig then + // None else if arity<>0 || not (isNil tps) then Some (f, arity) else @@ -217,20 +217,24 @@ module Pass1_DetermineTLRAndArities = let DetermineTLRAndArities g expr = let xinfo = GetUsageInfoOfImplFile g expr - let fArities = Zmap.chooseL (SelectTLRVals g xinfo) xinfo.Defns - let fArities = List.filter (fst >> IsValueRecursionFree xinfo) fArities - // Do not TLR v if it is bound under a shouldinline defn - // There is simply no point - the original value will be duplicated and TLR'd anyway - let rejectS = GetValsBoundUnderShouldInline xinfo - let fArities = List.filter (fun (v, _) -> not (Zset.contains v rejectS)) fArities - (*-*) - let tlrS = Zset.ofList valOrder (List.map fst fArities) - let topValS = xinfo.TopLevelBindings (* genuinely top level *) - let topValS = Zset.filter (IsMandatoryNonTopLevel g >> not) topValS (* restrict *) + let rejects = GetValsBoundUnderShouldInline xinfo + let fArities = + xinfo.Defns + |> Zmap.chooseL (SelectTLRVals g xinfo) + |> List.filter (fst >> IsValueRecursionFree xinfo) + // Do not TLR v if it is bound under a shouldinline defn + // There is simply no point - the original value will be duplicated and TLR'd anyway + |> List.filter (fun (v, _) -> not (Zset.contains v rejects)) + + let tlrs = Zset.ofList valOrder (List.map fst fArities) + let topVals = + xinfo.TopLevelBindings // genuinely top level *) + |> Zset.filter (IsMandatoryNonTopLevel g >> not) // restrict + #if DEBUG (* REPORT MISSED CASES *) if verboseTLR then - let missed = Zset.diff xinfo.TopLevelBindings tlrS + let missed = Zset.diff xinfo.TopLevelBindings tlrs missed |> Zset.iter (fun v -> dprintf "TopLevel but not TLR = %s\n" v.LogicalName) (* REPORT OVER *) #endif @@ -238,7 +242,7 @@ module Pass1_DetermineTLRAndArities = #if DEBUG if verboseTLR then DumpArity arityM #endif - tlrS, topValS, arityM + tlrs, topVals, arityM (* NOTES: For constants, @@ -760,7 +764,6 @@ let FlatEnvPacks g fclassM topValS declist (reqdItemsMap: Zmap List.map (fun (v, aenv) -> mkInvisibleBind aenv (exprForVal env.m v)) let unpack = @@ -785,7 +788,7 @@ let FlatEnvPacks g fclassM topValS declist (reqdItemsMap: Zmap match expr with