Skip to content

Commit 3a3a98e

Browse files
committed
[Profiler] NFC: Constify LoadedCounts
1 parent 1b83307 commit 3a3a98e

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lib/SIL/IR/SILProfiler.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -467,17 +467,20 @@ struct PGOMapping : public ASTWalker {
467467
/// The next counter value to assign.
468468
unsigned NextCounter;
469469

470+
/// The loaded counter data.
471+
const llvm::InstrProfRecord &LoadedCounts;
472+
470473
/// The map of statements to counters.
471474
llvm::DenseMap<ASTNode, ProfileCounter> &LoadedCounterMap;
472-
llvm::Expected<llvm::InstrProfRecord> &LoadedCounts;
473475
llvm::DenseMap<ASTNode, ASTNode> &CondToParentMap;
474476
llvm::DenseMap<ASTNode, unsigned> CounterMap;
475477

476478
PGOMapping(llvm::DenseMap<ASTNode, ProfileCounter> &LoadedCounterMap,
477-
llvm::Expected<llvm::InstrProfRecord> &LoadedCounts,
479+
const llvm::InstrProfRecord &LoadedCounts,
478480
llvm::DenseMap<ASTNode, ASTNode> &RegionCondToParentMap)
479-
: NextCounter(0), LoadedCounterMap(LoadedCounterMap),
480-
LoadedCounts(LoadedCounts), CondToParentMap(RegionCondToParentMap) {}
481+
: NextCounter(0), LoadedCounts(LoadedCounts),
482+
LoadedCounterMap(LoadedCounterMap),
483+
CondToParentMap(RegionCondToParentMap) {}
481484

482485
unsigned getParentCounter() const {
483486
if (Parent.isNull())
@@ -516,7 +519,7 @@ struct PGOMapping : public ASTWalker {
516519
"region does not have an associated counter");
517520

518521
unsigned CounterIndexForFunc = CounterIt->second;
519-
return LoadedCounts->Counts[CounterIndexForFunc];
522+
return LoadedCounts.Counts[CounterIndexForFunc];
520523
}
521524

522525
bool walkToDeclPre(Decl *D) override {
@@ -552,7 +555,7 @@ struct PGOMapping : public ASTWalker {
552555
if (!parent) {
553556
auto thenVal = thenCount.getValue();
554557
for (auto pCount = NextCounter - 1; pCount > 0; --pCount) {
555-
auto cCount = LoadedCounts->Counts[pCount];
558+
auto cCount = LoadedCounts.Counts[pCount];
556559
if (cCount > thenVal) {
557560
count = cCount;
558561
break;
@@ -642,7 +645,7 @@ struct PGOMapping : public ASTWalker {
642645
if (!parent) {
643646
auto thenVal = thenCount.getValue();
644647
for (auto pCount = NextCounter - 1; pCount > 0; --pCount) {
645-
auto cCount = LoadedCounts->Counts[pCount];
648+
auto cCount = LoadedCounts.Counts[pCount];
646649
if (cCount > thenVal) {
647650
count = cCount;
648651
break;
@@ -1186,7 +1189,7 @@ void SILProfiler::assignRegionCounters() {
11861189
llvm::dbgs() << PGOFuncName << "\n";
11871190
return;
11881191
}
1189-
PGOMapping pgoMapper(RegionLoadedCounterMap, LoadedCounts,
1192+
PGOMapping pgoMapper(RegionLoadedCounterMap, LoadedCounts.get(),
11901193
RegionCondToParentMap);
11911194
Root.walk(pgoMapper);
11921195
}

0 commit comments

Comments
 (0)