mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[PM] code refactoring /NFC
llvm-svn: 271822
This commit is contained in:
parent
c6ece6bf3b
commit
73b5d1e27d
@ -123,7 +123,7 @@ void initializeEarlyIfConverterPass(PassRegistry&);
|
||||
void initializeEdgeBundlesPass(PassRegistry&);
|
||||
void initializeExpandPostRAPass(PassRegistry&);
|
||||
void initializeAAResultsWrapperPassPass(PassRegistry &);
|
||||
void initializeGCOVProfilerPass(PassRegistry&);
|
||||
void initializeGCOVProfilerLegacyPassPass(PassRegistry&);
|
||||
void initializePGOInstrumentationGenLegacyPassPass(PassRegistry&);
|
||||
void initializePGOInstrumentationUseLegacyPassPass(PassRegistry&);
|
||||
void initializePGOIndirectCallPromotionLegacyPassPass(PassRegistry&);
|
||||
|
@ -68,85 +68,95 @@ GCOVOptions GCOVOptions::getDefault() {
|
||||
}
|
||||
|
||||
namespace {
|
||||
class GCOVFunction;
|
||||
class GCOVFunction;
|
||||
|
||||
class GCOVProfiler : public ModulePass {
|
||||
public:
|
||||
static char ID;
|
||||
GCOVProfiler() : GCOVProfiler(GCOVOptions::getDefault()) {}
|
||||
GCOVProfiler(const GCOVOptions &Opts) : ModulePass(ID), Options(Opts) {
|
||||
assert((Options.EmitNotes || Options.EmitData) &&
|
||||
"GCOVProfiler asked to do nothing?");
|
||||
ReversedVersion[0] = Options.Version[3];
|
||||
ReversedVersion[1] = Options.Version[2];
|
||||
ReversedVersion[2] = Options.Version[1];
|
||||
ReversedVersion[3] = Options.Version[0];
|
||||
ReversedVersion[4] = '\0';
|
||||
initializeGCOVProfilerPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
const char *getPassName() const override {
|
||||
return "GCOV Profiler";
|
||||
}
|
||||
class GCOVProfiler {
|
||||
public:
|
||||
GCOVProfiler() : GCOVProfiler(GCOVOptions::getDefault()) {}
|
||||
GCOVProfiler(const GCOVOptions &Opts) : Options(Opts) {
|
||||
assert((Options.EmitNotes || Options.EmitData) &&
|
||||
"GCOVProfiler asked to do nothing?");
|
||||
ReversedVersion[0] = Options.Version[3];
|
||||
ReversedVersion[1] = Options.Version[2];
|
||||
ReversedVersion[2] = Options.Version[1];
|
||||
ReversedVersion[3] = Options.Version[0];
|
||||
ReversedVersion[4] = '\0';
|
||||
}
|
||||
bool runOnModule(Module &M);
|
||||
|
||||
private:
|
||||
bool runOnModule(Module &M) override;
|
||||
private:
|
||||
// Create the .gcno files for the Module based on DebugInfo.
|
||||
void emitProfileNotes();
|
||||
|
||||
// Create the .gcno files for the Module based on DebugInfo.
|
||||
void emitProfileNotes();
|
||||
// Modify the program to track transitions along edges and call into the
|
||||
// profiling runtime to emit .gcda files when run.
|
||||
bool emitProfileArcs();
|
||||
|
||||
// Modify the program to track transitions along edges and call into the
|
||||
// profiling runtime to emit .gcda files when run.
|
||||
bool emitProfileArcs();
|
||||
// Get pointers to the functions in the runtime library.
|
||||
Constant *getStartFileFunc();
|
||||
Constant *getIncrementIndirectCounterFunc();
|
||||
Constant *getEmitFunctionFunc();
|
||||
Constant *getEmitArcsFunc();
|
||||
Constant *getSummaryInfoFunc();
|
||||
Constant *getDeleteWriteoutFunctionListFunc();
|
||||
Constant *getDeleteFlushFunctionListFunc();
|
||||
Constant *getEndFileFunc();
|
||||
|
||||
// Get pointers to the functions in the runtime library.
|
||||
Constant *getStartFileFunc();
|
||||
Constant *getIncrementIndirectCounterFunc();
|
||||
Constant *getEmitFunctionFunc();
|
||||
Constant *getEmitArcsFunc();
|
||||
Constant *getSummaryInfoFunc();
|
||||
Constant *getDeleteWriteoutFunctionListFunc();
|
||||
Constant *getDeleteFlushFunctionListFunc();
|
||||
Constant *getEndFileFunc();
|
||||
// Create or retrieve an i32 state value that is used to represent the
|
||||
// pred block number for certain non-trivial edges.
|
||||
GlobalVariable *getEdgeStateValue();
|
||||
|
||||
// Create or retrieve an i32 state value that is used to represent the
|
||||
// pred block number for certain non-trivial edges.
|
||||
GlobalVariable *getEdgeStateValue();
|
||||
// Produce a table of pointers to counters, by predecessor and successor
|
||||
// block number.
|
||||
GlobalVariable *buildEdgeLookupTable(Function *F, GlobalVariable *Counter,
|
||||
const UniqueVector<BasicBlock *> &Preds,
|
||||
const UniqueVector<BasicBlock *> &Succs);
|
||||
|
||||
// Produce a table of pointers to counters, by predecessor and successor
|
||||
// block number.
|
||||
GlobalVariable *buildEdgeLookupTable(Function *F,
|
||||
GlobalVariable *Counter,
|
||||
const UniqueVector<BasicBlock *>&Preds,
|
||||
const UniqueVector<BasicBlock*>&Succs);
|
||||
// Add the function to write out all our counters to the global destructor
|
||||
// list.
|
||||
Function *
|
||||
insertCounterWriteout(ArrayRef<std::pair<GlobalVariable *, MDNode *>>);
|
||||
Function *insertFlush(ArrayRef<std::pair<GlobalVariable *, MDNode *>>);
|
||||
void insertIndirectCounterIncrement();
|
||||
|
||||
// Add the function to write out all our counters to the global destructor
|
||||
// list.
|
||||
Function *insertCounterWriteout(ArrayRef<std::pair<GlobalVariable*,
|
||||
MDNode*> >);
|
||||
Function *insertFlush(ArrayRef<std::pair<GlobalVariable*, MDNode*> >);
|
||||
void insertIndirectCounterIncrement();
|
||||
std::string mangleName(const DICompileUnit *CU, const char *NewStem);
|
||||
|
||||
std::string mangleName(const DICompileUnit *CU, const char *NewStem);
|
||||
GCOVOptions Options;
|
||||
|
||||
GCOVOptions Options;
|
||||
// Reversed, NUL-terminated copy of Options.Version.
|
||||
char ReversedVersion[5];
|
||||
// Checksum, produced by hash of EdgeDestinations
|
||||
SmallVector<uint32_t, 4> FileChecksums;
|
||||
|
||||
// Reversed, NUL-terminated copy of Options.Version.
|
||||
char ReversedVersion[5];
|
||||
// Checksum, produced by hash of EdgeDestinations
|
||||
SmallVector<uint32_t, 4> FileChecksums;
|
||||
Module *M;
|
||||
LLVMContext *Ctx;
|
||||
SmallVector<std::unique_ptr<GCOVFunction>, 16> Funcs;
|
||||
};
|
||||
|
||||
Module *M;
|
||||
LLVMContext *Ctx;
|
||||
SmallVector<std::unique_ptr<GCOVFunction>, 16> Funcs;
|
||||
};
|
||||
class GCOVProfilerLegacyPass : public ModulePass {
|
||||
public:
|
||||
static char ID;
|
||||
GCOVProfilerLegacyPass()
|
||||
: GCOVProfilerLegacyPass(GCOVOptions::getDefault()) {}
|
||||
GCOVProfilerLegacyPass(const GCOVOptions &Opts)
|
||||
: ModulePass(ID), Profiler(Opts) {
|
||||
initializeGCOVProfilerLegacyPassPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
const char *getPassName() const override { return "GCOV Profiler"; }
|
||||
|
||||
bool runOnModule(Module &M) override { return Profiler.runOnModule(M); }
|
||||
|
||||
private:
|
||||
GCOVProfiler Profiler;
|
||||
};
|
||||
}
|
||||
|
||||
char GCOVProfiler::ID = 0;
|
||||
INITIALIZE_PASS(GCOVProfiler, "insert-gcov-profiling",
|
||||
char GCOVProfilerLegacyPass::ID = 0;
|
||||
INITIALIZE_PASS(GCOVProfilerLegacyPass, "insert-gcov-profiling",
|
||||
"Insert instrumentation for GCOV profiling", false, false)
|
||||
|
||||
ModulePass *llvm::createGCOVProfilerPass(const GCOVOptions &Options) {
|
||||
return new GCOVProfiler(Options);
|
||||
return new GCOVProfilerLegacyPass(Options);
|
||||
}
|
||||
|
||||
static StringRef getFunctionName(const DISubprogram *SP) {
|
||||
|
@ -59,7 +59,7 @@ void llvm::initializeInstrumentation(PassRegistry &Registry) {
|
||||
initializeAddressSanitizerPass(Registry);
|
||||
initializeAddressSanitizerModulePass(Registry);
|
||||
initializeBoundsCheckingPass(Registry);
|
||||
initializeGCOVProfilerPass(Registry);
|
||||
initializeGCOVProfilerLegacyPassPass(Registry);
|
||||
initializePGOInstrumentationGenLegacyPassPass(Registry);
|
||||
initializePGOInstrumentationUseLegacyPassPass(Registry);
|
||||
initializePGOIndirectCallPromotionLegacyPassPass(Registry);
|
||||
|
Loading…
x
Reference in New Issue
Block a user