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 | 3212b18bbf8458cc9eabbb8938ffcef68af7473c (patch) | |
tree | a6a34cfd94abda04f87803cc83aaf126c18a3573 /clang/lib/CodeGen | |
parent | 6b88e3a5454219ee265e5624015a113266cce463 (diff) | |
download | bcm5719-llvm-3212b18bbf8458cc9eabbb8938ffcef68af7473c.tar.gz bcm5719-llvm-3212b18bbf8458cc9eabbb8938ffcef68af7473c.zip |
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.
llvm-svn: 207203
Diffstat (limited to 'clang/lib/CodeGen')
-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. |