summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorkhei4 <kk.asano.luxy@gmail.com>2023-07-17 00:37:52 +0900
committerkhei4 <kk.asano.luxy@gmail.com>2023-07-17 00:37:52 +0900
commit4d307c482271ea3575a13b6c04222911e7706189 (patch)
tree32cf391f1ab50bf3d0a56199b8599064b232c325 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parent138f522b590492d1ef80f1483382a2a678dec7d9 (diff)
downloadrust-4d307c482271ea3575a13b6c04222911e7706189.tar.gz
rust-4d307c482271ea3575a13b6c04222911e7706189.zip
print on rustc_codegen_llvm and rename malloc and cpy c_char
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
-rw-r--r--compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
index 89beb09db75..695b8847a97 100644
--- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
@@ -112,14 +112,24 @@ extern "C" void LLVMRustSetNormalizedTarget(LLVMModuleRef M,
   unwrap(M)->setTargetTriple(Triple::normalize(Triple));
 }
 
-extern "C" void LLVMRustPrintPassTimings() {
-  raw_fd_ostream OS(2, false); // stderr.
-  TimerGroup::printAll(OS);
-}
-
-extern "C" void LLVMRustPrintStatistics() {
-  raw_fd_ostream OS(2, false); // stderr.
-  llvm::PrintStatistics(OS);
+extern "C" const char *LLVMRustPrintPassTimings(void) {
+  std::string buf;
+  raw_string_ostream SS(buf);
+  TimerGroup::printAll(SS);
+  SS.flush();
+  char* CStr = (char*) malloc((buf.length() + 1) * sizeof(char));
+  strcpy(CStr, buf.c_str());
+  return CStr;
+}
+
+extern "C" const char *LLVMRustPrintStatistics(void) {
+  std::string buf;
+  raw_string_ostream SS(buf);
+  llvm::PrintStatistics(SS);
+  SS.flush();
+  char* CStr = (char*) malloc((buf.length() + 1) * sizeof(char));
+  strcpy(CStr, buf.c_str());
+  return CStr;
 }
 
 extern "C" LLVMValueRef LLVMRustGetNamedValue(LLVMModuleRef M, const char *Name,