[llvm] [flang-rt] Fix for TIMEF test case hanging on Windows (PR #195651)

via llvm-commits llvm-commits at lists.llvm.org
Mon May 4 06:22:29 PDT 2026


https://github.com/NimishMishra created https://github.com/llvm/llvm-project/pull/195651

The merging of PR https://github.com/llvm/llvm-project/pull/185377 caused a test case to hang on Windows. This PR fixes the same by adding an upper bound on the number of iterations of the test-loop, post which the test gracefully exits irrespective of whether the TIMEF functionality is supported on Windows or not.

>From 6429eaf4b71a1b54eb4b7255842becf6fa77ecab Mon Sep 17 00:00:00 2001
From: NimishMishra <neelam.nimish at gmail.com>
Date: Mon, 4 May 2026 18:47:25 +0530
Subject: [PATCH 1/2] [flang-rt] Fix for hanging Windows test case

---
 flang-rt/unittests/Runtime/Time.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/flang-rt/unittests/Runtime/Time.cpp b/flang-rt/unittests/Runtime/Time.cpp
index 08c672c739909..3cf35074309f1 100644
--- a/flang-rt/unittests/Runtime/Time.cpp
+++ b/flang-rt/unittests/Runtime/Time.cpp
@@ -41,8 +41,11 @@ TEST(TimeIntrinsics, Timef) {
   // Loop until we get a different value from Timef. If we don't get one
   // before we time out, then we should probably look into an implementation
   // for Timef with a better timer resolution.
-  // By default, this loop should burn for 1 second.
-  for (end = start; end == start; end = RTNAME(Timef)()) {
+  // By default, this loop should burn for 1 second or until the end of
+  // the iteration count.
+  int max_iterations{10000000};
+  for (int iter = 0, end = start; end == start && iter < max_iterations;
+      end = RTNAME(Timef)(), iter++) {
     ASSERT_GE(end, 0.0);
     ASSERT_GE(end, start);
   }

>From d30380c6eb2d1de2a2f2371e4b797bd9821af07f Mon Sep 17 00:00:00 2001
From: NimishMishra <neelam.nimish at gmail.com>
Date: Mon, 4 May 2026 18:48:26 +0530
Subject: [PATCH 2/2] Modify comment

---
 flang-rt/lib/runtime/extensions.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/flang-rt/lib/runtime/extensions.cpp b/flang-rt/lib/runtime/extensions.cpp
index b653f3634187a..724c4ab6e6fd2 100644
--- a/flang-rt/lib/runtime/extensions.cpp
+++ b/flang-rt/lib/runtime/extensions.cpp
@@ -459,10 +459,8 @@ double RTNAME(Timef)() {
     return duration;
   }
 #else
-  // TODO: Windows implementation. Currently, we return a dummy
-  // non-zero value to prevent the `TIMEF` unittest from
-  // hanging
-  return 1.0;
+  // TODO: Windows implementation.
+  return 0.0;
 #endif
 }
 



More information about the llvm-commits mailing list