Skip to content

Commit ade0697

Browse files
dotnet-botedgarfgpT-Grobrianrourkebollpsfinaki
authored
Merge main to release/dev17.11 (#17056)
* Disallow calling abstract methods directly on interfaces (#17021) * Disallow calling abstract methods directly on interfaces * More tests * IWSAMs are not supported by NET472 * Update src/Compiler/Checking/ConstraintSolver.fs Co-authored-by: Tomas Grosup <[email protected]> * fix typos * looking for the right check * Add comments * move release notes * Add a new error number and message * Update docs/release-notes/.FSharp.Compiler.Service/8.0.400.md Co-authored-by: Brian Rourke Boll <[email protected]> * Update docs/release-notes/.FSharp.Compiler.Service/8.0.400.md Co-authored-by: Brian Rourke Boll <[email protected]> * Improve error message --------- Co-authored-by: Tomas Grosup <[email protected]> Co-authored-by: Brian Rourke Boll <[email protected]> * Always use `typeEquivAux EraseMeasures` (for integral range optimizations) (#17048) * Always use `typeEquivAux EraseMeasures` * Update release notes * Update baselines --------- Co-authored-by: Petr <[email protected]> --------- Co-authored-by: Edgar Gonzalez <[email protected]> Co-authored-by: Tomas Grosup <[email protected]> Co-authored-by: Brian Rourke Boll <[email protected]> Co-authored-by: Petr <[email protected]> Co-authored-by: Kevin Ransom (msft) <[email protected]>
1 parent d11b46f commit ade0697

File tree

5 files changed

+322
-172
lines changed

5 files changed

+322
-172
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### Fixed
22

33
* Disallow calling abstract methods directly on interfaces. ([Issue #14012](https://github.com/dotnet/fsharp/issues/14012), [Issue #16299](https://github.com/dotnet/fsharp/issues/16299), [PR #17021](https://github.com/dotnet/fsharp/pull/17021))
4-
* Various parenthesization API fixes. ([PR #16977](https://github.com/dotnet/fsharp/pull/16977))
5-
* Fix bug in optimization of for-loops over integral ranges with steps and units of measure. ([Issue #17025](https://github.com/dotnet/fsharp/issues/17025), [PR #17040](https://github.com/dotnet/fsharp/pull/17040))
4+
* Various parenthesization API fixes. ([PR #16977](https://github.com/dotnet/fsharp/pull/16977))
5+
* Fix bug in optimization of for-loops over integral ranges with steps and units of measure. ([Issue #17025](https://github.com/dotnet/fsharp/issues/17025), [PR #17040](https://github.com/dotnet/fsharp/pull/17040), [PR #17048](https://github.com/dotnet/fsharp/pull/17048))
66
* Fix calling an overridden virtual static method via the interface ([PR #17013](https://github.com/dotnet/fsharp/pull/17013))

src/Compiler/Optimize/LowerComputedCollections.fs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,21 +314,21 @@ module Array =
314314
let arrayTy = mkArrayType g overallElemTy
315315

316316
let convToNativeInt ovf expr =
317-
let ty = stripMeasuresFromTy g (tyOfExpr g expr)
317+
let ty = tyOfExpr g expr
318318

319319
let conv =
320320
match ovf with
321321
| NoCheckOvf -> AI_conv DT_I
322322
| CheckOvf when isSignedIntegerTy g ty -> AI_conv_ovf DT_I
323323
| CheckOvf -> AI_conv_ovf_un DT_I
324324

325-
if typeEquiv g ty g.int64_ty then
325+
if typeEquivAux EraseMeasures g ty g.int64_ty then
326326
mkAsmExpr ([conv], [], [expr], [g.nativeint_ty], m)
327-
elif typeEquiv g ty g.nativeint_ty then
327+
elif typeEquivAux EraseMeasures g ty g.nativeint_ty then
328328
mkAsmExpr ([conv], [], [mkAsmExpr ([AI_conv DT_I8], [], [expr], [g.int64_ty], m)], [g.nativeint_ty], m)
329-
elif typeEquiv g ty g.uint64_ty then
329+
elif typeEquivAux EraseMeasures g ty g.uint64_ty then
330330
mkAsmExpr ([conv], [], [expr], [g.nativeint_ty], m)
331-
elif typeEquiv g ty g.unativeint_ty then
331+
elif typeEquivAux EraseMeasures g ty g.unativeint_ty then
332332
mkAsmExpr ([conv], [], [mkAsmExpr ([AI_conv DT_U8], [], [expr], [g.uint64_ty], m)], [g.nativeint_ty], m)
333333
else
334334
expr

src/Compiler/TypedTree/TypedTreeOps.fs

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10434,41 +10434,37 @@ let mkRangeCount g m rangeTy rangeExpr start step finish =
1043410434
mkAsmExpr ([AI_clt_un], [], [e1; e2], [g.bool_ty], m)
1043510435

1043610436
let unsignedEquivalent ty =
10437-
if typeEquiv g ty g.int64_ty then g.uint64_ty
10438-
elif typeEquiv g ty g.int32_ty then g.uint32_ty
10439-
elif typeEquiv g ty g.int16_ty then g.uint16_ty
10440-
elif typeEquiv g ty g.sbyte_ty then g.byte_ty
10437+
if typeEquivAux EraseMeasures g ty g.int64_ty then g.uint64_ty
10438+
elif typeEquivAux EraseMeasures g ty g.int32_ty then g.uint32_ty
10439+
elif typeEquivAux EraseMeasures g ty g.int16_ty then g.uint16_ty
10440+
elif typeEquivAux EraseMeasures g ty g.sbyte_ty then g.byte_ty
1044110441
else ty
1044210442

1044310443
/// Find the unsigned type with twice the width of the given type, if available.
1044410444
let nextWidestUnsignedTy ty =
10445-
let ty = stripMeasuresFromTy g ty
10446-
10447-
if typeEquiv g ty g.int64_ty || typeEquiv g ty g.int32_ty || typeEquiv g ty g.uint32_ty then
10445+
if typeEquivAux EraseMeasures g ty g.int64_ty || typeEquivAux EraseMeasures g ty g.int32_ty || typeEquivAux EraseMeasures g ty g.uint32_ty then
1044810446
g.uint64_ty
10449-
elif typeEquiv g ty g.int16_ty || typeEquiv g ty g.uint16_ty || typeEquiv g ty g.char_ty then
10447+
elif typeEquivAux EraseMeasures g ty g.int16_ty || typeEquivAux EraseMeasures g ty g.uint16_ty || typeEquivAux EraseMeasures g ty g.char_ty then
1045010448
g.uint32_ty
10451-
elif typeEquiv g ty g.sbyte_ty || typeEquiv g ty g.byte_ty then
10449+
elif typeEquivAux EraseMeasures g ty g.sbyte_ty || typeEquivAux EraseMeasures g ty g.byte_ty then
1045210450
g.uint16_ty
1045310451
else
1045410452
ty
1045510453

1045610454
/// Convert the value to the next-widest unsigned type.
1045710455
/// We do this so that adding one won't result in overflow.
1045810456
let mkWiden e =
10459-
let ty = stripMeasuresFromTy g rangeTy
10460-
10461-
if typeEquiv g ty g.int32_ty then
10457+
if typeEquivAux EraseMeasures g rangeTy g.int32_ty then
1046210458
mkAsmExpr ([AI_conv DT_I8], [], [e], [g.uint64_ty], m)
10463-
elif typeEquiv g ty g.uint32_ty then
10459+
elif typeEquivAux EraseMeasures g rangeTy g.uint32_ty then
1046410460
mkAsmExpr ([AI_conv DT_U8], [], [e], [g.uint64_ty], m)
10465-
elif typeEquiv g ty g.int16_ty then
10461+
elif typeEquivAux EraseMeasures g rangeTy g.int16_ty then
1046610462
mkAsmExpr ([AI_conv DT_I4], [], [e], [g.uint32_ty], m)
10467-
elif typeEquiv g ty g.uint16_ty || typeEquiv g ty g.char_ty then
10463+
elif typeEquivAux EraseMeasures g rangeTy g.uint16_ty || typeEquivAux EraseMeasures g rangeTy g.char_ty then
1046810464
mkAsmExpr ([AI_conv DT_U4], [], [e], [g.uint32_ty], m)
10469-
elif typeEquiv g ty g.sbyte_ty then
10465+
elif typeEquivAux EraseMeasures g rangeTy g.sbyte_ty then
1047010466
mkAsmExpr ([AI_conv DT_I2], [], [e], [g.uint16_ty], m)
10471-
elif typeEquiv g ty g.byte_ty then
10467+
elif typeEquivAux EraseMeasures g rangeTy g.byte_ty then
1047210468
mkAsmExpr ([AI_conv DT_U2], [], [e], [g.uint16_ty], m)
1047310469
else
1047410470
e
@@ -10481,12 +10477,10 @@ let mkRangeCount g m rangeTy rangeExpr start step finish =
1048110477

1048210478
/// Whether the total count might not fit in 64 bits.
1048310479
let couldBeTooBig ty =
10484-
let underlying = stripMeasuresFromTy g ty
10485-
10486-
typeEquiv g underlying g.int64_ty
10487-
|| typeEquiv g underlying g.uint64_ty
10488-
|| typeEquiv g underlying g.nativeint_ty
10489-
|| typeEquiv g underlying g.unativeint_ty
10480+
typeEquivAux EraseMeasures g ty g.int64_ty
10481+
|| typeEquivAux EraseMeasures g ty g.uint64_ty
10482+
|| typeEquivAux EraseMeasures g ty g.nativeint_ty
10483+
|| typeEquivAux EraseMeasures g ty g.unativeint_ty
1049010484

1049110485
/// pseudoCount + 1
1049210486
let mkAddOne pseudoCount =
@@ -10499,16 +10493,14 @@ let mkRangeCount g m rangeTy rangeExpr start step finish =
1049910493
mkAsmExpr ([AI_add], [], [pseudoCount; mkTypedOne g m ty], [ty], m)
1050010494

1050110495
let mkRuntimeCalc mkThrowIfStepIsZero pseudoCount count =
10502-
let underlying = stripMeasuresFromTy g rangeTy
10503-
10504-
if typeEquiv g underlying g.int64_ty || typeEquiv g underlying g.uint64_ty then
10496+
if typeEquivAux EraseMeasures g rangeTy g.int64_ty || typeEquivAux EraseMeasures g rangeTy g.uint64_ty then
1050510497
RangeCount.PossiblyOversize (fun mkLoopExpr ->
1050610498
mkThrowIfStepIsZero
1050710499
(mkCompGenLetIn m (nameof pseudoCount) (tyOfExpr g pseudoCount) pseudoCount (fun (_, pseudoCount) ->
1050810500
let wouldOvf = mkILAsmCeq g m pseudoCount (Expr.Const (Const.UInt64 UInt64.MaxValue, m, g.uint64_ty))
1050910501
mkCompGenLetIn m (nameof wouldOvf) g.bool_ty wouldOvf (fun (_, wouldOvf) ->
1051010502
mkLoopExpr count wouldOvf))))
10511-
elif typeEquiv g underlying g.nativeint_ty || typeEquiv g underlying g.unativeint_ty then // We have a nativeint ty whose size we won't know till runtime.
10503+
elif typeEquivAux EraseMeasures g rangeTy g.nativeint_ty || typeEquivAux EraseMeasures g rangeTy g.unativeint_ty then // We have a nativeint ty whose size we won't know till runtime.
1051210504
RangeCount.PossiblyOversize (fun mkLoopExpr ->
1051310505
mkThrowIfStepIsZero
1051410506
(mkCompGenLetIn m (nameof pseudoCount) (tyOfExpr g pseudoCount) pseudoCount (fun (_, pseudoCount) ->

0 commit comments

Comments
 (0)