diff options
| author | Vedant Kumar <vsk@apple.com> | 2018-02-15 21:14:36 +0000 | 
|---|---|---|
| committer | Vedant Kumar <vsk@apple.com> | 2018-02-15 21:14:36 +0000 | 
| commit | 775c7af4f9ff934a85d4b6d521fffc7f5ac26cc0 (patch) | |
| tree | abbc35a6c84eb1edd39ec3b32656a58ed27f8cea /llvm/tools | |
| parent | f884cd42cc0d7d1a4522737e4af03feff017dd3a (diff) | |
| download | bcm5719-llvm-775c7af4f9ff934a85d4b6d521fffc7f5ac26cc0.tar.gz bcm5719-llvm-775c7af4f9ff934a85d4b6d521fffc7f5ac26cc0.zip | |
[opt] Port the debugify passes to the new pass manager
llvm-svn: 325294
Diffstat (limited to 'llvm/tools')
| -rw-r--r-- | llvm/tools/opt/Debugify.cpp | 12 | ||||
| -rw-r--r-- | llvm/tools/opt/NewPMDriver.cpp | 22 | ||||
| -rw-r--r-- | llvm/tools/opt/NewPMDriver.h | 5 | ||||
| -rw-r--r-- | llvm/tools/opt/PassPrinters.h | 16 | ||||
| -rw-r--r-- | llvm/tools/opt/opt.cpp | 5 | 
5 files changed, 53 insertions, 7 deletions
| diff --git a/llvm/tools/opt/Debugify.cpp b/llvm/tools/opt/Debugify.cpp index 931b8009a67..50b142b3240 100644 --- a/llvm/tools/opt/Debugify.cpp +++ b/llvm/tools/opt/Debugify.cpp @@ -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"); diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp index bf512e0db84..d596103bebc 100644 --- a/llvm/tools/opt/NewPMDriver.cpp +++ b/llvm/tools/opt/NewPMDriver.cpp @@ -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) { diff --git a/llvm/tools/opt/NewPMDriver.h b/llvm/tools/opt/NewPMDriver.h index e5490deaeaf..2f09e5a8afa 100644 --- a/llvm/tools/opt/NewPMDriver.h +++ b/llvm/tools/opt/NewPMDriver.h @@ -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 diff --git a/llvm/tools/opt/PassPrinters.h b/llvm/tools/opt/PassPrinters.h index 14b6e43d18e..6eba94795eb 100644 --- a/llvm/tools/opt/PassPrinters.h +++ b/llvm/tools/opt/PassPrinters.h @@ -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 diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp index 8e839b23907..1b8d70458b1 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -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;    } | 

