[Mlir-commits] [mlir] [mlir][target] Adjust the start and end position of the moduleToObject timer (PR #132693)

Guray Ozen llvmlistbot at llvm.org
Mon Mar 24 02:07:20 PDT 2025


https://github.com/grypp updated https://github.com/llvm/llvm-project/pull/132693

>From b8d39238149361d2a09787f446424b9ca62cc588 Mon Sep 17 00:00:00 2001
From: Zichen Lu <mikaovo2000 at gmail.com>
Date: Mon, 24 Mar 2025 16:33:56 +0800
Subject: [PATCH] [mlir][target] Adjust the start and end position of the
 moduleToObject timer

---
 mlir/lib/Target/LLVM/NVVM/Target.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mlir/lib/Target/LLVM/NVVM/Target.cpp b/mlir/lib/Target/LLVM/NVVM/Target.cpp
index 5a2b829fbd1bd..cccb2c276ae37 100644
--- a/mlir/lib/Target/LLVM/NVVM/Target.cpp
+++ b/mlir/lib/Target/LLVM/NVVM/Target.cpp
@@ -672,7 +672,6 @@ NVPTXSerializer::moduleToObject(llvm::Module &llvmModule) {
   llvm::Timer moduleToObjectTimer(
       "moduleToObjectTimer",
       "Timer for perf llvm-ir -> isa and isa -> binary.");
-  moduleToObjectTimer.startTimer();
   // Return LLVM IR if the compilation target is `offload`.
 #define DEBUG_TYPE "serialize-to-llvm"
   LLVM_DEBUG({
@@ -699,16 +698,17 @@ NVPTXSerializer::moduleToObject(llvm::Module &llvmModule) {
                                << triple << ", can't optimize with LLVM\n";
     return std::nullopt;
   }
+  moduleToObjectTimer.startTimer();
   std::optional<std::string> serializedISA =
       translateToISA(llvmModule, **targetMachine);
+  moduleToObjectTimer.stopTimer();
+  llvmToISATimeInMs = moduleToObjectTimer.getTotalTime().getWallTime() * 1000;
+  moduleToObjectTimer.clear();
   if (!serializedISA) {
     getOperation().emitError() << "Failed translating the module to ISA.";
     return std::nullopt;
   }
 
-  moduleToObjectTimer.stopTimer();
-  llvmToISATimeInMs = moduleToObjectTimer.getTotalTime().getWallTime() * 1000;
-  moduleToObjectTimer.clear();
   if (isaCallback)
     isaCallback(serializedISA.value());
 



More information about the Mlir-commits mailing list