diff options
Diffstat (limited to 'clang/lib/CodeGen/CodeGenPGO.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenPGO.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp index 6991e40f97c..9d4aaff8888 100644 --- a/clang/lib/CodeGen/CodeGenPGO.cpp +++ b/clang/lib/CodeGen/CodeGenPGO.cpp @@ -146,7 +146,7 @@ llvm::GlobalVariable *CodeGenPGO::buildDataVar() { } void CodeGenPGO::emitInstrumentationData() { - if (!CGM.getCodeGenOpts().ProfileInstrGenerate) + if (!RegionCounters) return; // Build the data. @@ -803,7 +803,7 @@ void CodeGenPGO::assignRegionCounters(const Decl *D, llvm::Function *Fn) { llvm::IndexedInstrProfReader *PGOReader = CGM.getPGOReader(); if (!InstrumentRegions && !PGOReader) return; - if (!D) + if (D->isImplicit()) return; setFuncName(Fn); @@ -845,6 +845,7 @@ void CodeGenPGO::mapRegionCounters(const Decl *D) { Walker.TraverseDecl(const_cast<BlockDecl *>(BD)); else if (const CapturedDecl *CD = dyn_cast_or_null<CapturedDecl>(D)) Walker.TraverseDecl(const_cast<CapturedDecl *>(CD)); + assert(Walker.NextCounter > 0 && "no entry counter mapped for decl"); NumRegionCounters = Walker.NextCounter; FunctionHash = Walker.Hash.finalize(); } @@ -920,6 +921,7 @@ void CodeGenPGO::destroyRegionCounters() { RegionCounterMap.reset(); StmtCountMap.reset(); RegionCounts.reset(); + RegionCounters = nullptr; } /// \brief Calculate what to divide by to scale weights. |