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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Mar 24 01:35:58 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Zichen Lu (MikaOvO)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/132693.diff


1 Files Affected:

- (modified) mlir/lib/Target/LLVM/NVVM/Target.cpp (+4-4) 


``````````diff
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());
 

``````````

</details>


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


More information about the Mlir-commits mailing list