[flang] [llvm] [flang][intrinsics] Implement the time intrinsic (PR #133823)

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 31 16:24:08 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- flang-rt/lib/runtime/extensions.cpp flang/include/flang/Optimizer/Builder/IntrinsicCall.h flang/include/flang/Optimizer/Builder/Runtime/Intrinsics.h flang/include/flang/Runtime/extensions.h flang/lib/Evaluate/intrinsics.cpp flang/lib/Optimizer/Builder/IntrinsicCall.cpp flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/flang-rt/lib/runtime/extensions.cpp b/flang-rt/lib/runtime/extensions.cpp
index 0a6ba6d38..686a976b2 100644
--- a/flang-rt/lib/runtime/extensions.cpp
+++ b/flang-rt/lib/runtime/extensions.cpp
@@ -269,9 +269,7 @@ void FORTRAN_PROCEDURE_NAME(qsort)(int *array, int *len, int *isize,
 }
 
 // GNU extension function TIME()
-std::int64_t RTNAME(time)() {
-  return time(nullptr);
-}
+std::int64_t RTNAME(time)() { return time(nullptr); }
 
 } // namespace Fortran::runtime
 } // extern "C"
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index 81852cfb4..9b8a8375f 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -975,7 +975,8 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
         DefaultInt, Rank::vector, IntrinsicClass::transformationalFunction},
     {"this_image", {OptionalTEAM}, DefaultInt, Rank::scalar,
         IntrinsicClass::transformationalFunction},
-    {"time", {}, TypePattern{IntType, KindCode::exactKind, 8}, Rank::scalar, IntrinsicClass::transformationalFunction},
+    {"time", {}, TypePattern{IntType, KindCode::exactKind, 8}, Rank::scalar,
+        IntrinsicClass::transformationalFunction},
     {"tiny",
         {{"x", SameReal, Rank::anyOrAssumedRank, Optionality::required,
             common::Intent::In, {ArgFlag::canBeMoldNull}}},
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index d4f380379..6629e322b 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -8373,15 +8373,13 @@ void IntrinsicLibrary::genThreadFenceSystem(
 }
 
 // TIME
-mlir::Value
-IntrinsicLibrary::genTime(mlir::Type resultType,
-                          llvm::ArrayRef<mlir::Value> args) {
+mlir::Value IntrinsicLibrary::genTime(mlir::Type resultType,
+                                      llvm::ArrayRef<mlir::Value> args) {
   assert(args.size() == 0);
-  return builder.createConvert(loc, resultType, 
-    fir::runtime::genTime(builder, loc));
+  return builder.createConvert(loc, resultType,
+                               fir::runtime::genTime(builder, loc));
 }
 
-
 // TRIM
 fir::ExtendedValue
 IntrinsicLibrary::genTrim(mlir::Type resultType,
diff --git a/flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp b/flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp
index 183eb0376..3aad06250 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp
@@ -253,7 +253,7 @@ void fir::runtime::genRename(fir::FirOpBuilder &builder, mlir::Location loc,
 }
 
 /// generate runtime call to time intrinsic
-mlir::Value fir::runtime::genTime(fir::FirOpBuilder &builder, 
+mlir::Value fir::runtime::genTime(fir::FirOpBuilder &builder,
                                   mlir::Location loc) {
   auto func = fir::runtime::getRuntimeFunc<mkRTKey(time)>(loc, builder);
   return builder.create<fir::CallOp>(loc, func, std::nullopt).getResult(0);

``````````

</details>


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


More information about the llvm-commits mailing list