summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ProfileData/CoverageMapping.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2015-02-18 18:40:46 +0000
committerJustin Bogner <mail@justinbogner.com>2015-02-18 18:40:46 +0000
commit428c605dff38347495060e5df983bbc7df3c67df (patch)
tree25ae3e1d9ba43a3c4452ab60ce267ade75cd4f44 /llvm/lib/ProfileData/CoverageMapping.cpp
parent34e79ed319436693870ed27c951bd55267f1a154 (diff)
downloadbcm5719-llvm-428c605dff38347495060e5df983bbc7df3c67df.tar.gz
bcm5719-llvm-428c605dff38347495060e5df983bbc7df3c67df.zip
InstrProf: Handle unknown functions if they consist only of zero-regions
This comes up when we generate coverage for a function but don't end up emitting the function at all - dead static functions or inline functions that aren't referenced in a particular TU, for example. In these cases we'd like to show that the function was never called, which is trivially true. llvm-svn: 229717
Diffstat (limited to 'llvm/lib/ProfileData/CoverageMapping.cpp')
-rw-r--r--llvm/lib/ProfileData/CoverageMapping.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/llvm/lib/ProfileData/CoverageMapping.cpp b/llvm/lib/ProfileData/CoverageMapping.cpp
index 3c615d5b784..bef8605df48 100644
--- a/llvm/lib/ProfileData/CoverageMapping.cpp
+++ b/llvm/lib/ProfileData/CoverageMapping.cpp
@@ -184,25 +184,26 @@ CoverageMapping::load(CoverageMappingReader &CoverageReader,
std::vector<uint64_t> Counts;
for (const auto &Record : CoverageReader) {
+ CounterMappingContext Ctx(Record.Expressions);
+
Counts.clear();
if (std::error_code EC = ProfileReader.getFunctionCounts(
Record.FunctionName, Record.FunctionHash, Counts)) {
- if (EC != instrprof_error::hash_mismatch &&
- EC != instrprof_error::unknown_function)
+ if (EC == instrprof_error::hash_mismatch) {
+ Coverage->MismatchedFunctionCount++;
+ continue;
+ } else if (EC != instrprof_error::unknown_function)
return EC;
- Coverage->MismatchedFunctionCount++;
- continue;
- }
+ } else
+ Ctx.setCounts(Counts);
- assert(Counts.size() != 0 && "Function's counts are empty");
- FunctionRecord Function(Record.FunctionName, Record.Filenames,
- Counts.front());
- CounterMappingContext Ctx(Record.Expressions, Counts);
+ assert(!Record.MappingRegions.empty() && "Function has no regions");
+ FunctionRecord Function(Record.FunctionName, Record.Filenames);
for (const auto &Region : Record.MappingRegions) {
ErrorOr<int64_t> ExecutionCount = Ctx.evaluate(Region.Count);
if (!ExecutionCount)
break;
- Function.CountedRegions.push_back(CountedRegion(Region, *ExecutionCount));
+ Function.pushRegion(Region, *ExecutionCount);
}
if (Function.CountedRegions.size() != Record.MappingRegions.size()) {
Coverage->MismatchedFunctionCount++;
OpenPOWER on IntegriCloud