diff --git a/Cargo.lock b/Cargo.lock index 9e4b2915feff..bfea1a36eb34 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3638,8 +3638,6 @@ dependencies = [ "rustc_span", "rustc_symbol_mangling", "rustc_target", - "serde", - "serde_json", "smallvec", "tracing", ] diff --git a/compiler/rustc_codegen_llvm/Cargo.toml b/compiler/rustc_codegen_llvm/Cargo.toml index b40962b759d8..9741436aacb7 100644 --- a/compiler/rustc_codegen_llvm/Cargo.toml +++ b/compiler/rustc_codegen_llvm/Cargo.toml @@ -38,8 +38,6 @@ rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } rustc_symbol_mangling = { path = "../rustc_symbol_mangling" } rustc_target = { path = "../rustc_target" } -serde = { version = "1", features = ["derive"] } -serde_json = "1" smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } tracing = "0.1" # tidy-alphabetical-end diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index d87de8b38467..e9306e050803 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -1136,7 +1136,7 @@ pub(crate) fn codegen( EmitObj::None => {} } - record_llvm_cgu_instructions_stats(&cgcx.prof, llmod); + record_llvm_cgu_instructions_stats(&cgcx.prof, &module.name, llmod); } // `.dwo` files are only emitted if: @@ -1343,22 +1343,11 @@ fn record_artifact_size( } } -fn record_llvm_cgu_instructions_stats(prof: &SelfProfilerRef, llmod: &llvm::Module) { +fn record_llvm_cgu_instructions_stats(prof: &SelfProfilerRef, name: &str, llmod: &llvm::Module) { if !prof.enabled() { return; } - let raw_stats = - llvm::build_string(|s| unsafe { llvm::LLVMRustModuleInstructionStats(llmod, s) }) - .expect("cannot get module instruction stats"); - - #[derive(serde::Deserialize)] - struct InstructionsStats { - module: String, - total: u64, - } - - let InstructionsStats { module, total } = - serde_json::from_str(&raw_stats).expect("cannot parse llvm cgu instructions stats"); - prof.artifact_size("cgu_instructions", module, total); + let total = unsafe { llvm::LLVMRustModuleInstructionStats(llmod) }; + prof.artifact_size("cgu_instructions", name, total); } diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 75b3e5955b78..ff91b2b691e3 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -2454,7 +2454,7 @@ unsafe extern "C" { pub(crate) fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize; pub(crate) fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer); pub(crate) fn LLVMRustModuleCost(M: &Module) -> u64; - pub(crate) fn LLVMRustModuleInstructionStats(M: &Module, Str: &RustString); + pub(crate) fn LLVMRustModuleInstructionStats(M: &Module) -> u64; pub(crate) fn LLVMRustThinLTOBufferCreate( M: &Module, diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 02e6abf24627..3cc2610c5077 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -1572,16 +1572,8 @@ extern "C" uint64_t LLVMRustModuleCost(LLVMModuleRef M) { return std::distance(std::begin(f), std::end(f)); } -extern "C" void LLVMRustModuleInstructionStats(LLVMModuleRef M, - RustStringRef Str) { - auto OS = RawRustStringOstream(Str); - auto JOS = llvm::json::OStream(OS); - auto Module = unwrap(M); - - JOS.object([&] { - JOS.attribute("module", Module->getName()); - JOS.attribute("total", Module->getInstructionCount()); - }); +extern "C" uint64_t LLVMRustModuleInstructionStats(LLVMModuleRef M) { + return unwrap(M)->getInstructionCount(); } // Transfers ownership of DiagnosticHandler unique_ptr to the caller.