diff options
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
| -rw-r--r-- | src/rustllvm/RustWrapper.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index a9373b6c7e5..26d0764934e 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -15,6 +15,7 @@ #include "llvm/Linker.h" #include "llvm/PassManager.h" #include "llvm/ADT/Triple.h" +#include "llvm/Assembly/PrintModulePass.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/Timer.h" #include "llvm/Support/raw_ostream.h" @@ -46,6 +47,17 @@ extern "C" const char *LLVMRustGetLastError(void) { extern "C" void LLVMAddBasicAliasAnalysisPass(LLVMPassManagerRef PM); +extern "C" void LLVMRustAddPrintModulePass(LLVMPassManagerRef PMR, + LLVMModuleRef M, + const char* path) { + PassManager *PM = unwrap<PassManager>(PMR); + std::string ErrorInfo; + raw_fd_ostream OS(path, ErrorInfo, raw_fd_ostream::F_Binary); + formatted_raw_ostream FOS(OS); + PM->add(createPrintModulePass(&FOS)); + PM->run(*unwrap(M)); +} + extern "C" bool LLVMLinkModules(LLVMModuleRef Dest, LLVMModuleRef Src) { static std::string err; |
