Skip to content

Commit ed4dbd9

Browse files
committed
[Coverage] NFC: Set the SourceFile on CoverageMapping
Saves having to pass it as a parameter to `emitSourceRegions`.
1 parent 6ead0c8 commit ed4dbd9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/SIL/IR/SILProfiler.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,7 @@ struct PGOMapping : public ASTWalker {
810810
struct CoverageMapping : public ASTWalker {
811811
private:
812812
const SourceManager &SM;
813+
SourceFile *SF;
813814

814815
/// The SIL function being profiled.
815816
SILDeclRef Constant;
@@ -1111,9 +1112,10 @@ struct CoverageMapping : public ASTWalker {
11111112

11121113
public:
11131114
CoverageMapping(
1114-
const SourceManager &SM, SILDeclRef Constant,
1115+
SourceFile *SF, SILDeclRef Constant,
11151116
const llvm::DenseMap<ProfileCounterRef, unsigned> &ConcreteCounters)
1116-
: SM(SM), Constant(Constant), ConcreteCounters(ConcreteCounters) {}
1117+
: SM(SF->getASTContext().SourceMgr), SF(SF), Constant(Constant),
1118+
ConcreteCounters(ConcreteCounters) {}
11171119

11181120
LazyInitializerWalking getLazyInitializerWalkingBehavior() override {
11191121
// We want to walk lazy initializers present in the synthesized getter for
@@ -1135,7 +1137,7 @@ struct CoverageMapping : public ASTWalker {
11351137
/// source regions.
11361138
SILCoverageMap *emitSourceRegions(SILModule &M, StringRef Name,
11371139
StringRef PGOFuncName, uint64_t Hash,
1138-
SourceFile *SF, StringRef Filename) {
1140+
StringRef Filename) {
11391141
if (SourceRegions.empty())
11401142
return nullptr;
11411143

@@ -1610,7 +1612,6 @@ static void walkNode(NodeToProfile Node, ASTWalker &Walker) {
16101612
}
16111613

16121614
void SILProfiler::assignRegionCounters() {
1613-
const auto &SM = M.getASTContext().SourceMgr;
16141615
auto *DC = forDecl.getInnermostDeclContext();
16151616
auto *SF = DC->getParentSourceFile();
16161617
assert(SF && "Not within a SourceFile?");
@@ -1647,10 +1648,10 @@ void SILProfiler::assignRegionCounters() {
16471648
PGOFuncHash = 0x0;
16481649

16491650
if (EmitCoverageMapping) {
1650-
CoverageMapping Coverage(SM, forDecl, RegionCounterMap);
1651+
CoverageMapping Coverage(SF, forDecl, RegionCounterMap);
16511652
walkNode(Root, Coverage);
16521653
CovMap = Coverage.emitSourceRegions(M, CurrentFuncName, PGOFuncName,
1653-
PGOFuncHash, SF, CurrentFileName);
1654+
PGOFuncHash, CurrentFileName);
16541655
}
16551656

16561657
if (llvm::IndexedInstrProfReader *IPR = M.getPGOReader()) {

0 commit comments

Comments
 (0)