Skip to content

Commit c27bb33

Browse files
committed
[Profiler] Simplify CounterExpr
This class is more or less just duplicating LLVM's `Counter` class, as such we can just wrap it directly and avoid having to construct it later. This also avoids building up unnecessarily large counter expressions and doing quadratic amounts of counter simplification work that we were previously doing. rdar://118185163
1 parent 682e06c commit c27bb33

File tree

3 files changed

+75
-176
lines changed

3 files changed

+75
-176
lines changed

include/swift/SIL/SILCoverageMap.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,16 @@ class SILCoverageMap : public llvm::ilist_node<SILCoverageMap>,
127127
return Expressions;
128128
}
129129

130-
void printCounter(llvm::raw_ostream &OS, llvm::coverage::Counter C) const;
130+
/// Print a given profiling counter expression, given the reference to the
131+
/// counter, and the list of counters it may reference.
132+
static void
133+
printCounter(llvm::raw_ostream &OS, llvm::coverage::Counter C,
134+
ArrayRef<llvm::coverage::CounterExpression> Expressions);
135+
136+
/// Print a given profiling counter expression.
137+
void printCounter(llvm::raw_ostream &OS, llvm::coverage::Counter C) const {
138+
printCounter(OS, C, getExpressions());
139+
}
131140

132141
/// Print the coverage map.
133142
void print(llvm::raw_ostream &OS, bool Verbose = false,

lib/SIL/IR/SILCoverageMap.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ struct Printer {
8686
};
8787
} // end anonymous namespace
8888

89-
void SILCoverageMap::printCounter(llvm::raw_ostream &OS,
90-
llvm::coverage::Counter C) const {
91-
OS << Printer(C, getExpressions());
89+
void SILCoverageMap::printCounter(
90+
llvm::raw_ostream &OS, llvm::coverage::Counter C,
91+
ArrayRef<llvm::coverage::CounterExpression> Expressions) {
92+
OS << Printer(C, Expressions);
9293
}

0 commit comments

Comments
 (0)