[flang-commits] [flang] [flang] Relax ETIME(VALUES=) runtime checking (PR #107647)
via flang-commits
flang-commits at lists.llvm.org
Fri Sep 6 15:04:55 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-runtime
Author: Peter Klausler (klausler)
<details>
<summary>Changes</summary>
Don't require the "VALUES=" argument to the extension intrinsic procedure ETIME to have exactly two elements. Other compilers that support ETIME do not, and it's easy to adapt the behavior to whatever the dynamic size turns out to be.
---
Full diff: https://github.com/llvm/llvm-project/pull/107647.diff
1 Files Affected:
- (modified) flang/runtime/time-intrinsic.cpp (+11-7)
``````````diff
diff --git a/flang/runtime/time-intrinsic.cpp b/flang/runtime/time-intrinsic.cpp
index 7e590eabf39660..e6f6e81c7b50cc 100644
--- a/flang/runtime/time-intrinsic.cpp
+++ b/flang/runtime/time-intrinsic.cpp
@@ -490,16 +490,20 @@ void RTNAME(Etime)(const Descriptor *values, const Descriptor *time,
auto typeCode{values->type().GetCategoryAndKind()};
// ETIME values argument must have decimal range == 2.
RUNTIME_CHECK(terminator,
- values->rank() == 1 && values->GetDimension(0).Extent() == 2 &&
- typeCode && typeCode->first == Fortran::common::TypeCategory::Real);
+ values->rank() == 1 && typeCode &&
+ typeCode->first == Fortran::common::TypeCategory::Real);
// Only accept KIND=4 here.
int kind{typeCode->second};
RUNTIME_CHECK(terminator, kind == 4);
-
- ApplyFloatingPointKind<StoreFloatingPointAt, void>(
- kind, terminator, *values, /* atIndex = */ 0, usrTime);
- ApplyFloatingPointKind<StoreFloatingPointAt, void>(
- kind, terminator, *values, /* atIndex = */ 1, sysTime);
+ auto extent{values->GetDimension(0).Extent()};
+ if (extent >= 1) {
+ ApplyFloatingPointKind<StoreFloatingPointAt, void>(
+ kind, terminator, *values, /* atIndex = */ 0, usrTime);
+ }
+ if (extent >= 2) {
+ ApplyFloatingPointKind<StoreFloatingPointAt, void>(
+ kind, terminator, *values, /* atIndex = */ 1, sysTime);
+ }
}
if (time) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/107647
More information about the flang-commits
mailing list