mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-22 13:29:44 +00:00
Use unique_ptr to handle ownership of GCOVFunctions in GCOVProfiler.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206786 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
864c5312a7
commit
77a301fc19
@ -39,6 +39,7 @@
|
|||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Transforms/Utils/ModuleUtils.h"
|
#include "llvm/Transforms/Utils/ModuleUtils.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
@ -77,9 +78,6 @@ namespace {
|
|||||||
"GCOVProfiler asked to do nothing?");
|
"GCOVProfiler asked to do nothing?");
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
~GCOVProfiler() {
|
|
||||||
DeleteContainerPointers(Funcs);
|
|
||||||
}
|
|
||||||
const char *getPassName() const override {
|
const char *getPassName() const override {
|
||||||
return "GCOV Profiler";
|
return "GCOV Profiler";
|
||||||
}
|
}
|
||||||
@ -141,7 +139,7 @@ namespace {
|
|||||||
|
|
||||||
Module *M;
|
Module *M;
|
||||||
LLVMContext *Ctx;
|
LLVMContext *Ctx;
|
||||||
SmallVector<GCOVFunction *, 16> Funcs;
|
SmallVector<std::unique_ptr<GCOVFunction>, 16> Funcs;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,19 +497,19 @@ void GCOVProfiler::emitProfileNotes() {
|
|||||||
++It;
|
++It;
|
||||||
EntryBlock.splitBasicBlock(It);
|
EntryBlock.splitBasicBlock(It);
|
||||||
|
|
||||||
GCOVFunction *Func =
|
Funcs.push_back(
|
||||||
new GCOVFunction(SP, &out, i, Options.UseCfgChecksum);
|
make_unique<GCOVFunction>(SP, &out, i, Options.UseCfgChecksum));
|
||||||
Funcs.push_back(Func);
|
GCOVFunction &Func = *Funcs.back();
|
||||||
|
|
||||||
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
|
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
|
||||||
GCOVBlock &Block = Func->getBlock(BB);
|
GCOVBlock &Block = Func.getBlock(BB);
|
||||||
TerminatorInst *TI = BB->getTerminator();
|
TerminatorInst *TI = BB->getTerminator();
|
||||||
if (int successors = TI->getNumSuccessors()) {
|
if (int successors = TI->getNumSuccessors()) {
|
||||||
for (int i = 0; i != successors; ++i) {
|
for (int i = 0; i != successors; ++i) {
|
||||||
Block.addEdge(Func->getBlock(TI->getSuccessor(i)));
|
Block.addEdge(Func.getBlock(TI->getSuccessor(i)));
|
||||||
}
|
}
|
||||||
} else if (isa<ReturnInst>(TI)) {
|
} else if (isa<ReturnInst>(TI)) {
|
||||||
Block.addEdge(Func->getReturnBlock());
|
Block.addEdge(Func.getReturnBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Line = 0;
|
uint32_t Line = 0;
|
||||||
@ -527,7 +525,7 @@ void GCOVProfiler::emitProfileNotes() {
|
|||||||
Lines.addLine(Loc.getLine());
|
Lines.addLine(Loc.getLine());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EdgeDestinations += Func->getEdgeDestinations();
|
EdgeDestinations += Func.getEdgeDestinations();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileChecksums.push_back(hash_value(EdgeDestinations));
|
FileChecksums.push_back(hash_value(EdgeDestinations));
|
||||||
@ -535,9 +533,7 @@ void GCOVProfiler::emitProfileNotes() {
|
|||||||
out.write(ReversedVersion, 4);
|
out.write(ReversedVersion, 4);
|
||||||
out.write(reinterpret_cast<char*>(&FileChecksums.back()), 4);
|
out.write(reinterpret_cast<char*>(&FileChecksums.back()), 4);
|
||||||
|
|
||||||
for (SmallVectorImpl<GCOVFunction *>::iterator I = Funcs.begin(),
|
for (auto &Func : Funcs) {
|
||||||
E = Funcs.end(); I != E; ++I) {
|
|
||||||
GCOVFunction *Func = *I;
|
|
||||||
Func->setCfgChecksum(FileChecksums.back());
|
Func->setCfgChecksum(FileChecksums.back());
|
||||||
Func->writeOut();
|
Func->writeOut();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user