Skip to content

Commit bdd55fc

Browse files
authored
Merge pull request #17200 from dotnet/revert-17189-cp_opt
Revert "Fix inlining regression: #17161"
2 parents c768e2d + 468dfa6 commit bdd55fc

File tree

4 files changed

+16
-88
lines changed

4 files changed

+16
-88
lines changed

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<!-- F# Version components -->
1515
<FSMajorVersion>8</FSMajorVersion>
1616
<FSMinorVersion>0</FSMinorVersion>
17-
<FSBuildVersion>301</FSBuildVersion>
17+
<FSBuildVersion>300</FSBuildVersion>
1818
<FSRevisionVersion>0</FSRevisionVersion>
1919
<!-- -->
2020
<!-- F# Language version -->

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"xcopy-msbuild": "17.8.1-2"
1515
},
1616
"native-tools": {
17-
"perl": "5.38.2.2"
17+
"perl": "5.38.0.1"
1818
},
1919
"msbuild-sdks": {
2020
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24204.3",

src/Compiler/Optimize/Optimizer.fs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,7 +2356,15 @@ let rec OptimizeExpr cenv (env: IncrementalOptimizationEnv) expr =
23562356
OptimizeConst cenv env expr (c, m, ty)
23572357

23582358
| Expr.Val (v, _vFlags, m) ->
2359-
OptimizeVal cenv env expr (v, m)
2359+
if not (v.Accessibility.IsPrivate) then
2360+
OptimizeVal cenv env expr (v, m)
2361+
else
2362+
expr,
2363+
{ TotalSize = 10
2364+
FunctionSize = 1
2365+
HasEffect = false
2366+
MightMakeCriticalTailcall=false
2367+
Info=UnknownValue }
23602368

23612369

23622370
| Expr.Quote (ast, splices, isFromQueryExpression, m, ty) ->
@@ -3074,6 +3082,9 @@ and TryOptimizeVal cenv env (vOpt: ValRef option, shouldInline, inlineIfLambda,
30743082
let fvs = freeInExpr CollectLocals expr
30753083
if fvs.UsesMethodLocalConstructs then
30763084
// Discarding lambda for binding because uses protected members --- TBD: Should we warn or error here
3085+
None
3086+
elif fvs.FreeLocals |> Seq.exists(fun v -> v.Accessibility.IsPrivate ) then
3087+
// Discarding lambda for binding because uses private members --- TBD: Should we warn or error here
30773088
None
30783089
else
30793090
let exprCopy = CopyExprForInlining cenv inlineIfLambda expr m
@@ -4112,10 +4123,10 @@ and OptimizeBinding cenv isRec env (TBind(vref, expr, spBind)) =
41124123
let fvs = freeInExpr CollectLocals body
41134124
if fvs.UsesMethodLocalConstructs then
41144125
// Discarding lambda for binding because uses protected members
4115-
UnknownValue
4126+
UnknownValue
41164127
elif fvs.FreeLocals.ToArray() |> Seq.fold(fun acc v -> if not acc then v.Accessibility.IsPrivate else acc) false then
41174128
// Discarding lambda for binding because uses private members
4118-
UnknownValue
4129+
UnknownValue
41194130
else
41204131
ivalue
41214132

tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/Inlining.fs

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ module Inlining =
1616
|> ignoreWarnings
1717
|> verifyILBaseline
1818

19-
let withRealInternalSignature realSig compilation =
20-
compilation
21-
|> withOptions [if realSig then "--realsig+" else "--realsig-" ]
22-
2319
// SOURCE=Match01.fs SCFLAGS="-a --optimize+" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd Match01.dll" # Match01.fs
2420
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Match01_RealInternalSignatureOn.fs"|])>]
2521
let ``Match01_RealInternalSignatureOn_fs`` compilation =
@@ -143,82 +139,3 @@ let found = data |> List.contains nan
143139
}"""]
144140
#endif
145141

146-
[<InlineData(true)>] // RealSig
147-
[<InlineData(false)>] // Regular
148-
[<Theory>]
149-
let ``Inlining field with private module`` (realSig) =
150-
Fsx """
151-
module private PrivateModule =
152-
let moduleValue = 1
153-
154-
let inline getModuleValue () =
155-
moduleValue
156-
157-
[<EntryPoint>]
158-
let main argv =
159-
// [FS1118] Failed to inline the value 'getModuleValue' marked 'inline', perhaps because a recursive value was marked 'inline'
160-
// (fixed by making PrivateModule internal instead of private)
161-
PrivateModule.getModuleValue () |> ignore
162-
0
163-
"""
164-
|> withOptimize
165-
|> withRealInternalSignature realSig
166-
|> asExe
167-
|> compileAndRun
168-
|> shouldSucceed
169-
170-
[<InlineData(true)>] // RealSig
171-
[<InlineData(false)>] // Regular
172-
[<Theory>]
173-
let ``Inlining field with private class`` (realSig) =
174-
Fsx """
175-
type private FirstType () =
176-
member this.FirstMethod () = ()
177-
178-
type private SecondType () =
179-
member this.SecondMethod () =
180-
let inline callFirstMethod (first: FirstType) =
181-
first.FirstMethod ()
182-
183-
callFirstMethod (FirstType())
184-
185-
printfn $"{(SecondType ()).SecondMethod()}"
186-
"""
187-
|> withOptimize
188-
|> withRealInternalSignature realSig
189-
|> asExe
190-
|> compileAndRun
191-
|> shouldSucceed
192-
193-
[<InlineData(true)>] // RealSig
194-
[<InlineData(false)>] // Regular
195-
[<Theory>]
196-
let ``Inlining deep local functions field with private class`` (realSig) =
197-
Fsx """
198-
type private FirstType () =
199-
member this.FirstMethod () = ()
200-
201-
type private SecondType () =
202-
member this.SecondMethod () =
203-
let inline callFirstMethod (first: FirstType) =
204-
first.FirstMethod ()
205-
206-
let inline callFirstMethodDeeper (first: FirstType) =
207-
callFirstMethod (first)
208-
209-
let inline callFirstMethodMoreDeeper (first: FirstType) =
210-
callFirstMethodDeeper (first)
211-
212-
let inline callFirstMethodMostDeeply (first: FirstType) =
213-
callFirstMethodMoreDeeper (first)
214-
215-
callFirstMethodMostDeeply (FirstType())
216-
217-
printfn $"{(SecondType ()).SecondMethod()}"
218-
"""
219-
|> withOptimize
220-
|> withRealInternalSignature realSig
221-
|> asExe
222-
|> compileAndRun
223-
|> shouldSucceed
224-

0 commit comments

Comments
 (0)