@@ -36,9 +36,10 @@ class ProfileCounterRef final {
3636public:
3737 enum class Kind : uint8_t {
3838 // / References an ASTNode.
39- // TODO: This is the currently the only kind, but it will be expanded in
40- // the future for e.g top-level entry and error branches.
41- Node
39+ Node,
40+
41+ // / References the error branch for an apply or access.
42+ ErrorBranch
4243 };
4344
4445private:
@@ -56,6 +57,12 @@ class ProfileCounterRef final {
5657 return ProfileCounterRef (node, Kind::Node);
5758 }
5859
60+ // / A profile counter that is associated with the error branch of a particular
61+ // / error-throwing AST node.
62+ static ProfileCounterRef errorBranchOf (ASTNode node) {
63+ return ProfileCounterRef (node, Kind::ErrorBranch);
64+ }
65+
5966 // / Retrieve the corresponding location of the counter.
6067 SILLocation getLocation () const ;
6168
@@ -135,11 +142,13 @@ class SILProfiler : public SILAllocated<SILProfiler> {
135142 // / Get the number of region counters.
136143 unsigned getNumRegionCounters () const { return NumRegionCounters; }
137144
138- // / Get the mapping from a \c ProfileCounterRef to its corresponding
139- // / profile counter.
140- const llvm::DenseMap<ProfileCounterRef, unsigned > &
141- getRegionCounterMap () const {
142- return RegionCounterMap;
145+ // / Retrieve the counter index for a given counter reference, asserting that
146+ // / it is present.
147+ unsigned getCounterIndexFor (ProfileCounterRef ref);
148+
149+ // / Whether a counter has been recorded for the given counter reference.
150+ bool hasCounterFor (ProfileCounterRef ref) {
151+ return RegionCounterMap.contains (ref);
143152 }
144153
145154private:
0 commit comments