1
Fork 0

print on rustc_codegen_llvm and rename malloc and cpy c_char

This commit is contained in:
khei4 2023-07-17 00:37:52 +09:00
parent 138f522b59
commit 4d307c4822
6 changed files with 47 additions and 19 deletions

View file

@ -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" 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" void LLVMRustPrintStatistics() {
raw_fd_ostream OS(2, false); // stderr.
llvm::PrintStatistics(OS);
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,