@@ -660,46 +660,11 @@ class RustAssemblyAnnotationWriter : public AssemblyAnnotationWriter {
660660  }
661661};
662662
663- class  RustPrintModulePass  : public  ModulePass  {
664-   raw_ostream* OS;
665-   DemangleFn Demangle;
666- public: 
667-   static  char  ID;
668-   RustPrintModulePass () : ModulePass(ID), OS(nullptr ), Demangle(nullptr ) {}
669-   RustPrintModulePass (raw_ostream &OS, DemangleFn Demangle)
670-       : ModulePass(ID), OS(&OS), Demangle(Demangle) {}
671- 
672-   bool  runOnModule (Module &M) override  {
673-     RustAssemblyAnnotationWriter AW (Demangle);
674- 
675-     M.print (*OS, &AW, false );
676- 
677-     return  false ;
678-   }
679- 
680-   void  getAnalysisUsage (AnalysisUsage &AU) const  override  {
681-     AU.setPreservesAll ();
682-   }
683- 
684-   static  StringRef name () { return  " RustPrintModulePass"  ; }
685- };
686- 
687663} //  namespace
688664
689- namespace  llvm  {
690-   void  initializeRustPrintModulePassPass (PassRegistry&);
691- }
692- 
693- char  RustPrintModulePass::ID = 0 ;
694- INITIALIZE_PASS (RustPrintModulePass, " print-rust-module"  ,
695-                 " Print rust module to stderr"  , false , false )
696- 
697665extern  " C"   LLVMRustResult
698- LLVMRustPrintModule(LLVMPassManagerRef PMR, LLVMModuleRef M,
699-                     const  char  *Path, DemangleFn Demangle) {
700-   llvm::legacy::PassManager *PM = unwrap<llvm::legacy::PassManager>(PMR);
666+ LLVMRustPrintModule (LLVMModuleRef M, const  char  *Path, DemangleFn Demangle) {
701667  std::string ErrorInfo;
702- 
703668  std::error_code EC;
704669  raw_fd_ostream OS (Path, EC, sys::fs::F_None);
705670  if  (EC)
@@ -709,11 +674,9 @@ LLVMRustPrintModule(LLVMPassManagerRef PMR, LLVMModuleRef M,
709674    return  LLVMRustResult::Failure;
710675  }
711676
677+   RustAssemblyAnnotationWriter AAW (Demangle);
712678  formatted_raw_ostream FOS (OS);
713- 
714-   PM->add (new  RustPrintModulePass (FOS, Demangle));
715- 
716-   PM->run (*unwrap (M));
679+   unwrap (M)->print (FOS, &AAW);
717680
718681  return  LLVMRustResult::Success;
719682}
0 commit comments