1
Fork 0

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.
This commit is contained in:
Simon Heath 2019-10-23 09:08:26 -04:00
parent 8c7b921feb
commit 567962d220
2 changed files with 9 additions and 0 deletions

View file

@ -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);