Skip to content

Commit 6ee97f1

Browse files
committed
print stats
1 parent 54c1680 commit 6ee97f1

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

+2
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,8 @@ pub(crate) unsafe fn codegen(
568568
let llcx = &*module.module_llvm.llcx;
569569
let tm = &*module.module_llvm.tm;
570570
let module_name = module.name.clone();
571+
let count = unsafe { llvm::LLVMRustModuleInstructionStats(&llmod) };
572+
println!("llvm-module: {module_name} = {count}");
571573
let module_name = Some(&module_name[..]);
572574
let handlers = DiagnosticHandlers::new(cgcx, diag_handler, llcx);
573575

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2410,6 +2410,7 @@ extern "C" {
24102410
pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
24112411
pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
24122412
pub fn LLVMRustModuleCost(M: &Module) -> u64;
2413+
pub fn LLVMRustModuleInstructionStats(M: &Module) -> u64;
24132414

24142415
pub fn LLVMRustThinLTOBufferCreate(M: &Module, is_thin: bool) -> &'static mut ThinLTOBuffer;
24152416
pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1754,10 +1754,13 @@ LLVMRustModuleCost(LLVMModuleRef M) {
17541754
extern "C" uint64_t
17551755
LLVMRustModuleInstructionStats(LLVMModuleRef M) {
17561756
auto f = unwrap(M)->functions();
1757+
raw_fd_ostream OS(2, false); // stderr.
17571758
for (auto &func : f)
17581759
{
17591760
auto name = func.getName();
1761+
17601762
auto count = func.getInstructionCount();
1763+
OS << name << "\t" << count << "\n";
17611764
}
17621765
return unwrap(M)->getInstructionCount();
17631766
}

0 commit comments

Comments
 (0)