diff options
| author | Justin Bogner <mail@justinbogner.com> | 2014-04-25 07:20:05 +0000 |
|---|---|---|
| committer | Justin Bogner <mail@justinbogner.com> | 2014-04-25 07:20:05 +0000 |
| commit | 2196195a2a825cf60a455337133969c9870672c1 (patch) | |
| tree | 071f2e436f594acffac71b911b4e6aca79be84e8 /lib/CodeGen/CodeGenPGO.cpp | |
| parent | 4f2e3bb97d2b431dfc302ebbd43976c24739b15e (diff) | |
| download | clang-2196195a2a825cf60a455337133969c9870672c1.tar.gz clang-2196195a2a825cf60a455337133969c9870672c1.tar.bz2 clang-2196195a2a825cf60a455337133969c9870672c1.tar.xz | |
CodeGen: Avoid instrumenting implicit Decls more effectively
We don't assign counters for implicit Decls, but we were emitting code
to increment the (non-existent) counters and adding empty counter
lists in the output. This fixes the checks in assignRegionCounters and
emitInstrumentationData to do the right thing, and adds an assert for
the pathological case of emitting zero counters.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207203 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenPGO.cpp')
| -rw-r--r-- | lib/CodeGen/CodeGenPGO.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/CodeGen/CodeGenPGO.cpp b/lib/CodeGen/CodeGenPGO.cpp index 6991e40f97..9d4aaff888 100644 --- a/lib/CodeGen/CodeGenPGO.cpp +++ b/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. |
