[llvm] r276265 - [GCOV] Remove a layer of indirection.
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 21 05:06:32 PDT 2016
Author: d0k
Date: Thu Jul 21 07:06:31 2016
New Revision: 276265
URL: http://llvm.org/viewvc/llvm-project?rev=276265&view=rev
Log:
[GCOV] Remove a layer of indirection.
StringMap is designed to hold large values. No functionality change
intended.
Modified:
llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp
Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=276265&r1=276264&r2=276265&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Thu Jul 21 07:06:31 2016
@@ -251,11 +251,7 @@ namespace {
class GCOVBlock : public GCOVRecord {
public:
GCOVLines &getFile(StringRef Filename) {
- GCOVLines *&Lines = LinesByFile[Filename];
- if (!Lines) {
- Lines = new GCOVLines(Filename, os);
- }
- return *Lines;
+ return LinesByFile.emplace_second(Filename, Filename, os).first->second;
}
void addEdge(GCOVBlock &Successor) {
@@ -264,9 +260,9 @@ namespace {
void writeOut() {
uint32_t Len = 3;
- SmallVector<StringMapEntry<GCOVLines *> *, 32> SortedLinesByFile;
+ SmallVector<StringMapEntry<GCOVLines> *, 32> SortedLinesByFile;
for (auto &I : LinesByFile) {
- Len += I.second->length();
+ Len += I.second.length();
SortedLinesByFile.push_back(&I);
}
@@ -274,21 +270,17 @@ namespace {
write(Len);
write(Number);
- std::sort(SortedLinesByFile.begin(), SortedLinesByFile.end(),
- [](StringMapEntry<GCOVLines *> *LHS,
- StringMapEntry<GCOVLines *> *RHS) {
- return LHS->getKey() < RHS->getKey();
- });
+ std::sort(
+ SortedLinesByFile.begin(), SortedLinesByFile.end(),
+ [](StringMapEntry<GCOVLines> *LHS, StringMapEntry<GCOVLines> *RHS) {
+ return LHS->getKey() < RHS->getKey();
+ });
for (auto &I : SortedLinesByFile)
- I->getValue()->writeOut();
+ I->getValue().writeOut();
write(0);
write(0);
}
- ~GCOVBlock() {
- DeleteContainerSeconds(LinesByFile);
- }
-
GCOVBlock(const GCOVBlock &RHS) : GCOVRecord(RHS), Number(RHS.Number) {
// Only allow copy before edges and lines have been added. After that,
// there are inter-block pointers (eg: edges) that won't take kindly to
@@ -306,7 +298,7 @@ namespace {
}
uint32_t Number;
- StringMap<GCOVLines *> LinesByFile;
+ StringMap<GCOVLines> LinesByFile;
SmallVector<GCOVBlock *, 4> OutEdges;
};
More information about the llvm-commits
mailing list