Skip to content

Commit 9bb87a5

Browse files
committed
[Profiler] NFC: Invert isUnmapped
IMO it's clearer this way.
1 parent b7d3f50 commit 9bb87a5

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

lib/SIL/IR/SILProfiler.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,58 +41,58 @@ static bool doesClosureHaveBody(AbstractClosureExpr *ACE) {
4141
return false;
4242
}
4343

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.
4747
if (N.getStartLoc().isInvalid() || N.getEndLoc().isInvalid()) {
4848
LLVM_DEBUG(llvm::dbgs()
4949
<< "Skipping ASTNode: invalid start/end locations\n");
50-
return true;
50+
return false;
5151
}
5252

5353
if (auto *E = N.dyn_cast<Expr *>()) {
5454
if (auto *CE = dyn_cast<AbstractClosureExpr>(E)) {
55-
// Only map closure expressions with bodies.
55+
// Only profile closure expressions with bodies.
5656
if (!doesClosureHaveBody(CE)) {
5757
LLVM_DEBUG(llvm::dbgs() << "Skipping ASTNode: closure without body\n");
58-
return true;
58+
return false;
5959
}
6060

61-
// Don't map implicit closures, unless they're autoclosures.
61+
// Don't profile implicit closures, unless they're autoclosures.
6262
if (!isa<AutoClosureExpr>(CE) && CE->isImplicit()) {
6363
LLVM_DEBUG(llvm::dbgs() << "Skipping ASTNode: implicit closure expr\n");
64-
return true;
64+
return false;
6565
}
6666
}
6767

68-
// Map all other kinds of expressions.
69-
return false;
68+
// Profile all other kinds of expressions.
69+
return true;
7070
}
7171

7272
auto *D = N.get<Decl *>();
7373
if (auto *AFD = dyn_cast<AbstractFunctionDecl>(D)) {
74-
// Don't map functions without bodies.
74+
// Don't profile functions without bodies.
7575
if (!AFD->hasBody()) {
7676
LLVM_DEBUG(llvm::dbgs() << "Skipping ASTNode: function without body\n");
77-
return true;
77+
return false;
7878
}
7979

80-
// Map implicit getters for lazy variables.
80+
// Profile implicit getters for lazy variables.
8181
if (auto *accessor = dyn_cast<AccessorDecl>(AFD)) {
8282
if (accessor->isImplicit() && accessor->isGetter() &&
8383
accessor->getStorage()->getAttrs().hasAttribute<LazyAttr>()) {
84-
return false;
84+
return true;
8585
}
8686
}
8787
}
8888

8989
// Skip any remaining implicit, or otherwise unsupported decls.
9090
if (D->isImplicit() || isa<EnumCaseDecl>(D)) {
9191
LLVM_DEBUG(llvm::dbgs() << "Skipping ASTNode: implicit/unsupported decl\n");
92-
return true;
92+
return false;
9393
}
9494

95-
return false;
95+
return true;
9696
}
9797

9898
namespace swift {
@@ -102,7 +102,7 @@ bool doesASTRequireProfiling(SILModule &M, ASTNode N) {
102102
if (Opts.UseProfile.empty() && !Opts.GenerateProfile)
103103
return false;
104104

105-
return !isUnmapped(N);
105+
return shouldProfile(N);
106106
}
107107
} // namespace swift
108108

0 commit comments

Comments
 (0)