diff options
| author | Pietro Albini <pietro@pietroalbini.org> | 2019-11-05 09:49:50 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-05 09:49:50 +0100 |
| commit | 7976d5720a5393274b16b2318375075d4f8d9da8 (patch) | |
| tree | 41859a64450c74f482ef8d9ee5a6dde7a61cba8f /src/rustllvm/RustWrapper.cpp | |
| parent | 5831e0643e1f3772950075e55b62e3a4d0de297a (diff) | |
| parent | 567962d22090bbd23c1c3dc0e04229ac8c681ea8 (diff) | |
| download | rust-7976d5720a5393274b16b2318375075d4f8d9da8.tar.gz rust-7976d5720a5393274b16b2318375075d4f8d9da8.zip | |
Rollup merge of #65720 - icefoxen:LLVMgetInstructionCount, r=rkruppe
Add FFI bindings for LLVM's Module::getInstructionCount() Just to make it usable 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.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
| -rw-r--r-- | src/rustllvm/RustWrapper.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
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); |
