diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2024-11-08 18:51:30 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-08 18:51:30 +1100 |
| commit | 3a48d801557a571c819ce62764ae2cc18605e5c8 (patch) | |
| tree | 1e8c238dd9b0862f0744c6f9a90f7ee6e4e65536 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | |
| parent | 758a904764f438ffe05337912a84d49c62021da5 (diff) | |
| parent | 5bfa0b106e253e6f8ed93d4c4f44534ccbb13c85 (diff) | |
| download | rust-3a48d801557a571c819ce62764ae2cc18605e5c8.tar.gz rust-3a48d801557a571c819ce62764ae2cc18605e5c8.zip | |
Rollup merge of #132590 - Zalathar:z-timings-stats, r=jieyouxu
Simplify FFI calls for `-Ztime-llvm-passes` and `-Zprint-codegen-stats` The existing code for these unstable LLVM-infodump flags was jumping through hoops to pass an allocated C string across the FFI boundary, when it's much simpler to just write to a `&RustString` instead.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
| -rw-r--r-- | compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 645b4082be5..a68eed03e61 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -140,26 +140,14 @@ extern "C" void LLVMRustSetNormalizedTarget(LLVMModuleRef M, unwrap(M)->setTargetTriple(Triple::normalize(Triple)); } -extern "C" const char *LLVMRustPrintPassTimings(size_t *Len) { - std::string buf; - auto SS = raw_string_ostream(buf); - TimerGroup::printAll(SS); - SS.flush(); - *Len = buf.length(); - char *CStr = (char *)malloc(*Len); - memcpy(CStr, buf.c_str(), *Len); - return CStr; -} - -extern "C" const char *LLVMRustPrintStatistics(size_t *Len) { - std::string buf; - auto SS = raw_string_ostream(buf); - llvm::PrintStatistics(SS); - SS.flush(); - *Len = buf.length(); - char *CStr = (char *)malloc(*Len); - memcpy(CStr, buf.c_str(), *Len); - return CStr; +extern "C" void LLVMRustPrintPassTimings(RustStringRef OutBuf) { + auto OS = RawRustStringOstream(OutBuf); + TimerGroup::printAll(OS); +} + +extern "C" void LLVMRustPrintStatistics(RustStringRef OutBuf) { + auto OS = RawRustStringOstream(OutBuf); + llvm::PrintStatistics(OS); } extern "C" LLVMValueRef LLVMRustGetNamedValue(LLVMModuleRef M, const char *Name, |
