From 637258e1752355d663e377dc9e2bede7667a5472 Mon Sep 17 00:00:00 2001 From: Sergey Bogolepov Date: Thu, 9 Feb 2023 16:54:46 +0200 Subject: [PATCH] [K/N] Add LLVM C wrappers for -time-passes API. --- .../libllvmext/src/main/cpp/CAPIExtensions.cpp | 13 +++++++++++++ .../libllvmext/src/main/include/CAPIExtensions.h | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/kotlin-native/libllvmext/src/main/cpp/CAPIExtensions.cpp b/kotlin-native/libllvmext/src/main/cpp/CAPIExtensions.cpp index 0a7e3e1e4ba..f524a5473f6 100644 --- a/kotlin-native/libllvmext/src/main/cpp/CAPIExtensions.cpp +++ b/kotlin-native/libllvmext/src/main/cpp/CAPIExtensions.cpp @@ -11,6 +11,7 @@ #include #include #include +#include using namespace llvm; @@ -58,3 +59,15 @@ int LLVMInlineCall(LLVMValueRef call) { void LLVMAddThreadSanitizerPass(LLVMPassManagerRef PM) { unwrap(PM)->add(createThreadSanitizerLegacyPassPass()); } + +void LLVMSetTimePasses(int enabled) { + llvm::TimePassesIsEnabled = static_cast(enabled); +} + +void LLVMPrintAllTimersToStdOut() { + llvm::TimerGroup::printAll(llvm::outs()); +} + +void LLVMClearAllTimers() { + llvm::TimerGroup::clearAll(); +} diff --git a/kotlin-native/libllvmext/src/main/include/CAPIExtensions.h b/kotlin-native/libllvmext/src/main/include/CAPIExtensions.h index c9d5f654804..d8dc2e4344f 100644 --- a/kotlin-native/libllvmext/src/main/include/CAPIExtensions.h +++ b/kotlin-native/libllvmext/src/main/include/CAPIExtensions.h @@ -27,6 +27,15 @@ int LLVMInlineCall(LLVMValueRef call); void LLVMAddThreadSanitizerPass(LLVMPassManagerRef PM); +/// Control LLVM -time-passes flag. +void LLVMSetTimePasses(int enabled); + +/// Print timing results. Useful in combination with LLVMSetTimePasses. +void LLVMPrintAllTimersToStdOut(); + +/// Clear all LLVM timers. Allows avoiding automatic printing on shutdown +void LLVMClearAllTimers(); + # ifdef __cplusplus } # endif \ No newline at end of file