[flang-commits] [flang] fe58527 - [flang] Relax ETIME(VALUES=) runtime checking (#107647)
via flang-commits
flang-commits at lists.llvm.org
Tue Sep 10 14:11:40 PDT 2024
Author: Peter Klausler
Date: 2024-09-10T14:11:37-07:00
New Revision: fe58527305d86df8bd9770f3d41a6de420958af7
URL: https://github.com/llvm/llvm-project/commit/fe58527305d86df8bd9770f3d41a6de420958af7
DIFF: https://github.com/llvm/llvm-project/commit/fe58527305d86df8bd9770f3d41a6de420958af7.diff
LOG: [flang] Relax ETIME(VALUES=) runtime checking (#107647)
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.
Added:
Modified:
flang/runtime/time-intrinsic.cpp
Removed:
################################################################################
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) {
More information about the flang-commits
mailing list