@@ -41,58 +41,58 @@ static bool doesClosureHaveBody(AbstractClosureExpr *ACE) {
41
41
return false ;
42
42
}
43
43
44
- // / Check whether a root AST node is unmapped, i.e not profiled.
45
- static bool isUnmapped (ASTNode N) {
46
- // Do not map AST nodes with invalid source locations.
44
+ // / Check whether a root AST node should be profiled.
45
+ static bool shouldProfile (ASTNode N) {
46
+ // Do not profile AST nodes with invalid source locations.
47
47
if (N.getStartLoc ().isInvalid () || N.getEndLoc ().isInvalid ()) {
48
48
LLVM_DEBUG (llvm::dbgs ()
49
49
<< " Skipping ASTNode: invalid start/end locations\n " );
50
- return true ;
50
+ return false ;
51
51
}
52
52
53
53
if (auto *E = N.dyn_cast <Expr *>()) {
54
54
if (auto *CE = dyn_cast<AbstractClosureExpr>(E)) {
55
- // Only map closure expressions with bodies.
55
+ // Only profile closure expressions with bodies.
56
56
if (!doesClosureHaveBody (CE)) {
57
57
LLVM_DEBUG (llvm::dbgs () << " Skipping ASTNode: closure without body\n " );
58
- return true ;
58
+ return false ;
59
59
}
60
60
61
- // Don't map implicit closures, unless they're autoclosures.
61
+ // Don't profile implicit closures, unless they're autoclosures.
62
62
if (!isa<AutoClosureExpr>(CE) && CE->isImplicit ()) {
63
63
LLVM_DEBUG (llvm::dbgs () << " Skipping ASTNode: implicit closure expr\n " );
64
- return true ;
64
+ return false ;
65
65
}
66
66
}
67
67
68
- // Map all other kinds of expressions.
69
- return false ;
68
+ // Profile all other kinds of expressions.
69
+ return true ;
70
70
}
71
71
72
72
auto *D = N.get <Decl *>();
73
73
if (auto *AFD = dyn_cast<AbstractFunctionDecl>(D)) {
74
- // Don't map functions without bodies.
74
+ // Don't profile functions without bodies.
75
75
if (!AFD->hasBody ()) {
76
76
LLVM_DEBUG (llvm::dbgs () << " Skipping ASTNode: function without body\n " );
77
- return true ;
77
+ return false ;
78
78
}
79
79
80
- // Map implicit getters for lazy variables.
80
+ // Profile implicit getters for lazy variables.
81
81
if (auto *accessor = dyn_cast<AccessorDecl>(AFD)) {
82
82
if (accessor->isImplicit () && accessor->isGetter () &&
83
83
accessor->getStorage ()->getAttrs ().hasAttribute <LazyAttr>()) {
84
- return false ;
84
+ return true ;
85
85
}
86
86
}
87
87
}
88
88
89
89
// Skip any remaining implicit, or otherwise unsupported decls.
90
90
if (D->isImplicit () || isa<EnumCaseDecl>(D)) {
91
91
LLVM_DEBUG (llvm::dbgs () << " Skipping ASTNode: implicit/unsupported decl\n " );
92
- return true ;
92
+ return false ;
93
93
}
94
94
95
- return false ;
95
+ return true ;
96
96
}
97
97
98
98
namespace swift {
@@ -102,7 +102,7 @@ bool doesASTRequireProfiling(SILModule &M, ASTNode N) {
102
102
if (Opts.UseProfile .empty () && !Opts.GenerateProfile )
103
103
return false ;
104
104
105
- return ! isUnmapped (N);
105
+ return shouldProfile (N);
106
106
}
107
107
} // namespace swift
108
108
0 commit comments