This is an archive of the discontinued LLVM Phabricator instance.

[flang] Implement Posix version of DATE_AND_TIME runtime
ClosedPublic

Authored by jeanPerier on Aug 24 2021, 4:36 AM.

Details

Summary

Use gettimeofday and localtime_r to implement DATE_AND_TIME intrinsic.
The Windows version fallbacks to the "no date and time information
available" defined by the standard (strings set to blanks and values to
-HUGE).

The implementation uses an ifdef between windows and the rest because
from my tests, the SFINAE approach leads to undeclared name bogus errors
with clang 8 that seems to ignore failure to instantiate is not an error
for the function names (i.e., it understands it should not instantiate
the version using gettimeofday if it is not there, but still yields an
error that it is not declared on the spot where it is called in the
uninstantiated version).

Diff Detail

Event Timeline

jeanPerier created this revision.Aug 24 2021, 4:36 AM
jeanPerier requested review of this revision.Aug 24 2021, 4:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2021, 4:36 AM

Looks like it's doing what's needed. Is there a follow-on patch to fix the fact that values isn't being passed to the DATE_AND_TIME subroutine?

Fix windows build and accept zone == 0 in unit tests.

Looks like it's doing what's needed. Is there a follow-on patch to fix the fact that values isn't being passed to the DATE_AND_TIME subroutine?

Do you mean a patch in lowering ?

If so, yes, once this is up streamed, lowering will be updated.

Looks like it's doing what's needed. Is there a follow-on patch to fix the fact that values isn't being passed to the DATE_AND_TIME subroutine?

Do you mean a patch in lowering ?

If so, yes, once this is up streamed, lowering will be updated.

Yes, I mean the lowering of calls to DATE_AND_TIME - line 2080 in IntrinsicCall.cpp which prints a message saying values is not yet implemented.

If you remember, do add me to that review.

klausler accepted this revision.Aug 24 2021, 9:05 AM
klausler added inline comments.
flang/runtime/time-intrinsic.cpp
178

You may not need distinct anonymous namespaces here.

This revision is now accepted and ready to land.Aug 24 2021, 9:05 AM

Merge anonymous namespaces.

jeanPerier marked an inline comment as done.Aug 25 2021, 1:00 AM