-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Teach EagerSpecializer how to use the new form of the @_specialize attribute #7277
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
Teach EagerSpecializer how to use the new form of the @_specialize attribute #7277
Conversation
1f063d4
to
5365bda
Compare
@swift-ci please smoke test |
assert(!CanSILFuncTy->isPolymorphic()); | ||
auto CalleeSubstFnTy = CanSILFuncTy; | ||
ArrayRef<Substitution> Subs; | ||
//assert(!CanSILFuncTy->isPolymorphic()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line?
assert(!CanSILFuncTy->isPolymorphic()); | ||
return Builder.createApply(CalleeFunc->getLocation(), FuncRefInst, CallArgs, | ||
false); | ||
//assert(!CanSILFuncTy->isPolymorphic()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
5365bda
to
1683f05
Compare
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
Sorry, the merge conflicts are from the |
1683f05
to
fe4a98f
Compare
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
…ttribute and partial specializations.
…tribute In addition to supporting the creation of full specializations, the EagerSpecializer changes contain some code for generating the layout-constrained partial specializations as well.
fe4a98f
to
a8ae2bd
Compare
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
@slavapestov OK, so this is supposed to be a working version of the @_specialize. I implemented the code generation for the dynamic dispatch and IRGen changes. Tests are updated to test these new features. The function |
This allows IRGen to use direct loads and stores instead of calling value witness tables.
a8ae2bd
to
cbe4b0d
Compare
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
d521d0a
to
072ed25
Compare
@swift-ci please smoke test Linux |
1 similar comment
@swift-ci please smoke test Linux |
072ed25
to
d48d171
Compare
@swift-ci please smoke test Linux |
1 similar comment
@swift-ci please smoke test Linux |
@swift-ci please smoke test OS X |
@swift-ci please test |
1 similar comment
@swift-ci please test |
Build failed |
Build failed |
Build failed |
d48d171
to
7a0013a
Compare
@swift-ci please test |
1 similar comment
@swift-ci please test |
Build failed |
Build failed |
7a0013a
to
e05dee1
Compare
@swift-ci please test |
1 similar comment
@swift-ci please test |
lib/SILOptimizer/Utils/Generics.cpp
Outdated
FnTy->getOptionalErrorResult(), M.getASTContext()); | ||
|
||
// This is an interface type. It should not have any archetypes. | ||
if (NewFnTy->hasArchetype()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these three lines
lib/SILOptimizer/Utils/Generics.cpp
Outdated
assert(FirstType && SecondType); | ||
|
||
bool isFirstTypeNonConcrete = | ||
FirstType->hasArchetype() || FirstType->hasTypeParameter(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasArchetype should always be false -- can you assert?
lib/SILOptimizer/Utils/Generics.cpp
Outdated
bool isSecondTypeNonConcrete = | ||
SecondType->hasArchetype() || SecondType->hasTypeParameter(); | ||
// Only one of the types should be concrete. | ||
assert((isFirstTypeNonConcrete ^ isSecondTypeNonConcrete) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would find != more readable than ^ here
lib/SILOptimizer/Utils/Generics.cpp
Outdated
|
||
for (auto &Req : Requirements) { | ||
if (Req.getKind() == RequirementKind::SameType) { | ||
auto CallerArchetype = dyn_cast<SubstitutableType>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dyn_cast can return null; either use cast or handle the null case
->getCanonicalType()); | ||
// Remember that a given generic parameter is mapped | ||
// to a concrete type. | ||
CallerArchetypeToInterfaceMap.addSubstitution( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addSubstitution() is going to be private. I just refactored a dozen usages of it, please don't add new ones. Substitution maps should be constructed by using GenericSignature::getSubstitutionMap() or GenericEnvironment::getSubstitutionMap()
lib/SILOptimizer/Utils/Generics.cpp
Outdated
for (auto Sub : ForwardingSubs) { | ||
auto ClonerSub = Sub.subst( | ||
SM, QuerySubstitutionMap{ClonerArchetypeToConcreteMap}, | ||
LookUpConformanceInModule(SM)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a FIXME comment to clean up the module conformance lookup (for me :))
// Substitute into forwarding substitutions to get the cloner substitutions | ||
// and substitutions to be used by the caller for calling the specialized | ||
// function. | ||
SmallVector<Substitution, 4> ClonerSubsList; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead, construct these arrays by calling GenericSignature::getSubstitutions() or GenericEnvironment::getSubstitutions(). Otherwise you're relying on them having entries in the same order as the forwarding substitutions.
Build failed |
@swift-ci please test |
1 similar comment
@swift-ci please test |
Ok, I think this is good to go now. |
Build failed |
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
Teach EagerSpecializer how to use the new form of the @_specialize attribute
In addition to supporting the creation of full specializations, the EagerSpecializer changes contain some code for generating the layout-constrained partial specializations as well.