Skip to content

AST: Make SubstFlags::UseErrorType the default behavior #26776

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

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Aug 22, 2019

We've fixed a number of bugs recently where callers did not expect
to get a null Type out of subst(). This occurs particularly often
in SourceKit, where the input AST is often invalid and the types
resulting from substitution are mostly used for display.

Let's fix all these potential problems in one fell swoop by changing
subst() to always return a Type, possibly one containing ErrorTypes.

Only a couple of places depended on the old behavior, and they were
easy enough to change from checking for a null Type to checking if
the result responds with true to hasError().

Also while we're at it, simplify a few call sites of subst().

We've fixed a number of bugs recently where callers did not expect
to get a null Type out of subst(). This occurs particularly often
in SourceKit, where the input AST is often invalid and the types
resulting from substitution are mostly used for display.

Let's fix all these potential problems in one fell swoop by changing
subst() to always return a Type, possibly one containing ErrorTypes.

Only a couple of places depended on the old behavior, and they were
easy enough to change from checking for a null Type to checking if
the result responds with true to hasError().

Also while we're at it, simplify a few call sites of subst().
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor Author

@swift-ci Please test compiler performance

@swift-ci
Copy link
Contributor

Summary for master full

Unexpected test results, excluded stats for RxCocoa, Base64CoderSwiftUI, SwifterSwift

Regressions found (see below)

Debug-batch

debug-batch 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 46,402,076,437,704 46,536,836,572,424 134,760,134,720 0.29%
LLVM.NumLLVMBytesOutput 1,786,906,002 1,786,897,678 -8,324 -0.0%
time.swift-driver.wall 5093.6s 5080.2s -13.4s -0.26%

debug-batch detailed

Regressed (2)
name old new delta delta_pct
Driver.NumDriverPipePolls 57,021 58,080 1,059 1.86% ⛔
Driver.NumDriverPipeReads 44,080 45,096 1,016 2.3% ⛔
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (150)
name old new delta delta_pct
AST.NumASTBytesAllocated 64,522,322,705 64,617,771,181 95,448,476 0.15%
AST.NumDecls 140,002 140,002 0 0.0%
AST.NumDependencies 321,525 321,515 -10 -0.0%
AST.NumInfixOperators 53,782 53,782 0 0.0%
AST.NumLinkLibraries 0 0 0 0.0%
AST.NumLoadedModules 399,488 399,488 0 0.0%
AST.NumLocalTypeDecls 253 253 0 0.0%
AST.NumLookupInModule 6,758,604 6,774,678 16,074 0.24%
AST.NumLookupQualifiedInAnyObject 281 281 0 0.0%
AST.NumLookupQualifiedInModule 3,266,761 3,282,544 15,783 0.48%
AST.NumLookupQualifiedInNominal 8,185,896 8,189,476 3,580 0.04%
AST.NumModuleLookupClassMember 15,754 15,754 0 0.0%
AST.NumModuleLookupValue 45,570,382 45,588,953 18,571 0.04%
AST.NumObjCMethods 24,701 24,701 0 0.0%
AST.NumPostfixOperators 23 23 0 0.0%
AST.NumPrecedenceGroups 25,668 25,668 0 0.0%
AST.NumPrefixOperators 99 99 0 0.0%
AST.NumReferencedDynamicNames 189 189 0 0.0%
AST.NumReferencedMemberNames 6,322,519 6,322,519 0 0.0%
AST.NumReferencedTopLevelNames 476,992 476,992 0 0.0%
AST.NumSourceBuffers 566,010 566,010 0 0.0%
AST.NumSourceLines 4,685,544 4,685,544 0 0.0%
AST.NumSourceLinesPerSecond 3,452,234 3,457,533 5,299 0.15%
AST.NumTotalClangImportedEntities 6,460,173 6,467,089 6,916 0.11%
AST.NumUnqualifiedLookup 4,382,434 4,382,705 271 0.01%
Driver.ChildrenMaxRSS 235,874,164,736 236,527,583,232 653,418,496 0.28%
Driver.DriverDepCascadingDynamic 0 0 0 0.0%
Driver.DriverDepCascadingExternal 0 0 0 0.0%
Driver.DriverDepCascadingMember 0 0 0 0.0%
Driver.DriverDepCascadingNominal 0 0 0 0.0%
Driver.DriverDepCascadingTopLevel 0 0 0 0.0%
Driver.DriverDepDynamic 0 0 0 0.0%
Driver.DriverDepExternal 0 0 0 0.0%
Driver.DriverDepMember 0 0 0 0.0%
Driver.DriverDepNominal 0 0 0 0.0%
Driver.DriverDepTopLevel 0 0 0 0.0%
Driver.NumDriverJobsRun 27,904 27,904 0 0.0%
Driver.NumDriverJobsSkipped 0 0 0 0.0%
Driver.NumProcessFailures 0 0 0 0.0%
Frontend.MaxMallocUsage 1,325,960,413,600 1,328,286,982,920 2,326,569,320 0.18%
Frontend.NumInstructionsExecuted 46,402,076,437,704 46,536,836,572,424 134,760,134,720 0.29%
Frontend.NumProcessFailures 0 0 0 0.0%
IRModule.NumIRAliases 197,197 197,197 0 0.0%
IRModule.NumIRBasicBlocks 6,800,554 6,800,554 0 0.0%
IRModule.NumIRComdatSymbols 0 0 0 0.0%
IRModule.NumIRFunctions 3,364,031 3,364,031 0 0.0%
IRModule.NumIRGlobals 3,522,315 3,522,315 0 0.0%
IRModule.NumIRIFuncs 0 0 0 0.0%
IRModule.NumIRInsts 86,650,633 86,650,633 0 0.0%
IRModule.NumIRNamedMetaData 134,220 134,220 0 0.0%
IRModule.NumIRValueSymbols 6,231,344 6,231,344 0 0.0%
LLVM.NumLLVMBytesOutput 1,786,906,002 1,786,897,678 -8,324 -0.0%
Parse.NumFunctionsParsed 267,971 267,971 0 0.0%
Parse.NumIterableDeclContextParsed 908,708 908,653 -55 -0.01%
SILModule.NumSILGenDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILGenFunctions 1,709,477 1,709,477 0 0.0%
SILModule.NumSILGenGlobalVariables 53,884 53,884 0 0.0%
SILModule.NumSILGenVtables 18,576 18,576 0 0.0%
SILModule.NumSILGenWitnessTables 72,169 72,169 0 0.0%
SILModule.NumSILOptDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILOptFunctions 2,441,619 2,441,619 0 0.0%
SILModule.NumSILOptGlobalVariables 55,508 55,508 0 0.0%
SILModule.NumSILOptVtables 31,332 31,332 0 0.0%
SILModule.NumSILOptWitnessTables 157,751 157,751 0 0.0%
Sema.AccessLevelRequest 12,196,526 12,252,394 55,868 0.46%
Sema.AttachedFunctionBuilderRequest 3 3 0 0.0%
Sema.AttachedPropertyWrapperTypeRequest 515,933 515,933 0 0.0%
Sema.AttachedPropertyWrappersRequest 2,173,991 2,173,991 0 0.0%
Sema.CollectOverriddenDeclsRequest 7,502,328 7,561,688 59,360 0.79%
Sema.CursorInfoRequest 0 0 0 0.0%
Sema.CustomAttrNominalRequest 3 3 0 0.0%
Sema.DefaultAndMaxAccessLevelRequest 57,753 57,745 -8 -0.01%
Sema.DefaultDefinitionTypeRequest 8,104 8,104 0 0.0%
Sema.DefaultTypeRequest 460,563 460,563 0 0.0%
Sema.EmittedMembersRequest 27,953 27,953 0 0.0%
Sema.EnumRawTypeRequest 25,102 25,102 0 0.0%
Sema.ExistentialConformsToSelfRequest 23,415 23,475 60 0.26%
Sema.ExistentialTypeSupportedRequest 17,731 17,731 0 0.0%
Sema.ExtendedNominalRequest 6,900,132 6,903,201 3,069 0.04%
Sema.FunctionBuilderTypeRequest 3 3 0 0.0%
Sema.GetDestructorRequest 28,360 28,360 0 0.0%
Sema.HasDynamicMemberLookupAttributeRequest 0 0 0 0.0%
Sema.InheritedDeclsReferencedRequest 6,235,576 6,246,664 11,088 0.18%
Sema.InheritedTypeRequest 332,529 332,738 209 0.06%
Sema.InitKindRequest 112,507 112,507 0 0.0%
Sema.IsAccessorTransparentRequest 320,248 320,248 0 0.0%
Sema.IsDeclApplicableRequest 0 0 0 0.0%
Sema.IsDynamicRequest 1,664,601 1,664,601 0 0.0%
Sema.IsFinalRequest 2,644,258 2,651,423 7,165 0.27%
Sema.IsGetterMutatingRequest 443,263 443,263 0 0.0%
Sema.IsImplicitlyUnwrappedOptionalRequest 2,534,251 2,536,210 1,959 0.08%
Sema.IsObjCRequest 1,606,611 1,605,917 -694 -0.04%
Sema.IsSetterMutatingRequest 350,119 350,119 0 0.0%
Sema.LazyStoragePropertyRequest 2,603 2,603 0 0.0%
Sema.MangleLocalTypeDeclRequest 506 506 0 0.0%
Sema.NamedLazyMemberLoadFailureCount 22,352 22,358 6 0.03%
Sema.NamedLazyMemberLoadSuccessCount 29,709,379 29,703,995 -5,384 -0.02%
Sema.NominalTypeLookupDirectCount 36,782,438 36,806,171 23,733 0.06%
Sema.NumAccessorBodiesSynthesized 189,296 189,296 0 0.0%
Sema.NumAccessorsSynthesized 296,229 296,229 0 0.0%
Sema.NumConformancesDeserialized 9,465,529 9,491,162 25,633 0.27%
Sema.NumConstraintScopes 24,778,486 24,782,282 3,796 0.02%
Sema.NumConstraintsConsideredForEdgeContraction 74,023,718 74,024,762 1,044 0.0%
Sema.NumCyclicOneWayComponentsCollapsed 0 0 0 0.0%
Sema.NumDeclsDeserialized 76,057,185 76,282,744 225,559 0.3%
Sema.NumDeclsTypechecked 1,403,524 1,403,524 0 0.0%
Sema.NumDeclsValidated 2,589,370 2,589,334 -36 -0.0%
Sema.NumFunctionsTypechecked 527,252 527,252 0 0.0%
Sema.NumGenericSignatureBuilders 1,495,074 1,489,143 -5,931 -0.4%
Sema.NumLazyGenericEnvironments 13,822,662 13,840,763 18,101 0.13%
Sema.NumLazyGenericEnvironmentsLoaded 323,627 323,822 195 0.06%
Sema.NumLazyIterableDeclContexts 9,756,151 9,762,261 6,110 0.06%
Sema.NumLazyRequirementSignatures 1,032,437 1,032,505 68 0.01%
Sema.NumLazyRequirementSignaturesLoaded 663,351 663,537 186 0.03%
Sema.NumLeafScopes 16,040,425 16,043,448 3,023 0.02%
Sema.NumTypesDeserialized 22,557,065 22,594,828 37,763 0.17%
Sema.NumTypesValidated 1,817,268 1,817,249 -19 -0.0%
Sema.NumUnloadedLazyIterableDeclContexts 6,306,991 6,304,281 -2,710 -0.04%
Sema.OpaqueReadOwnershipRequest 282,386 282,386 0 0.0%
Sema.OverriddenDeclsRequest 2,422,780 2,430,054 7,274 0.3%
Sema.PropertyWrapperBackingPropertyInfoRequest 510,547 510,547 0 0.0%
Sema.PropertyWrapperBackingPropertyTypeRequest 515,933 515,933 0 0.0%
Sema.PropertyWrapperMutabilityRequest 621,976 621,976 0 0.0%
Sema.PropertyWrapperTypeInfoRequest 1 1 0 0.0%
Sema.ProtocolRequiresClassRequest 92,406 92,618 212 0.23%
Sema.ProvideDefaultImplForRequest 7,502,328 7,561,688 59,360 0.79%
Sema.RangeInfoRequest 0 0 0 0.0%
Sema.RequirementRequest 112,224 112,221 -3 -0.0%
Sema.RequirementSignatureRequest 764,947 765,349 402 0.05%
Sema.RequiresOpaqueAccessorsRequest 1,325,458 1,325,458 0 0.0%
Sema.RequiresOpaqueModifyCoroutineRequest 273,633 273,633 0 0.0%
Sema.ResilienceExpansionRequest 1,843,184 1,843,159 -25 -0.0%
Sema.ResolveProtocolNameRequest 0 0 0 0.0%
Sema.RootAndResultTypeOfKeypathDynamicMemberRequest 0 0 0 0.0%
Sema.RootTypeOfKeypathDynamicMemberRequest 0 0 0 0.0%
Sema.SelfAccessKindRequest 6,373,583 6,373,612 29 0.0%
Sema.SelfBoundsFromWhereClauseRequest 8,097,859 8,113,842 15,983 0.2%
Sema.SetterAccessLevelRequest 151,118 151,118 0 0.0%
Sema.StorageImplInfoRequest 1,209,538 1,209,538 0 0.0%
Sema.StoredPropertiesAndMissingMembersRequest 32,443 32,443 0 0.0%
Sema.StoredPropertiesRequest 350,308 350,308 0 0.0%
Sema.StructuralTypeRequest 0 0 0 0.0%
Sema.SuperclassDeclRequest 501,155 501,599 444 0.09%
Sema.SuperclassTypeRequest 56,563 56,563 0 0.0%
Sema.SynthesizeAccessorRequest 296,229 296,229 0 0.0%
Sema.TypeCheckFunctionBodyUntilRequest 527,252 527,252 0 0.0%
Sema.TypeDeclsFromWhereClauseRequest 29,967 29,959 -8 -0.03%
Sema.TypeRelationCheckRequest 0 0 0 0.0%
Sema.USRGenerationRequest 8,717,957 8,778,120 60,163 0.69%
Sema.UnderlyingTypeDeclsReferencedRequest 297,059 297,705 646 0.22%

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 47,081,415,573,728 47,093,238,184,642 11,822,610,914 0.03%
LLVM.NumLLVMBytesOutput 1,541,597,514 1,541,598,442 928 0.0%
time.swift-driver.wall 8543.3s 8556.6s 13.3s 0.16%

release detailed

Regressed (0)
name old new delta delta_pct
Improved (1)
name old new delta delta_pct
Sema.NumGenericSignatureBuilders 302,395 295,642 -6,753 -2.23% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (20)
name old new delta delta_pct
AST.NumLoadedModules 30,333 30,333 0 0.0%
AST.NumTotalClangImportedEntities 1,231,537 1,231,537 0 0.0%
IRModule.NumIRBasicBlocks 5,632,953 5,632,953 0 0.0%
IRModule.NumIRFunctions 2,856,736 2,856,736 0 0.0%
IRModule.NumIRGlobals 3,026,851 3,026,851 0 0.0%
IRModule.NumIRInsts 53,112,869 53,112,869 0 0.0%
IRModule.NumIRValueSymbols 5,526,332 5,526,332 0 0.0%
LLVM.NumLLVMBytesOutput 1,541,597,514 1,541,598,442 928 0.0%
SILModule.NumSILGenFunctions 1,191,467 1,191,467 0 0.0%
SILModule.NumSILOptFunctions 1,681,840 1,681,840 0 0.0%
Sema.NumConformancesDeserialized 3,930,087 3,930,087 0 0.0%
Sema.NumConstraintScopes 24,309,822 24,309,822 0 0.0%
Sema.NumDeclsDeserialized 10,453,700 10,453,700 0 0.0%
Sema.NumDeclsValidated 1,826,146 1,826,146 0 0.0%
Sema.NumFunctionsTypechecked 530,874 530,874 0 0.0%
Sema.NumLazyGenericEnvironments 2,062,676 2,062,676 0 0.0%
Sema.NumLazyGenericEnvironmentsLoaded 35,748 35,748 0 0.0%
Sema.NumLazyIterableDeclContexts 1,330,132 1,330,132 0 0.0%
Sema.NumTypesDeserialized 5,621,264 5,621,264 0 0.0%
Sema.NumTypesValidated 947,067 947,067 0 0.0%

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.

2 participants