diff options
| -rw-r--r-- | src/librustc_codegen_llvm/llvm/ffi.rs | 1 | ||||
| -rw-r--r-- | src/rustllvm/RustWrapper.cpp | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/librustc_codegen_llvm/llvm/ffi.rs b/src/librustc_codegen_llvm/llvm/ffi.rs index b07214fdc03..773451a36cd 100644 --- a/src/librustc_codegen_llvm/llvm/ffi.rs +++ b/src/librustc_codegen_llvm/llvm/ffi.rs @@ -1729,6 +1729,7 @@ extern "C" { ) -> LLVMRustResult; pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char); pub fn LLVMRustPrintPasses(); + pub fn LLVMRustGetInstructionCount(M: &Module) -> u32; pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char); pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool); pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t); diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 16d08ee534e..e6c45b8e362 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -87,6 +87,14 @@ extern "C" char *LLVMRustGetLastError(void) { return Ret; } +extern "C" unsigned int LLVMRustGetInstructionCount(LLVMModuleRef M) { +#if LLVM_VERSION_GE(7, 0) + return unwrap(M)->getInstructionCount(); +#else + report_fatal_error("Module::getInstructionCount not available before LLVM 7"); +#endif +} + extern "C" void LLVMRustSetLastError(const char *Err) { free((void *)LastError); LastError = strdup(Err); |
