mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-04 01:11:44 +00:00
[opt] Port the debugify passes to the new pass manager
llvm-svn: 325294
This commit is contained in:
parent
04205b79c8
commit
477f3d1e17
@ -1,10 +1,17 @@
|
||||
; RUN: opt -debugify -S -o - < %s | FileCheck %s
|
||||
; RUN: opt -passes=debugify -S -o - < %s | FileCheck %s
|
||||
|
||||
; RUN: opt -debugify -debugify -S -o - < %s 2>&1 | \
|
||||
; RUN: FileCheck %s -check-prefix=CHECK-REPEAT
|
||||
; RUN: opt -passes=debugify,debugify -S -o - < %s 2>&1 | \
|
||||
; RUN: FileCheck %s -check-prefix=CHECK-REPEAT
|
||||
|
||||
; RUN: opt -debugify -check-debugify -S -o - < %s | \
|
||||
; RUN: FileCheck %s -implicit-check-not="CheckDebugify: FAIL"
|
||||
; RUN: opt -passes=debugify,check-debugify -S -o - < %s | \
|
||||
; RUN: FileCheck %s -implicit-check-not="CheckDebugify: FAIL"
|
||||
; RUN: opt -enable-debugify -passes=verify -S -o - < %s | \
|
||||
; RUN: FileCheck %s -implicit-check-not="CheckDebugify: FAIL"
|
||||
|
||||
; RUN: opt -debugify -strip -check-debugify -S -o - < %s | \
|
||||
; RUN: FileCheck %s -check-prefix=CHECK-FAIL
|
||||
|
@ -12,6 +12,7 @@
|
||||
///
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "PassPrinters.h"
|
||||
#include "llvm/ADT/BitVector.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/IR/BasicBlock.h"
|
||||
@ -206,8 +207,19 @@ struct CheckDebugifyPass : public ModulePass {
|
||||
|
||||
ModulePass *createDebugifyPass() { return new DebugifyPass(); }
|
||||
|
||||
PreservedAnalyses NewPMDebugifyPass::run(Module &M, ModuleAnalysisManager &) {
|
||||
applyDebugifyMetadata(M);
|
||||
return PreservedAnalyses::all();
|
||||
}
|
||||
|
||||
ModulePass *createCheckDebugifyPass() { return new CheckDebugifyPass(); }
|
||||
|
||||
PreservedAnalyses NewPMCheckDebugifyPass::run(Module &M,
|
||||
ModuleAnalysisManager &) {
|
||||
checkDebugifyMetadata(M);
|
||||
return PreservedAnalyses::all();
|
||||
}
|
||||
|
||||
char DebugifyPass::ID = 0;
|
||||
static RegisterPass<DebugifyPass> X("debugify",
|
||||
"Attach debug info to everything");
|
||||
|
@ -14,6 +14,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "NewPMDriver.h"
|
||||
#include "PassPrinters.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
#include "llvm/Analysis/CGSCCPassManager.h"
|
||||
@ -185,7 +186,8 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
|
||||
VerifierKind VK,
|
||||
bool ShouldPreserveAssemblyUseListOrder,
|
||||
bool ShouldPreserveBitcodeUseListOrder,
|
||||
bool EmitSummaryIndex, bool EmitModuleHash) {
|
||||
bool EmitSummaryIndex, bool EmitModuleHash,
|
||||
bool EnableDebugify) {
|
||||
bool VerifyEachPass = VK == VK_VerifyEachPass;
|
||||
|
||||
Optional<PGOOptions> P;
|
||||
@ -208,6 +210,20 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
|
||||
PassBuilder PB(TM, P);
|
||||
registerEPCallbacks(PB, VerifyEachPass, DebugPM);
|
||||
|
||||
// Register a callback that creates the debugify passes as needed.
|
||||
PB.registerPipelineParsingCallback(
|
||||
[](StringRef Name, ModulePassManager &MPM,
|
||||
ArrayRef<PassBuilder::PipelineElement>) {
|
||||
if (Name == "debugify") {
|
||||
MPM.addPass(NewPMDebugifyPass());
|
||||
return true;
|
||||
} else if (Name == "check-debugify") {
|
||||
MPM.addPass(NewPMCheckDebugifyPass());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
#ifdef LINK_POLLY_INTO_TOOLS
|
||||
polly::RegisterPollyPasses(PB);
|
||||
#endif
|
||||
@ -238,6 +254,8 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
|
||||
ModulePassManager MPM(DebugPM);
|
||||
if (VK > VK_NoVerifier)
|
||||
MPM.addPass(VerifierPass());
|
||||
if (EnableDebugify)
|
||||
MPM.addPass(NewPMDebugifyPass());
|
||||
|
||||
if (!PB.parsePassPipeline(MPM, PassPipeline, VerifyEachPass, DebugPM)) {
|
||||
errs() << Arg0 << ": unable to parse pass pipeline description.\n";
|
||||
@ -246,6 +264,8 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
|
||||
|
||||
if (VK > VK_NoVerifier)
|
||||
MPM.addPass(VerifierPass());
|
||||
if (EnableDebugify)
|
||||
MPM.addPass(NewPMCheckDebugifyPass());
|
||||
|
||||
// Add any relevant output pass at the end of the pipeline.
|
||||
switch (OK) {
|
||||
|
@ -57,7 +57,8 @@ bool runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
|
||||
opt_tool::OutputKind OK, opt_tool::VerifierKind VK,
|
||||
bool ShouldPreserveAssemblyUseListOrder,
|
||||
bool ShouldPreserveBitcodeUseListOrder,
|
||||
bool EmitSummaryIndex, bool EmitModuleHash);
|
||||
}
|
||||
bool EmitSummaryIndex, bool EmitModuleHash,
|
||||
bool EnableDebugify);
|
||||
} // namespace llvm
|
||||
|
||||
#endif
|
||||
|
@ -15,6 +15,8 @@
|
||||
#ifndef LLVM_TOOLS_OPT_PASSPRINTERS_H
|
||||
#define LLVM_TOOLS_OPT_PASSPRINTERS_H
|
||||
|
||||
#include "llvm/IR/PassManager.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class BasicBlockPass;
|
||||
@ -25,6 +27,7 @@ class LoopPass;
|
||||
class PassInfo;
|
||||
class raw_ostream;
|
||||
class RegionPass;
|
||||
class Module;
|
||||
|
||||
FunctionPass *createFunctionPassPrinter(const PassInfo *PI, raw_ostream &out,
|
||||
bool Quiet);
|
||||
@ -46,4 +49,17 @@ BasicBlockPass *createBasicBlockPassPrinter(const PassInfo *PI,
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
llvm::ModulePass *createDebugifyPass();
|
||||
|
||||
struct NewPMDebugifyPass : public llvm::PassInfoMixin<NewPMDebugifyPass> {
|
||||
llvm::PreservedAnalyses run(llvm::Module &M, llvm::ModuleAnalysisManager &AM);
|
||||
};
|
||||
|
||||
llvm::ModulePass *createCheckDebugifyPass();
|
||||
|
||||
struct NewPMCheckDebugifyPass
|
||||
: public llvm::PassInfoMixin<NewPMCheckDebugifyPass> {
|
||||
llvm::PreservedAnalyses run(llvm::Module &M, llvm::ModuleAnalysisManager &AM);
|
||||
};
|
||||
|
||||
#endif // LLVM_TOOLS_OPT_PASSPRINTERS_H
|
||||
|
@ -257,9 +257,6 @@ static cl::opt<std::string>
|
||||
cl::desc("YAML output filename for pass remarks"),
|
||||
cl::value_desc("filename"));
|
||||
|
||||
extern ModulePass *createDebugifyPass();
|
||||
extern ModulePass *createCheckDebugifyPass();
|
||||
|
||||
static inline void addPass(legacy::PassManagerBase &PM, Pass *P) {
|
||||
// Add the pass to the pass manager...
|
||||
PM.add(P);
|
||||
@ -555,7 +552,7 @@ int main(int argc, char **argv) {
|
||||
OptRemarkFile.get(), PassPipeline, OK, VK,
|
||||
PreserveAssemblyUseListOrder,
|
||||
PreserveBitcodeUseListOrder, EmitSummaryIndex,
|
||||
EmitModuleHash)
|
||||
EmitModuleHash, EnableDebugify)
|
||||
? 0
|
||||
: 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user