Skip to content

Commit 1d19006

Browse files
authored
[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 ```
1 parent 9b8bc53 commit 1d19006

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mlir/lib/Target/LLVM/NVVM/Target.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "mlir/Target/LLVMIR/Dialect/NVVM/NVVMToLLVMIRTranslation.h"
2727
#include "mlir/Target/LLVMIR/Export.h"
2828

29+
#include "llvm/ADT/ScopeExit.h"
2930
#include "llvm/Config/llvm-config.h"
3031
#include "llvm/Support/FileSystem.h"
3132
#include "llvm/Support/FileUtilities.h"
@@ -673,6 +674,7 @@ NVPTXSerializer::moduleToObject(llvm::Module &llvmModule) {
673674
llvm::Timer moduleToObjectTimer(
674675
"moduleToObjectTimer",
675676
"Timer for perf llvm-ir -> isa and isa -> binary.");
677+
auto clear = llvm::make_scope_exit([&]() { moduleToObjectTimer.clear(); });
676678
// Return LLVM IR if the compilation target is `offload`.
677679
#define DEBUG_TYPE "serialize-to-llvm"
678680
LLVM_DEBUG({

0 commit comments

Comments
 (0)