summaryrefslogtreecommitdiff
path: root/lib/ProfileData/Coverage/CoverageMapping.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-07-28 10:51:19 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-07-28 10:51:19 +0000
commiteb11fae6d08f479c0799db45860a98af528fa6e7 (patch)
tree44d492a50c8c1a7eb8e2d17ea3360ec4d066f042 /lib/ProfileData/Coverage/CoverageMapping.cpp
parentb8a2042aa938069e862750553db0e4d82d25822c (diff)
Notes
Diffstat (limited to 'lib/ProfileData/Coverage/CoverageMapping.cpp')
-rw-r--r--lib/ProfileData/Coverage/CoverageMapping.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/lib/ProfileData/Coverage/CoverageMapping.cpp b/lib/ProfileData/Coverage/CoverageMapping.cpp
index 8dbd58632f0e..b3c2b182e76c 100644
--- a/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ b/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -83,7 +83,7 @@ Counter CounterExpressionBuilder::simplify(Counter ExpressionTree) {
return Counter::getZero();
// Group the terms by counter ID.
- std::sort(Terms.begin(), Terms.end(), [](const Term &LHS, const Term &RHS) {
+ llvm::sort(Terms.begin(), Terms.end(), [](const Term &LHS, const Term &RHS) {
return LHS.CounterID < RHS.CounterID;
});
@@ -207,8 +207,10 @@ Error CoverageMapping::loadFunctionRecord(
else
OrigFuncName = getFuncNameWithoutPrefix(OrigFuncName, Record.Filenames[0]);
- // Don't load records for functions we've already seen.
- if (!FunctionNames.insert(OrigFuncName).second)
+ // Don't load records for (filenames, function) pairs we've already seen.
+ auto FilenamesHash = hash_combine_range(Record.Filenames.begin(),
+ Record.Filenames.end());
+ if (!RecordProvenance[FilenamesHash].insert(hash_value(OrigFuncName)).second)
return Error::success();
CounterMappingContext Ctx(Record.Expressions);
@@ -292,7 +294,7 @@ CoverageMapping::load(ArrayRef<StringRef> ObjectFilenames,
namespace {
-/// \brief Distributes functions into instantiation sets.
+/// Distributes functions into instantiation sets.
///
/// An instantiation set is a collection of functions that have the same source
/// code, ie, template functions specializations.
@@ -344,7 +346,7 @@ class SegmentBuilder {
else
Segments.emplace_back(StartLoc.first, StartLoc.second, IsRegionEntry);
- DEBUG({
+ LLVM_DEBUG({
const auto &Last = Segments.back();
dbgs() << "Segment at " << Last.Line << ":" << Last.Col
<< " (count = " << Last.Count << ")"
@@ -457,8 +459,8 @@ class SegmentBuilder {
/// Sort a nested sequence of regions from a single file.
static void sortNestedRegions(MutableArrayRef<CountedRegion> Regions) {
- std::sort(Regions.begin(), Regions.end(), [](const CountedRegion &LHS,
- const CountedRegion &RHS) {
+ llvm::sort(Regions.begin(), Regions.end(), [](const CountedRegion &LHS,
+ const CountedRegion &RHS) {
if (LHS.startLoc() != RHS.startLoc())
return LHS.startLoc() < RHS.startLoc();
if (LHS.endLoc() != RHS.endLoc())
@@ -522,7 +524,7 @@ public:
sortNestedRegions(Regions);
ArrayRef<CountedRegion> CombinedRegions = combineRegions(Regions);
- DEBUG({
+ LLVM_DEBUG({
dbgs() << "Combined regions:\n";
for (const auto &CR : CombinedRegions)
dbgs() << " " << CR.LineStart << ":" << CR.ColumnStart << " -> "
@@ -537,8 +539,8 @@ public:
const auto &L = Segments[I - 1];
const auto &R = Segments[I];
if (!(L.Line < R.Line) && !(L.Line == R.Line && L.Col < R.Col)) {
- DEBUG(dbgs() << " ! Segment " << L.Line << ":" << L.Col
- << " followed by " << R.Line << ":" << R.Col << "\n");
+ LLVM_DEBUG(dbgs() << " ! Segment " << L.Line << ":" << L.Col
+ << " followed by " << R.Line << ":" << R.Col << "\n");
assert(false && "Coverage segments not unique or sorted");
}
}
@@ -555,7 +557,7 @@ std::vector<StringRef> CoverageMapping::getUniqueSourceFiles() const {
for (const auto &Function : getCoveredFunctions())
Filenames.insert(Filenames.end(), Function.Filenames.begin(),
Function.Filenames.end());
- std::sort(Filenames.begin(), Filenames.end());
+ llvm::sort(Filenames.begin(), Filenames.end());
auto Last = std::unique(Filenames.begin(), Filenames.end());
Filenames.erase(Last, Filenames.end());
return Filenames;
@@ -611,7 +613,7 @@ CoverageData CoverageMapping::getCoverageForFile(StringRef Filename) const {
}
}
- DEBUG(dbgs() << "Emitting segments for file: " << Filename << "\n");
+ LLVM_DEBUG(dbgs() << "Emitting segments for file: " << Filename << "\n");
FileCoverage.Segments = SegmentBuilder::buildSegments(Regions);
return FileCoverage;
@@ -652,7 +654,8 @@ CoverageMapping::getCoverageForFunction(const FunctionRecord &Function) const {
FunctionCoverage.Expansions.emplace_back(CR, Function);
}
- DEBUG(dbgs() << "Emitting segments for function: " << Function.Name << "\n");
+ LLVM_DEBUG(dbgs() << "Emitting segments for function: " << Function.Name
+ << "\n");
FunctionCoverage.Segments = SegmentBuilder::buildSegments(Regions);
return FunctionCoverage;
@@ -670,8 +673,8 @@ CoverageData CoverageMapping::getCoverageForExpansion(
ExpansionCoverage.Expansions.emplace_back(CR, Expansion.Function);
}
- DEBUG(dbgs() << "Emitting segments for expansion of file " << Expansion.FileID
- << "\n");
+ LLVM_DEBUG(dbgs() << "Emitting segments for expansion of file "
+ << Expansion.FileID << "\n");
ExpansionCoverage.Segments = SegmentBuilder::buildSegments(Regions);
return ExpansionCoverage;