[Mlir-commits] [mlir] 1d19006 - [mlir][target] RAII wrap moduleToObject timer to ensure call `clear` function (#136142)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Apr 18 03:33:34 PDT 2025
Author: Zichen Lu
Date: 2025-04-18T12:33:31+02:00
New Revision: 1d190065d92a7cc9fbe322edbfa233c2318c8839
URL: https://github.com/llvm/llvm-project/commit/1d190065d92a7cc9fbe322edbfa233c2318c8839
DIFF: https://github.com/llvm/llvm-project/commit/1d190065d92a7cc9fbe322edbfa233c2318c8839.diff
LOG: [mlir][target] RAII wrap moduleToObject timer to ensure call `clear` function (#136142)
As title, we need to call `Timer::clear` to avoid extra log like this:
```
===-------------------------------------------------------------------------===
...
===-------------------------------------------------------------------------===
Total Execution Time: 0.0000 seconds (0.0000 wall clock)
---Wall Time--- --- Name ---
----- ....
----- Total
```
Added:
Modified:
mlir/lib/Target/LLVM/NVVM/Target.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Target/LLVM/NVVM/Target.cpp b/mlir/lib/Target/LLVM/NVVM/Target.cpp
index 586748df8d154..f8420385cbec4 100644
--- a/mlir/lib/Target/LLVM/NVVM/Target.cpp
+++ b/mlir/lib/Target/LLVM/NVVM/Target.cpp
@@ -26,6 +26,7 @@
#include "mlir/Target/LLVMIR/Dialect/NVVM/NVVMToLLVMIRTranslation.h"
#include "mlir/Target/LLVMIR/Export.h"
+#include "llvm/ADT/ScopeExit.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FileUtilities.h"
@@ -673,6 +674,7 @@ NVPTXSerializer::moduleToObject(llvm::Module &llvmModule) {
llvm::Timer moduleToObjectTimer(
"moduleToObjectTimer",
"Timer for perf llvm-ir -> isa and isa -> binary.");
+ auto clear = llvm::make_scope_exit([&]() { moduleToObjectTimer.clear(); });
// Return LLVM IR if the compilation target is `offload`.
#define DEBUG_TYPE "serialize-to-llvm"
LLVM_DEBUG({
More information about the Mlir-commits
mailing list