Skip to content

Commit c2b2667

Browse files
committed
AST: Fast path to skip evaluating requests on local variables without property wrappers
1 parent 01b3965 commit c2b2667

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

lib/AST/Decl.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5910,6 +5910,11 @@ void VarDecl::visitAuxiliaryDecls(llvm::function_ref<void(VarDecl *)> visit) con
59105910
if (getDeclContext()->isTypeContext())
59115911
return;
59125912

5913+
// Avoid request evaluator overhead in the common case where there's
5914+
// no wrapper.
5915+
if (!getAttrs().hasAttribute<CustomAttr>())
5916+
return;
5917+
59135918
if (auto *backingVar = getPropertyWrapperBackingProperty())
59145919
visit(backingVar);
59155920

lib/SILGen/SILGenDecl.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,17 +1220,21 @@ void SILGenFunction::visitPatternBindingDecl(PatternBindingDecl *PBD) {
12201220
void SILGenFunction::visitVarDecl(VarDecl *D) {
12211221
// We handle emitting the variable storage when we see the pattern binding.
12221222

1223-
// Emit the property wrapper backing initializer if necessary.
1224-
auto wrapperInfo = D->getPropertyWrapperBackingPropertyInfo();
1225-
if (wrapperInfo && wrapperInfo.initializeFromOriginal)
1226-
SGM.emitPropertyWrapperBackingInitializer(D);
1223+
// Avoid request evaluator overhead in the common case where there's
1224+
// no wrapper.
1225+
if (D->getAttrs().hasAttribute<CustomAttr>()) {
1226+
// Emit the property wrapper backing initializer if necessary.
1227+
auto wrapperInfo = D->getPropertyWrapperBackingPropertyInfo();
1228+
if (wrapperInfo && wrapperInfo.initializeFromOriginal)
1229+
SGM.emitPropertyWrapperBackingInitializer(D);
12271230

1228-
D->visitAuxiliaryDecls([&](VarDecl *var) {
1229-
if (auto *patternBinding = var->getParentPatternBinding())
1230-
visitPatternBindingDecl(patternBinding);
1231+
D->visitAuxiliaryDecls([&](VarDecl *var) {
1232+
if (auto *patternBinding = var->getParentPatternBinding())
1233+
visitPatternBindingDecl(patternBinding);
12311234

1232-
visit(var);
1233-
});
1235+
visit(var);
1236+
});
1237+
}
12341238

12351239
// Emit the variable's accessors.
12361240
D->visitEmittedAccessors([&](AccessorDecl *accessor) {

0 commit comments

Comments
 (0)