record llvm cgu instruction stats

This commit is contained in:
csmoe 2022-11-03 22:34:24 +08:00
parent 07c993eba8
commit a30de6e7cb
6 changed files with 41 additions and 0 deletions

View file

@ -1751,6 +1751,19 @@ LLVMRustModuleCost(LLVMModuleRef M) {
return std::distance(std::begin(f), std::end(f));
}
extern "C" void
LLVMRustModuleInstructionStats(LLVMModuleRef M, RustStringRef Str)
{
RawRustStringOstream OS(Str);
llvm::json::OStream JOS(OS);
auto Module = unwrap(M);
JOS.object([&] {
JOS.attribute("module", Module->getName());
JOS.attribute("total", Module->getInstructionCount());
});
}
// Vector reductions:
extern "C" LLVMValueRef
LLVMRustBuildVectorReduceFAdd(LLVMBuilderRef B, LLVMValueRef Acc, LLVMValueRef Src) {