mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +01:00
[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
This commit is contained in:
parent
72060249ea
commit
4a9fcdb008
29
include/llvm/Analysis/ModuleDebugInfoPrinter.h
Normal file
29
include/llvm/Analysis/ModuleDebugInfoPrinter.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
//===- ModuleDebugInfoPrinter.h - -----------------------------------------===//
|
||||||
|
//
|
||||||
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef LLVM_ANALYSIS_MODULEDEBUGINFOPRINTER_H
|
||||||
|
#define LLVM_ANALYSIS_MODULEDEBUGINFOPRINTER_H
|
||||||
|
|
||||||
|
#include "llvm/IR/DebugInfo.h"
|
||||||
|
#include "llvm/IR/PassManager.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
|
||||||
|
class ModuleDebugInfoPrinterPass
|
||||||
|
: public PassInfoMixin<ModuleDebugInfoPrinterPass> {
|
||||||
|
DebugInfoFinder Finder;
|
||||||
|
raw_ostream &OS;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ModuleDebugInfoPrinterPass(raw_ostream &OS);
|
||||||
|
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
|
||||||
|
};
|
||||||
|
} // end namespace llvm
|
||||||
|
|
||||||
|
#endif // LLVM_ANALYSIS_MODULEDEBUGINFOPRINTER_H
|
@ -306,7 +306,7 @@ void initializeMergeFunctionsLegacyPassPass(PassRegistry&);
|
|||||||
void initializeMergeICmpsLegacyPassPass(PassRegistry &);
|
void initializeMergeICmpsLegacyPassPass(PassRegistry &);
|
||||||
void initializeMergedLoadStoreMotionLegacyPassPass(PassRegistry&);
|
void initializeMergedLoadStoreMotionLegacyPassPass(PassRegistry&);
|
||||||
void initializeMetaRenamerPass(PassRegistry&);
|
void initializeMetaRenamerPass(PassRegistry&);
|
||||||
void initializeModuleDebugInfoPrinterPass(PassRegistry&);
|
void initializeModuleDebugInfoLegacyPrinterPass(PassRegistry &);
|
||||||
void initializeModuleMemProfilerLegacyPassPass(PassRegistry &);
|
void initializeModuleMemProfilerLegacyPassPass(PassRegistry &);
|
||||||
void initializeModuleSummaryIndexWrapperPassPass(PassRegistry&);
|
void initializeModuleSummaryIndexWrapperPassPass(PassRegistry&);
|
||||||
void initializeModuloScheduleTestPass(PassRegistry&);
|
void initializeModuloScheduleTestPass(PassRegistry&);
|
||||||
|
@ -63,7 +63,7 @@ void llvm::initializeAnalysis(PassRegistry &Registry) {
|
|||||||
initializeMemDepPrinterPass(Registry);
|
initializeMemDepPrinterPass(Registry);
|
||||||
initializeMemDerefPrinterPass(Registry);
|
initializeMemDerefPrinterPass(Registry);
|
||||||
initializeMemoryDependenceWrapperPassPass(Registry);
|
initializeMemoryDependenceWrapperPassPass(Registry);
|
||||||
initializeModuleDebugInfoPrinterPass(Registry);
|
initializeModuleDebugInfoLegacyPrinterPass(Registry);
|
||||||
initializeModuleSummaryIndexWrapperPassPass(Registry);
|
initializeModuleSummaryIndexWrapperPassPass(Registry);
|
||||||
initializeMustExecutePrinterPass(Registry);
|
initializeMustExecutePrinterPass(Registry);
|
||||||
initializeMustBeExecutedContextPrinterPass(Registry);
|
initializeMustBeExecutedContextPrinterPass(Registry);
|
||||||
|
@ -14,9 +14,11 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "llvm/Analysis/ModuleDebugInfoPrinter.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
#include "llvm/Analysis/Passes.h"
|
#include "llvm/Analysis/Passes.h"
|
||||||
#include "llvm/IR/DebugInfo.h"
|
#include "llvm/IR/DebugInfo.h"
|
||||||
|
#include "llvm/IR/PassManager.h"
|
||||||
#include "llvm/InitializePasses.h"
|
#include "llvm/InitializePasses.h"
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
@ -24,32 +26,34 @@
|
|||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class ModuleDebugInfoPrinter : public ModulePass {
|
class ModuleDebugInfoLegacyPrinter : public ModulePass {
|
||||||
DebugInfoFinder Finder;
|
DebugInfoFinder Finder;
|
||||||
public:
|
|
||||||
static char ID; // Pass identification, replacement for typeid
|
|
||||||
ModuleDebugInfoPrinter() : ModulePass(ID) {
|
|
||||||
initializeModuleDebugInfoPrinterPass(*PassRegistry::getPassRegistry());
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
bool runOnModule(Module &M) override;
|
||||||
AU.setPreservesAll();
|
|
||||||
}
|
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||||
void print(raw_ostream &O, const Module *M) const override;
|
AU.setPreservesAll();
|
||||||
};
|
}
|
||||||
|
void print(raw_ostream &O, const Module *M) const override;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
char ModuleDebugInfoPrinter::ID = 0;
|
char ModuleDebugInfoLegacyPrinter::ID = 0;
|
||||||
INITIALIZE_PASS(ModuleDebugInfoPrinter, "module-debuginfo",
|
INITIALIZE_PASS(ModuleDebugInfoLegacyPrinter, "module-debuginfo",
|
||||||
"Decodes module-level debug info", false, true)
|
"Decodes module-level debug info", false, true)
|
||||||
|
|
||||||
ModulePass *llvm::createModuleDebugInfoPrinterPass() {
|
ModulePass *llvm::createModuleDebugInfoPrinterPass() {
|
||||||
return new ModuleDebugInfoPrinter();
|
return new ModuleDebugInfoLegacyPrinter();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModuleDebugInfoPrinter::runOnModule(Module &M) {
|
bool ModuleDebugInfoLegacyPrinter::runOnModule(Module &M) {
|
||||||
Finder.processModule(M);
|
Finder.processModule(M);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -67,7 +71,8 @@ static void printFile(raw_ostream &O, StringRef Filename, StringRef Directory,
|
|||||||
O << ":" << Line;
|
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
|
// Printing the nodes directly isn't particularly helpful (since they
|
||||||
// reference other nodes that won't be printed, particularly for the
|
// reference other nodes that won't be printed, particularly for the
|
||||||
// filenames), so just print a few useful things.
|
// filenames), so just print a few useful things.
|
||||||
@ -126,3 +131,18 @@ void ModuleDebugInfoPrinter::print(raw_ostream &O, const Module *M) const {
|
|||||||
O << '\n';
|
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();
|
||||||
|
}
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
#include "llvm/Analysis/LoopNestAnalysis.h"
|
#include "llvm/Analysis/LoopNestAnalysis.h"
|
||||||
#include "llvm/Analysis/MemoryDependenceAnalysis.h"
|
#include "llvm/Analysis/MemoryDependenceAnalysis.h"
|
||||||
#include "llvm/Analysis/MemorySSA.h"
|
#include "llvm/Analysis/MemorySSA.h"
|
||||||
|
#include "llvm/Analysis/ModuleDebugInfoPrinter.h"
|
||||||
#include "llvm/Analysis/ModuleSummaryAnalysis.h"
|
#include "llvm/Analysis/ModuleSummaryAnalysis.h"
|
||||||
#include "llvm/Analysis/ObjCARCAliasAnalysis.h"
|
#include "llvm/Analysis/ObjCARCAliasAnalysis.h"
|
||||||
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
|
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
|
||||||
|
@ -85,6 +85,7 @@ MODULE_PASS("print", PrintModulePass(dbgs()))
|
|||||||
MODULE_PASS("print-lcg", LazyCallGraphPrinterPass(dbgs()))
|
MODULE_PASS("print-lcg", LazyCallGraphPrinterPass(dbgs()))
|
||||||
MODULE_PASS("print-lcg-dot", LazyCallGraphDOTPrinterPass(dbgs()))
|
MODULE_PASS("print-lcg-dot", LazyCallGraphDOTPrinterPass(dbgs()))
|
||||||
MODULE_PASS("print-stack-safety", StackSafetyGlobalPrinterPass(dbgs()))
|
MODULE_PASS("print-stack-safety", StackSafetyGlobalPrinterPass(dbgs()))
|
||||||
|
MODULE_PASS("print<module-debuginfo>", ModuleDebugInfoPrinterPass(dbgs()))
|
||||||
MODULE_PASS("rewrite-statepoints-for-gc", RewriteStatepointsForGC())
|
MODULE_PASS("rewrite-statepoints-for-gc", RewriteStatepointsForGC())
|
||||||
MODULE_PASS("rewrite-symbols", RewriteSymbolPass())
|
MODULE_PASS("rewrite-symbols", RewriteSymbolPass())
|
||||||
MODULE_PASS("rpo-function-attrs", ReversePostOrderFunctionAttrsPass())
|
MODULE_PASS("rpo-function-attrs", ReversePostOrderFunctionAttrsPass())
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
; RUN: opt -analyze -module-debuginfo < %s | FileCheck %s
|
; RUN: opt -analyze -module-debuginfo -enable-new-pm=0 < %s | FileCheck %s
|
||||||
|
; RUN: opt -passes='print<module-debuginfo>' -disable-output 2>&1 < %s \
|
||||||
|
; RUN: | FileCheck %s
|
||||||
|
|
||||||
; This module is generated from the following c-code:
|
; This module is generated from the following c-code:
|
||||||
;
|
;
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
; RUN: opt -analyze -module-debuginfo < %s | FileCheck %s
|
; RUN: opt -analyze -module-debuginfo -enable-new-pm=0 < %s | FileCheck %s
|
||||||
|
; RUN: opt -passes='print<module-debuginfo>' -disable-output 2>&1 < %s \
|
||||||
|
; RUN: | FileCheck %s
|
||||||
|
|
||||||
; This is to track DebugInfoFinder's ability to find the debug info metadata,
|
; This is to track DebugInfoFinder's ability to find the debug info metadata,
|
||||||
; in particular, properly visit different kinds of DIImportedEntit'ies.
|
; in particular, properly visit different kinds of DIImportedEntities.
|
||||||
|
|
||||||
; Derived from the following C++ snippet
|
; Derived from the following C++ snippet
|
||||||
;
|
;
|
||||||
@ -13,7 +15,6 @@
|
|||||||
;
|
;
|
||||||
; compiled with `clang -O1 -g3 -emit-llvm -S`
|
; compiled with `clang -O1 -g3 -emit-llvm -S`
|
||||||
|
|
||||||
; CHECK: Printing analysis 'Decodes module-level debug info':
|
|
||||||
; CHECK: Compile unit: DW_LANG_C_plus_plus from /somewhere/source.cpp
|
; CHECK: Compile unit: DW_LANG_C_plus_plus from /somewhere/source.cpp
|
||||||
; CHECK: Global variable: i from /somewhere/source.cpp:2 ('_ZN1s1iE')
|
; CHECK: Global variable: i from /somewhere/source.cpp:2 ('_ZN1s1iE')
|
||||||
; CHECK: Type: int DW_ATE_signed
|
; CHECK: Type: int DW_ATE_signed
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
; RUN: opt -analyze -module-debuginfo < %s | FileCheck %s
|
; RUN: opt -analyze -module-debuginfo -enable-new-pm=0 < %s | FileCheck %s
|
||||||
|
; RUN: opt -passes='print<module-debuginfo>' -disable-output 2>&1 < %s \
|
||||||
|
; RUN: | FileCheck %s
|
||||||
|
|
||||||
; Verify that both compile units, even though one compile units's functions
|
; Verify that both compile units, even though one compile units's functions
|
||||||
; were entirely inlined into the other.
|
; were entirely inlined into the other.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
; RUN: opt -analyze -module-debuginfo < %s | FileCheck %s
|
; RUN: opt -analyze -module-debuginfo -enable-new-pm=0 < %s | FileCheck %s
|
||||||
|
; RUN: opt -passes='print<module-debuginfo>' -disable-output 2>&1 < %s \
|
||||||
|
; RUN: | FileCheck %s
|
||||||
|
|
||||||
; Produced from linking:
|
; Produced from linking:
|
||||||
; /tmp/test1.c containing f()
|
; /tmp/test1.c containing f()
|
||||||
|
Loading…
Reference in New Issue
Block a user