@@ -658,46 +658,11 @@ class RustAssemblyAnnotationWriter : public AssemblyAnnotationWriter {
658658 }
659659};
660660
661- class RustPrintModulePass : public ModulePass {
662- raw_ostream* OS;
663- DemangleFn Demangle;
664- public:
665- static char ID;
666- RustPrintModulePass () : ModulePass(ID), OS(nullptr ), Demangle(nullptr ) {}
667- RustPrintModulePass (raw_ostream &OS, DemangleFn Demangle)
668- : ModulePass(ID), OS(&OS), Demangle(Demangle) {}
669-
670- bool runOnModule (Module &M) override {
671- RustAssemblyAnnotationWriter AW (Demangle);
672-
673- M.print (*OS, &AW, false );
674-
675- return false ;
676- }
677-
678- void getAnalysisUsage (AnalysisUsage &AU) const override {
679- AU.setPreservesAll ();
680- }
681-
682- static StringRef name () { return " RustPrintModulePass" ; }
683- };
684-
685661} // namespace
686662
687- namespace llvm {
688- void initializeRustPrintModulePassPass (PassRegistry&);
689- }
690-
691- char RustPrintModulePass::ID = 0 ;
692- INITIALIZE_PASS (RustPrintModulePass, " print-rust-module" ,
693- " Print rust module to stderr" , false , false )
694-
695663extern " C" LLVMRustResult
696- LLVMRustPrintModule(LLVMPassManagerRef PMR, LLVMModuleRef M,
697- const char *Path, DemangleFn Demangle) {
698- llvm::legacy::PassManager *PM = unwrap<llvm::legacy::PassManager>(PMR);
664+ LLVMRustPrintModule (LLVMModuleRef M, const char *Path, DemangleFn Demangle) {
699665 std::string ErrorInfo;
700-
701666 std::error_code EC;
702667 raw_fd_ostream OS (Path, EC, sys::fs::F_None);
703668 if (EC)
@@ -707,11 +672,9 @@ LLVMRustPrintModule(LLVMPassManagerRef PMR, LLVMModuleRef M,
707672 return LLVMRustResult::Failure;
708673 }
709674
675+ RustAssemblyAnnotationWriter AAW (Demangle);
710676 formatted_raw_ostream FOS (OS);
711-
712- PM->add (new RustPrintModulePass (FOS, Demangle));
713-
714- PM->run (*unwrap (M));
677+ unwrap (M)->print (FOS, &AAW);
715678
716679 return LLVMRustResult::Success;
717680}
0 commit comments