Skip to content

[Function builders] Add support for buildExpression(). #27716

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

If a function builder type has a static method buildExpression(), use
it to pass through each expression whose value will become part of the
final result. This is part of the function builders pitch that had not
yet been implemented.

If a function builder type has a static method buildExpression(), use
it to pass through each expression whose value will become part of the
final result. This is part of the function builders pitch that had not
yet been implemented.
@DougGregor DougGregor requested review from rjmccall and xedin October 16, 2019 05:27
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please test compiler performance

Copy link
Contributor

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, the real blocker for buildExpression is that we need to transform single-expression closures, but this is certainly a necessary step and generally looks right to me.

if (builderSupports(ctx.Id_buildExpression)) {
expr = buildCallIfWanted(expr->getLoc(), ctx.Id_buildExpression,
{ expr }, { Identifier() },
/*allowOneWay=*/true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know the parameter name is existing code, but why is this "allow" one-way, since it's an unconditional instruction to make the result one-way?

Anyway, this seems like the right interaction with one-way, although arguably it would be clearer in code if that was done unconditionally as a separate step.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It used to be conditional, and I just removed the staging flag. I can clean this up

@DougGregor
Copy link
Member Author

@xedin is going to look into single-expression closures. We need to delay constraint generation for single-expression closures until we know which parameter it will get matched with.

@DougGregor DougGregor merged commit 64d0b18 into swiftlang:master Oct 16, 2019
@DougGregor DougGregor deleted the function-builders-build-expression branch October 16, 2019 19:53
@swift-ci
Copy link
Contributor

Summary for master full

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

No regressions above thresholds

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 47,169,307,505,006 47,212,942,431,488 43,634,926,482 0.09%
LLVM.NumLLVMBytesOutput 1,790,608,924 1,790,607,820 -1,104 -0.0%
time.swift-driver.wall 5459.1s 5455.8s -3.3s -0.06%

debug-batch detailed

Regressed (0)
name old new delta delta_pct
Improved (2)
name old new delta delta_pct
Driver.NumDriverPipePolls 55,811 54,741 -1,070 -1.92% ✅
Driver.NumDriverPipeReads 43,064 41,986 -1,078 -2.5% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (181)
name old new delta delta_pct
AST.ImportSetCacheHit 1,746,557 1,746,303 -254 -0.01%
AST.ImportSetCacheMiss 617,166 617,110 -56 -0.01%
AST.ImportSetFoldHit 178,259 178,235 -24 -0.01%
AST.ImportSetFoldMiss 438,907 438,874 -33 -0.01%
AST.ModuleShadowCacheHit 2,344 2,344 0 0.0%
AST.ModuleShadowCacheMiss 1,657 1,657 0 0.0%
AST.ModuleVisibilityCacheHit 305,515 305,515 0 0.0%
AST.ModuleVisibilityCacheMiss 23,499 23,499 0 0.0%
AST.NumASTBytesAllocated 63,131,690,024 63,432,248,052 300,558,028 0.48%
AST.NumASTScopeLookups 4,238,726 4,238,828 102 0.0%
AST.NumBraceStmtASTScopeExpansions 479,933 479,933 0 0.0%
AST.NumBraceStmtASTScopes 479,933 479,933 0 0.0%
AST.NumDecls 140,724 140,724 0 0.0%
AST.NumDependencies 426,390 426,410 20 0.0%
AST.NumInfixOperators 53,865 53,865 0 0.0%
AST.NumIterableTypeBodyASTScopeExpansions 266,896 266,904 8 0.0%
AST.NumIterableTypeBodyASTScopes 351,392 351,509 117 0.03%
AST.NumLinkLibraries 0 0 0 0.0%
AST.NumLoadedModules 399,963 399,963 0 0.0%
AST.NumLocalTypeDecls 253 253 0 0.0%
AST.NumLookupInModule 6,649,626 6,642,270 -7,356 -0.11%
AST.NumLookupQualifiedInAnyObject 291 291 0 0.0%
AST.NumLookupQualifiedInModule 3,165,551 3,158,103 -7,448 -0.24%
AST.NumLookupQualifiedInNominal 8,048,588 8,055,819 7,231 0.09%
AST.NumModuleLookupClassMember 7,167 7,167 0 0.0%
AST.NumModuleLookupValue 48,786,829 48,779,384 -7,445 -0.02%
AST.NumObjCMethods 24,701 24,701 0 0.0%
AST.NumPostfixOperators 49 49 0 0.0%
AST.NumPrecedenceGroups 25,744 25,744 0 0.0%
AST.NumPrefixOperators 99 99 0 0.0%
AST.NumReferencedDynamicNames 199 199 0 0.0%
AST.NumReferencedMemberNames 6,348,332 6,348,332 0 0.0%
AST.NumReferencedTopLevelNames 478,114 478,114 0 0.0%
AST.NumSourceBuffers 567,714 567,714 0 0.0%
AST.NumSourceLines 4,697,936 4,697,936 0 0.0%
AST.NumSourceLinesPerSecond 3,407,412 3,411,825 4,413 0.13%
AST.NumTotalClangImportedEntities 6,290,478 6,291,539 1,061 0.02%
AST.NumUnqualifiedLookup 4,384,071 4,384,173 102 0.0%
Driver.ChildrenMaxRSS 238,736,824,320 238,192,539,648 -544,284,672 -0.23%
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,879 27,879 0 0.0%
Driver.NumDriverJobsSkipped 0 0 0 0.0%
Driver.NumProcessFailures 0 0 0 0.0%
Frontend.MaxMallocUsage 1,153,425,563,768 1,155,414,871,152 1,989,307,384 0.17%
Frontend.NumInstructionsExecuted 47,169,307,505,006 47,212,942,431,488 43,634,926,482 0.09%
Frontend.NumProcessFailures 0 0 0 0.0%
IRModule.NumIRAliases 197,463 197,463 0 0.0%
IRModule.NumIRBasicBlocks 6,822,015 6,822,015 0 0.0%
IRModule.NumIRComdatSymbols 0 0 0 0.0%
IRModule.NumIRFunctions 3,355,626 3,355,626 0 0.0%
IRModule.NumIRGlobals 3,652,949 3,652,949 0 0.0%
IRModule.NumIRIFuncs 0 0 0 0.0%
IRModule.NumIRInsts 86,876,059 86,876,059 0 0.0%
IRModule.NumIRNamedMetaData 134,575 134,575 0 0.0%
IRModule.NumIRValueSymbols 6,352,418 6,352,418 0 0.0%
LLVM.NumLLVMBytesOutput 1,790,608,924 1,790,607,820 -1,104 -0.0%
Parse.NumFunctionsParsed 267,931 267,931 0 0.0%
Parse.NumIterableDeclContextParsed 914,511 914,507 -4 -0.0%
Parse.ParseAbstractFunctionBodyRequest 247,119 247,119 0 0.0%
Parse.ParseMembersRequest 748,844 748,840 -4 -0.0%
SILModule.NumSILGenDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILGenFunctions 1,714,182 1,714,182 0 0.0%
SILModule.NumSILGenGlobalVariables 53,914 53,914 0 0.0%
SILModule.NumSILGenVtables 18,663 18,663 0 0.0%
SILModule.NumSILGenWitnessTables 72,471 72,471 0 0.0%
SILModule.NumSILOptDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILOptFunctions 2,452,773 2,452,773 0 0.0%
SILModule.NumSILOptGlobalVariables 55,524 55,524 0 0.0%
SILModule.NumSILOptVtables 31,498 31,498 0 0.0%
SILModule.NumSILOptWitnessTables 158,424 158,424 0 0.0%
Sema.AbstractGenericSignatureRequest 26,484 26,484 0 0.0%
Sema.AccessLevelRequest 12,072,706 12,164,293 91,587 0.76%
Sema.AttachedFunctionBuilderRequest 3 3 0 0.0%
Sema.AttachedPropertyWrapperTypeRequest 536,994 536,994 0 0.0%
Sema.AttachedPropertyWrappersRequest 2,087,679 2,087,679 0 0.0%
Sema.ClassAncestryFlagsRequest 109,921 109,921 0 0.0%
Sema.CollectOverriddenDeclsRequest 7,236,144 7,278,074 41,930 0.58%
Sema.CursorInfoRequest 0 0 0 0.0%
Sema.CustomAttrNominalRequest 3 3 0 0.0%
Sema.DefaultAndMaxAccessLevelRequest 58,252 58,258 6 0.01%
Sema.DefaultDefinitionTypeRequest 8,166 8,166 0 0.0%
Sema.DefaultTypeRequest 463,141 463,141 0 0.0%
Sema.EmittedMembersRequest 28,105 28,105 0 0.0%
Sema.EnumRawTypeRequest 25,063 25,063 0 0.0%
Sema.EnumRawValuesRequest 10,115 10,115 0 0.0%
Sema.ExistentialConformsToSelfRequest 24,599 24,621 22 0.09%
Sema.ExistentialTypeSupportedRequest 17,765 17,765 0 0.0%
Sema.ExpandASTScopeRequest 7,282,706 7,282,882 176 0.0%
Sema.ExtendedNominalRequest 879,505 879,505 0 0.0%
Sema.ExtendedTypeRequest 82,895 82,898 3 0.0%
Sema.FunctionBuilderTypeRequest 3 3 0 0.0%
Sema.FunctionOperatorRequest 73,137 73,137 0 0.0%
Sema.GenericParamListRequest 16,652,045 16,706,823 54,778 0.33%
Sema.GenericSignatureRequest 9,559,631 9,563,781 4,150 0.04%
Sema.GetDestructorRequest 28,499 28,499 0 0.0%
Sema.HasDynamicMemberLookupAttributeRequest 0 0 0 0.0%
Sema.InferredGenericSignatureRequest 185,816 185,829 13 0.01%
Sema.InheritedDeclsReferencedRequest 6,177,209 6,190,975 13,766 0.22%
Sema.InheritedTypeRequest 309,581 309,528 -53 -0.02%
Sema.InitKindRequest 100,485 100,485 0 0.0%
Sema.IsABICompatibleOverrideRequest 136,898 136,898 0 0.0%
Sema.IsAccessorTransparentRequest 320,498 320,498 0 0.0%
Sema.IsDeclApplicableRequest 0 0 0 0.0%
Sema.IsDynamicRequest 1,668,237 1,668,237 0 0.0%
Sema.IsFinalRequest 2,635,909 2,642,544 6,635 0.25%
Sema.IsGetterMutatingRequest 438,479 438,479 0 0.0%
Sema.IsImplicitlyUnwrappedOptionalRequest 2,526,921 2,525,605 -1,316 -0.05%
Sema.IsObjCRequest 1,596,479 1,597,967 1,488 0.09%
Sema.IsSetterMutatingRequest 345,253 345,253 0 0.0%
Sema.IsStaticRequest 4,001,118 4,001,471 353 0.01%
Sema.LazyStoragePropertyRequest 2,604 2,604 0 0.0%
Sema.LookupPrecedenceGroupRequest 176,106 176,106 0 0.0%
Sema.MangleLocalTypeDeclRequest 506 506 0 0.0%
Sema.NamedLazyMemberLoadFailureCount 22,349 22,344 -5 -0.02%
Sema.NamedLazyMemberLoadSuccessCount 30,771,378 30,787,967 16,589 0.05%
Sema.NeedsNewVTableEntryRequest 695,177 695,177 0 0.0%
Sema.NominalTypeLookupDirectCount 36,484,709 36,515,238 30,529 0.08%
Sema.NumAccessorBodiesSynthesized 189,454 189,454 0 0.0%
Sema.NumAccessorsSynthesized 296,472 296,472 0 0.0%
Sema.NumConformancesDeserialized 9,461,399 9,502,825 41,426 0.44%
Sema.NumConstraintScopes 27,044,019 27,047,774 3,755 0.01%
Sema.NumConstraintsConsideredForEdgeContraction 86,127,156 86,127,170 14 0.0%
Sema.NumCyclicOneWayComponentsCollapsed 0 0 0 0.0%
Sema.NumDeclsDeserialized 75,559,604 75,788,169 228,565 0.3%
Sema.NumDeclsTypechecked 1,401,140 1,401,140 0 0.0%
Sema.NumDeclsValidated 6,149,950 6,163,192 13,242 0.22%
Sema.NumFunctionsTypechecked 528,694 528,694 0 0.0%
Sema.NumGenericSignatureBuilders 1,442,278 1,446,266 3,988 0.28%
Sema.NumLazyIterableDeclContexts 9,737,955 9,753,795 15,840 0.16%
Sema.NumLazyRequirementSignatures 1,028,665 1,029,387 722 0.07%
Sema.NumLazyRequirementSignaturesLoaded 663,404 663,824 420 0.06%
Sema.NumLeafScopes 17,403,644 17,407,044 3,400 0.02%
Sema.NumTypesDeserialized 22,423,940 22,479,492 55,552 0.25%
Sema.NumTypesValidated 1,533,255 1,533,257 2 0.0%
Sema.NumUnloadedLazyIterableDeclContexts 6,296,242 6,293,660 -2,582 -0.04%
Sema.OpaqueReadOwnershipRequest 282,807 282,807 0 0.0%
Sema.OpaqueResultTypeRequest 0 0 0 0.0%
Sema.OperatorPrecedenceGroupRequest 747 747 0 0.0%
Sema.OverriddenDeclsRequest 2,475,235 2,481,558 6,323 0.26%
Sema.ParamSpecifierRequest 1,313,222 1,313,224 2 0.0%
Sema.PropertyWrapperBackingPropertyInfoRequest 531,605 531,605 0 0.0%
Sema.PropertyWrapperBackingPropertyTypeRequest 536,994 536,994 0 0.0%
Sema.PropertyWrapperMutabilityRequest 612,133 612,133 0 0.0%
Sema.PropertyWrapperTypeInfoRequest 1 1 0 0.0%
Sema.ProtocolRequiresClassRequest 90,941 90,918 -23 -0.03%
Sema.ProvideDefaultImplForRequest 7,236,144 7,278,074 41,930 0.58%
Sema.RangeInfoRequest 0 0 0 0.0%
Sema.RequirementRequest 112,855 112,857 2 0.0%
Sema.RequirementSignatureRequest 742,871 743,253 382 0.05%
Sema.RequiresOpaqueAccessorsRequest 1,317,080 1,317,080 0 0.0%
Sema.RequiresOpaqueModifyCoroutineRequest 274,090 274,090 0 0.0%
Sema.ResilienceExpansionRequest 1,864,422 1,864,437 15 0.0%
Sema.ResolveProtocolNameRequest 0 0 0 0.0%
Sema.ResultTypeRequest 693,229 693,237 8 0.0%
Sema.RootAndResultTypeOfKeypathDynamicMemberRequest 0 0 0 0.0%
Sema.RootTypeOfKeypathDynamicMemberRequest 0 0 0 0.0%
Sema.SelfAccessKindRequest 6,225,244 6,225,822 578 0.01%
Sema.SelfBoundsFromWhereClauseRequest 8,032,421 8,055,378 22,957 0.29%
Sema.SetterAccessLevelRequest 145,972 145,972 0 0.0%
Sema.StorageImplInfoRequest 1,427,450 1,427,450 0 0.0%
Sema.StoredPropertiesAndMissingMembersRequest 32,601 32,601 0 0.0%
Sema.StoredPropertiesRequest 350,653 350,653 0 0.0%
Sema.StructuralTypeRequest 2,319 2,319 0 0.0%
Sema.SuperclassDeclRequest 500,909 501,341 432 0.09%
Sema.SuperclassTypeRequest 56,515 56,515 0 0.0%
Sema.SynthesizeAccessorRequest 296,472 296,472 0 0.0%
Sema.TypeCheckFunctionBodyUntilRequest 528,694 528,694 0 0.0%
Sema.TypeDeclsFromWhereClauseRequest 30,375 30,381 6 0.02%
Sema.TypeRelationCheckRequest 0 0 0 0.0%
Sema.USRGenerationRequest 8,633,773 8,678,070 44,297 0.51%
Sema.UnderlyingTypeDeclsReferencedRequest 269,004 269,046 42 0.02%
Sema.UnderlyingTypeRequest 37,189 37,189 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 49,072,390,997,306 49,019,980,678,578 -52,410,318,728 -0.11%
LLVM.NumLLVMBytesOutput 1,943,829,940 1,943,829,148 -792 -0.0%
time.swift-driver.wall 9071.8s 9088.9s 17.1s 0.19%

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) (19)
name old new delta delta_pct
AST.NumLoadedModules 30,351 30,351 0 0.0%
AST.NumTotalClangImportedEntities 1,218,165 1,218,165 0 0.0%
IRModule.NumIRBasicBlocks 5,531,615 5,531,615 0 0.0%
IRModule.NumIRFunctions 2,858,149 2,858,149 0 0.0%
IRModule.NumIRGlobals 3,180,255 3,180,255 0 0.0%
IRModule.NumIRInsts 53,517,634 53,517,634 0 0.0%
IRModule.NumIRValueSymbols 5,681,517 5,681,517 0 0.0%
LLVM.NumLLVMBytesOutput 1,943,829,940 1,943,829,148 -792 -0.0%
SILModule.NumSILGenFunctions 1,195,184 1,195,184 0 0.0%
SILModule.NumSILOptFunctions 1,711,295 1,711,295 0 0.0%
Sema.NumConformancesDeserialized 3,802,718 3,802,718 0 0.0%
Sema.NumConstraintScopes 26,603,787 26,603,787 0 0.0%
Sema.NumDeclsDeserialized 10,416,908 10,416,908 0 0.0%
Sema.NumDeclsValidated 2,453,916 2,453,916 0 0.0%
Sema.NumFunctionsTypechecked 532,316 532,316 0 0.0%
Sema.NumGenericSignatureBuilders 273,682 273,682 0 0.0%
Sema.NumLazyIterableDeclContexts 1,326,066 1,326,066 0 0.0%
Sema.NumTypesDeserialized 5,252,893 5,252,893 0 0.0%
Sema.NumTypesValidated 825,872 825,872 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.

3 participants