@@ -810,6 +810,7 @@ struct PGOMapping : public ASTWalker {
810
810
struct CoverageMapping : public ASTWalker {
811
811
private:
812
812
const SourceManager &SM;
813
+ SourceFile *SF;
813
814
814
815
// / The SIL function being profiled.
815
816
SILDeclRef Constant;
@@ -1111,9 +1112,10 @@ struct CoverageMapping : public ASTWalker {
1111
1112
1112
1113
public:
1113
1114
CoverageMapping (
1114
- const SourceManager &SM , SILDeclRef Constant,
1115
+ SourceFile *SF , SILDeclRef Constant,
1115
1116
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) {}
1117
1119
1118
1120
LazyInitializerWalking getLazyInitializerWalkingBehavior () override {
1119
1121
// We want to walk lazy initializers present in the synthesized getter for
@@ -1135,7 +1137,7 @@ struct CoverageMapping : public ASTWalker {
1135
1137
// / source regions.
1136
1138
SILCoverageMap *emitSourceRegions (SILModule &M, StringRef Name,
1137
1139
StringRef PGOFuncName, uint64_t Hash,
1138
- SourceFile *SF, StringRef Filename) {
1140
+ StringRef Filename) {
1139
1141
if (SourceRegions.empty ())
1140
1142
return nullptr ;
1141
1143
@@ -1610,7 +1612,6 @@ static void walkNode(NodeToProfile Node, ASTWalker &Walker) {
1610
1612
}
1611
1613
1612
1614
void SILProfiler::assignRegionCounters () {
1613
- const auto &SM = M.getASTContext ().SourceMgr ;
1614
1615
auto *DC = forDecl.getInnermostDeclContext ();
1615
1616
auto *SF = DC->getParentSourceFile ();
1616
1617
assert (SF && " Not within a SourceFile?" );
@@ -1647,10 +1648,10 @@ void SILProfiler::assignRegionCounters() {
1647
1648
PGOFuncHash = 0x0 ;
1648
1649
1649
1650
if (EmitCoverageMapping) {
1650
- CoverageMapping Coverage (SM , forDecl, RegionCounterMap);
1651
+ CoverageMapping Coverage (SF , forDecl, RegionCounterMap);
1651
1652
walkNode (Root, Coverage);
1652
1653
CovMap = Coverage.emitSourceRegions (M, CurrentFuncName, PGOFuncName,
1653
- PGOFuncHash, SF, CurrentFileName);
1654
+ PGOFuncHash, CurrentFileName);
1654
1655
}
1655
1656
1656
1657
if (llvm::IndexedInstrProfReader *IPR = M.getPGOReader ()) {
0 commit comments