@@ -810,6 +810,7 @@ struct PGOMapping : public ASTWalker {
810810struct CoverageMapping : public ASTWalker {
811811private:
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
11121113public:
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
16121614void 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