diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Analysis/ModuleDebugInfoPrinter.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Analysis/ModuleDebugInfoPrinter.cpp | 56 |
1 files changed, 38 insertions, 18 deletions
diff --git a/contrib/llvm-project/llvm/lib/Analysis/ModuleDebugInfoPrinter.cpp b/contrib/llvm-project/llvm/lib/Analysis/ModuleDebugInfoPrinter.cpp index 52b884fb88e0..64fd5eb1acd4 100644 --- a/contrib/llvm-project/llvm/lib/Analysis/ModuleDebugInfoPrinter.cpp +++ b/contrib/llvm-project/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(); +} |