summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorcsmoe <csmoe@msn.com>2022-11-03 22:34:24 +0800
committercsmoe <csmoe@msn.com>2023-02-25 16:18:56 +0800
commita30de6e7cb1458e271ead5e40e49dbe709275537 (patch)
tree6c2c19a7f7ecd7b404e57b8a9cdb2da4f2fd830e /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parent07c993eba8b76eae497e98433ae075b00f01be10 (diff)
downloadrust-a30de6e7cb1458e271ead5e40e49dbe709275537.tar.gz
rust-a30de6e7cb1458e271ead5e40e49dbe709275537.zip
record llvm cgu instruction stats
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
-rw-r--r--compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
index b1e6534944d..e3493caaaf7 100644
--- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
@@ -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) {