diff options
author | Amy Huang <akhuang@google.com> | 2020-10-19 14:31:17 -0700 |
---|---|---|
committer | Amy Huang <akhuang@google.com> | 2020-10-19 14:31:17 -0700 |
commit | ea693a162786d933863ab079648d4261ac0ead47 (patch) | |
tree | b223c003748114d0dfac7eddddec7a308dee93a3 /llvm/lib/Analysis/ModuleDebugInfoPrinter.cpp | |
parent | e0567582b8b1def8656f4a5addce0909fa51c86e (diff) | |
download | llvm-ea693a162786d933863ab079648d4261ac0ead47.zip llvm-ea693a162786d933863ab079648d4261ac0ead47.tar.gz llvm-ea693a162786d933863ab079648d4261ac0ead47.tar.bz2 |
[NPM] Port module-debuginfo pass to the new pass manager
Port pass to NPM and update tests in DebugInfo/Generic.
Differential Revision: https://reviews.llvm.org/D89730
Diffstat (limited to 'llvm/lib/Analysis/ModuleDebugInfoPrinter.cpp')
-rw-r--r-- | llvm/lib/Analysis/ModuleDebugInfoPrinter.cpp | 56 |
1 files changed, 38 insertions, 18 deletions
diff --git a/llvm/lib/Analysis/ModuleDebugInfoPrinter.cpp b/llvm/lib/Analysis/ModuleDebugInfoPrinter.cpp index 52b884f..64fd5eb 100644 --- a/llvm/lib/Analysis/ModuleDebugInfoPrinter.cpp +++ b/llvm/lib/Analysis/ModuleDebugInfoPrinter.cpp @@ -14,9 +14,11 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Analysis/ModuleDebugInfoPrinter.h" #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/Passes.h" #include "llvm/IR/DebugInfo.h" +#include "llvm/IR/PassManager.h" #include "llvm/InitializePasses.h" #include "llvm/Pass.h" #include "llvm/Support/ErrorHandling.h" @@ -24,32 +26,34 @@ using namespace llvm; namespace { - class ModuleDebugInfoPrinter : public ModulePass { - DebugInfoFinder Finder; - public: - static char ID; // Pass identification, replacement for typeid - ModuleDebugInfoPrinter() : ModulePass(ID) { - initializeModuleDebugInfoPrinterPass(*PassRegistry::getPassRegistry()); - } +class ModuleDebugInfoLegacyPrinter : public ModulePass { + DebugInfoFinder Finder; - bool runOnModule(Module &M) override; +public: + static char ID; // Pass identification, replacement for typeid + ModuleDebugInfoLegacyPrinter() : ModulePass(ID) { + initializeModuleDebugInfoLegacyPrinterPass( + *PassRegistry::getPassRegistry()); + } - void getAnalysisUsage(AnalysisUsage &AU) const override { - AU.setPreservesAll(); - } - void print(raw_ostream &O, const Module *M) const override; - }; + bool runOnModule(Module &M) override; + + void getAnalysisUsage(AnalysisUsage &AU) const override { + AU.setPreservesAll(); + } + void print(raw_ostream &O, const Module *M) const override; +}; } -char ModuleDebugInfoPrinter::ID = 0; -INITIALIZE_PASS(ModuleDebugInfoPrinter, "module-debuginfo", +char ModuleDebugInfoLegacyPrinter::ID = 0; +INITIALIZE_PASS(ModuleDebugInfoLegacyPrinter, "module-debuginfo", "Decodes module-level debug info", false, true) ModulePass *llvm::createModuleDebugInfoPrinterPass() { - return new ModuleDebugInfoPrinter(); + return new ModuleDebugInfoLegacyPrinter(); } -bool ModuleDebugInfoPrinter::runOnModule(Module &M) { +bool ModuleDebugInfoLegacyPrinter::runOnModule(Module &M) { Finder.processModule(M); return false; } @@ -67,7 +71,8 @@ static void printFile(raw_ostream &O, StringRef Filename, StringRef Directory, O << ":" << Line; } -void ModuleDebugInfoPrinter::print(raw_ostream &O, const Module *M) const { +static void printModuleDebugInfo(raw_ostream &O, const Module *M, + const DebugInfoFinder &Finder) { // Printing the nodes directly isn't particularly helpful (since they // reference other nodes that won't be printed, particularly for the // filenames), so just print a few useful things. @@ -126,3 +131,18 @@ void ModuleDebugInfoPrinter::print(raw_ostream &O, const Module *M) const { O << '\n'; } } + +void ModuleDebugInfoLegacyPrinter::print(raw_ostream &O, + const Module *M) const { + printModuleDebugInfo(O, M, Finder); +} + +ModuleDebugInfoPrinterPass::ModuleDebugInfoPrinterPass(raw_ostream &OS) + : OS(OS) {} + +PreservedAnalyses ModuleDebugInfoPrinterPass::run(Module &M, + ModuleAnalysisManager &AM) { + Finder.processModule(M); + printModuleDebugInfo(OS, &M, Finder); + return PreservedAnalyses::all(); +} |