1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

[Debugify] Move global namespace functions into llvm::

Also move exportDebugifyStats from tools/opt to Debugify.cpp
This commit is contained in:
Fangrui Song 2020-10-28 19:11:19 -07:00
parent efffbdf8f7
commit 23241c90df
3 changed files with 33 additions and 33 deletions

View File

@ -40,8 +40,6 @@ bool applyDebugifyMetadata(
/// Returns true if any change was made.
bool stripDebugifyMetadata(Module &M);
} // namespace llvm
llvm::ModulePass *createDebugifyModulePass();
llvm::FunctionPass *createDebugifyFunctionPass();
@ -77,6 +75,8 @@ struct DebugifyStatistics {
/// Map pass names to a per-pass DebugifyStatistics instance.
using DebugifyStatsMap = llvm::MapVector<llvm::StringRef, DebugifyStatistics>;
void exportDebugifyStats(StringRef Path, const DebugifyStatsMap &Map);
llvm::ModulePass *
createCheckDebugifyModulePass(bool Strip = false,
llvm::StringRef NameOfWrappedPass = "",
@ -92,7 +92,6 @@ struct NewPMCheckDebugifyPass
llvm::PreservedAnalyses run(llvm::Module &M, llvm::ModuleAnalysisManager &AM);
};
namespace llvm {
/// DebugifyCustomPassManager wraps each pass with the debugify passes if
/// needed.
/// NOTE: We support legacy custom pass manager only.

View File

@ -472,9 +472,32 @@ private:
} // end anonymous namespace
ModulePass *createDebugifyModulePass() { return new DebugifyModulePass(); }
void llvm::exportDebugifyStats(StringRef Path, const DebugifyStatsMap &Map) {
std::error_code EC;
raw_fd_ostream OS{Path, EC};
if (EC) {
errs() << "Could not open file: " << EC.message() << ", " << Path << '\n';
return;
}
FunctionPass *createDebugifyFunctionPass() {
OS << "Pass Name" << ',' << "# of missing debug values" << ','
<< "# of missing locations" << ',' << "Missing/Expected value ratio" << ','
<< "Missing/Expected location ratio" << '\n';
for (const auto &Entry : Map) {
StringRef Pass = Entry.first;
DebugifyStatistics Stats = Entry.second;
OS << Pass << ',' << Stats.NumDbgValuesMissing << ','
<< Stats.NumDbgLocsMissing << ',' << Stats.getMissingValueRatio() << ','
<< Stats.getEmptyLocationRatio() << '\n';
}
}
ModulePass *llvm::createDebugifyModulePass() {
return new DebugifyModulePass();
}
FunctionPass *llvm::createDebugifyFunctionPass() {
return new DebugifyFunctionPass();
}
@ -484,15 +507,15 @@ PreservedAnalyses NewPMDebugifyPass::run(Module &M, ModuleAnalysisManager &) {
return PreservedAnalyses::all();
}
ModulePass *createCheckDebugifyModulePass(bool Strip,
StringRef NameOfWrappedPass,
DebugifyStatsMap *StatsMap) {
ModulePass *llvm::createCheckDebugifyModulePass(bool Strip,
StringRef NameOfWrappedPass,
DebugifyStatsMap *StatsMap) {
return new CheckDebugifyModulePass(Strip, NameOfWrappedPass, StatsMap);
}
FunctionPass *createCheckDebugifyFunctionPass(bool Strip,
StringRef NameOfWrappedPass,
DebugifyStatsMap *StatsMap) {
FunctionPass *
llvm::createCheckDebugifyFunctionPass(bool Strip, StringRef NameOfWrappedPass,
DebugifyStatsMap *StatsMap) {
return new CheckDebugifyFunctionPass(Strip, NameOfWrappedPass, StatsMap);
}

View File

@ -446,28 +446,6 @@ static TargetMachine* GetTargetMachine(Triple TheTriple, StringRef CPUStr,
void initializeExampleIRTransforms(llvm::PassRegistry &Registry);
#endif
static void exportDebugifyStats(llvm::StringRef Path,
const DebugifyStatsMap &Map) {
std::error_code EC;
raw_fd_ostream OS{Path, EC};
if (EC) {
errs() << "Could not open file: " << EC.message() << ", " << Path << '\n';
return;
}
OS << "Pass Name" << ',' << "# of missing debug values" << ','
<< "# of missing locations" << ',' << "Missing/Expected value ratio" << ','
<< "Missing/Expected location ratio" << '\n';
for (const auto &Entry : Map) {
StringRef Pass = Entry.first;
DebugifyStatistics Stats = Entry.second;
OS << Pass << ',' << Stats.NumDbgValuesMissing << ','
<< Stats.NumDbgLocsMissing << ',' << Stats.getMissingValueRatio() << ','
<< Stats.getEmptyLocationRatio() << '\n';
}
}
struct TimeTracerRAII {
TimeTracerRAII(StringRef ProgramName) {
if (TimeTrace)