Skip to content

[Constraint solver] Compute common apply result type in the solver. #22977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

DougGregor
Copy link
Member

Constraint generation for function application expressions contains a simple
hack to try to find the common result type for an overload set containing
callable things. Instead, perform this “common result type” computation
when simplifying an applicable function constraint, so it is more
widely applicable.

These functions appear to have been part of an implementation of constraint
propagation that was removed or never committed; remove them. NFC
Constraint generation for function application expressions contains a simple
hack to try to find the common result type for an overload set containing
callable things. Instead, perform this “common result type” computation
when simplifying an applicable function constraint, so it is more
widely applicable.
Extend the computation of effective overload types, used in common result
type and common type computations, to also handle subscripts and variables.
This allows the optimization to also apply to subscripts, which did not
previously have a peephole in constraint generation.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please smoke test compiler performance

@swift-ci
Copy link
Contributor

Compilation-performance test failed

@slavapestov
Copy link
Contributor

Tests?

… inits.

There are multiple ways in which the Clang importer can produce an
initializer, and we have existing name shadowing rules to decide on
the best. Extend those rules to cover the case where a
Clang-importer-synthesized initializer collides with a C function
imported as an initializer. There's technically no reason to do the
latter because the former already exists, but some frameworks
currently depend on this.

Prior to this, the constraint solver was preferring the synthesized
initializer already (which is the right thing to do), for the wrong
reasons.
@DougGregor
Copy link
Member Author

@slavapestov added some targeted tests to make sure this is doing what we expect.

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

@swift-ci please smoke test compiler performance

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please smoke test compiler performance

@DougGregor
Copy link
Member Author

@swift-ci please smoke test Linux

@swift-ci
Copy link
Contributor

Summary for master smoketest

Unexpected test results, excluded stats for ReactiveCocoa

Regressions found (see below)

Debug

debug brief

Regressed (1)
name old new delta delta_pct
time.swift-driver.wall 14.1s 14.3s 196.8ms 1.4% ⛔
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (2)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 106,705,951,877 107,041,589,846 335,637,969 0.31%
LLVM.NumLLVMBytesOutput 6,173,068 6,169,188 -3,880 -0.06%

debug detailed

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (23)
name old new delta delta_pct
AST.NumImportedExternalDefinitions 1,110 1,110 0 0.0%
AST.NumLoadedModules 1,038 1,038 0 0.0%
AST.NumTotalClangImportedEntities 4,462 4,462 0 0.0%
AST.NumUsedConformances 886 886 0 0.0%
IRModule.NumIRBasicBlocks 18,028 18,028 0 0.0%
IRModule.NumIRFunctions 10,554 10,554 0 0.0%
IRModule.NumIRGlobals 8,013 8,013 0 0.0%
IRModule.NumIRInsts 315,985 313,896 -2,089 -0.66%
IRModule.NumIRValueSymbols 17,630 17,630 0 0.0%
LLVM.NumLLVMBytesOutput 6,173,068 6,169,188 -3,880 -0.06%
SILModule.NumSILGenFunctions 5,382 5,382 0 0.0%
SILModule.NumSILOptFunctions 7,055 7,052 -3 -0.04%
Sema.NumConformancesDeserialized 17,297 17,297 0 0.0%
Sema.NumConstraintScopes 41,814 41,870 56 0.13%
Sema.NumDeclsDeserialized 145,811 145,507 -304 -0.21%
Sema.NumDeclsValidated 11,580 11,580 0 0.0%
Sema.NumFunctionsTypechecked 2,540 2,540 0 0.0%
Sema.NumGenericSignatureBuilders 5,030 5,030 0 0.0%
Sema.NumLazyGenericEnvironments 32,607 32,607 0 0.0%
Sema.NumLazyGenericEnvironmentsLoaded 2,036 2,036 0 0.0%
Sema.NumLazyIterableDeclContexts 26,629 26,618 -11 -0.04%
Sema.NumTypesDeserialized 66,236 66,189 -47 -0.07%
Sema.NumTypesValidated 12,154 12,154 0 0.0%

Release

release brief

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (3)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 141,129,775,489 141,302,632,891 172,857,402 0.12%
LLVM.NumLLVMBytesOutput 7,146,808 7,146,776 -32 -0.0%
time.swift-driver.wall 26.4s 26.4s -4.0ms -0.02%

release detailed

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (23)
name old new delta delta_pct
AST.NumImportedExternalDefinitions 402 402 0 0.0%
AST.NumLoadedModules 76 76 0 0.0%
AST.NumTotalClangImportedEntities 2,146 2,146 0 0.0%
AST.NumUsedConformances 890 890 0 0.0%
IRModule.NumIRBasicBlocks 20,921 20,921 0 0.0%
IRModule.NumIRFunctions 10,070 10,070 0 0.0%
IRModule.NumIRGlobals 8,102 8,102 0 0.0%
IRModule.NumIRInsts 220,732 220,745 13 0.01%
IRModule.NumIRValueSymbols 17,316 17,316 0 0.0%
LLVM.NumLLVMBytesOutput 7,146,808 7,146,776 -32 -0.0%
SILModule.NumSILGenFunctions 4,178 4,178 0 0.0%
SILModule.NumSILOptFunctions 5,856 5,856 0 0.0%
Sema.NumConformancesDeserialized 12,445 12,445 0 0.0%
Sema.NumConstraintScopes 40,618 40,674 56 0.14%
Sema.NumDeclsDeserialized 32,249 32,249 0 0.0%
Sema.NumDeclsValidated 7,874 7,874 0 0.0%
Sema.NumFunctionsTypechecked 2,204 2,204 0 0.0%
Sema.NumGenericSignatureBuilders 1,718 1,718 0 0.0%
Sema.NumLazyGenericEnvironments 6,785 6,785 0 0.0%
Sema.NumLazyGenericEnvironmentsLoaded 130 130 0 0.0%
Sema.NumLazyIterableDeclContexts 4,203 4,203 0 0.0%
Sema.NumTypesDeserialized 18,066 18,070 4 0.02%
Sema.NumTypesValidated 6,942 6,942 0 0.0%

@DougGregor
Copy link
Member Author

@slavapestov I'm going to merge this so I can build another PR on it, and address your remaining two comments separately. Thank you!

@DougGregor DougGregor merged commit 9e5d8ee into swiftlang:master Mar 1, 2019
@DougGregor DougGregor deleted the constraint-solver-common-result-type branch March 1, 2019 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants