From 567962d22090bbd23c1c3dc0e04229ac8c681ea8 Mon Sep 17 00:00:00 2001 From: Simon Heath Date: Wed, 23 Oct 2019 09:08:26 -0400 Subject: Add FFI bindings for Module::getInstructionCount() Just to make it useable for profiling and such inside rustc itself. It was vaguely useful in https://wiki.alopex.li/WhereRustcSpendsItsTime and I figured I might as well upstream it; I may or may not ever get around to doing more with it (hopefully I will), but it may be useful for others. --- src/rustllvm/RustWrapper.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/rustllvm/RustWrapper.cpp') 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); -- cgit 1.4.1-3-g733a5