578 Commits

Author SHA1 Message Date
Peter Klausler
1c35c1a739
[flang] Allow runtime build with AVOID_NATIVE_INT128_T=1
This patch enables the Fortran runtime support library to be
built without native 128-bit integer support in the C++ compiler.

Experimental: do not merge yet.

Differential Revision: https://reviews.llvm.org/D154660
2023-09-01 08:54:38 -07:00
Slava Zakharin
4d9771741d [flang] Improved performance of runtime Matmul/MatmulTranspose.
This patch mostly affects performance of the code produced by
HLIFR lowering. If MATMUL argument is an array slice, then
HLFIR lowering passes the slice to the runtime, whereas
FIR lowering would create a contiguous temporary for the slice.
Performance might be better than the generic implementation
for cases where the leading dimension is contiguous.
This patch improves CPU2000/178.galgel making HLFIR version
faster than FIR version (due to avoiding the temporary copies
for MATMUL arguments).

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D159134
2023-08-29 17:04:00 -07:00
Peter Klausler
212beb66f8
[flang] When formatting integers for Gw.d/Gw.dEe output, only 'w' matters
Leading zeros should appear only for Iw.m output formatting.
Gw, Gw.d, and Gw.dEe output editing all map to Iw with no ".m"
(Fortran 202X 13.7.5.2.2).

Differential Revision: https://reviews.llvm.org/D159037
2023-08-29 09:33:10 -07:00
Peter Klausler
7db0610c06
[flang] INQUIRE(FILE=path, READ/READWRITE/WRITE=x) should be UNKNOWN when unknown
For nonexistent or inaccessible files, we're returning NO, which is
indeed true, but we should return UNKNOWN instead.

Differential Revision: https://reviews.llvm.org/D158653
2023-08-28 14:46:00 -07:00
Slava Zakharin
668f261bfa [flang] Make ISO_Fortran_binding.h a standalone header again.
This implements the proposal from
https://discourse.llvm.org/t/adding-flang-specific-header-files-to-clang/72442/6
Since ISO_Fortran_binding.h is supposed to be included from users'
C/C++ codes, it would better have no dependencies on other header
files.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D158549
2023-08-22 18:56:27 -07:00
Peter Klausler
b21c24c308
[flang][runtime] Recognize and handle FINAL subroutines with contiguous dummy arrays when data are not so
When a FINAL subroutine is being invoked for a discontiguous array, which can
happen for INTENT(OUT) dummy arguments and for some left-hand side variables
in intrinsic assignment statements, it may be the case that the subroutine
being called was defined with a dummy argument that requires contiguous data.

Extend the derived type descriptions used by the runtime to signify when
a special procedure binding requires contiguity; set the flags accordingly;
check them in the runtime support library, and, when necessary, use a
temporary shallow copy of the finalized array data in the call to the
final subroutine.

Differential Revision: https://reviews.llvm.org/D156760
2023-08-01 13:46:45 -07:00
Peter Steinfeld
478e0b5860 [flang] Quadmath 128 bit floating point intrinsics
This update allows constant folding for many 128 bit floating point intrinsics
through the library quadmath, which is only available on some platforms.

Differential Revision: https://reviews.llvm.org/D156435
2023-07-31 11:12:29 -07:00
Slava Zakharin
c78b528f99 [flang][runtime] Handle conflicts for derived types with dynamic components.
When creating a temporary for conflicting LHS and RHS we have to deep copy
the dynamic (allocatable, automatic) components from RHS to the temp.
Otherwise, the conflict may still be present between LHS and temp.

gfortran/regression/alloc_comp_assign_1.f90 is an example where the current
runtime code produces wrong result:
7b5b5dcbf9/Fortran/gfortran/regression/alloc_comp_assign_1.f90 (L50)

Reviewed By: klausler, tblah

Differential Revision: https://reviews.llvm.org/D156364
2023-07-27 13:56:13 -07:00
Peter Klausler
b7585c75ee
[flang][runtime] Fix NORM2([negative, ...])
NORM2 is broken for arrays that start with a negative number
because it sets the initial running max_ value to that number
rather than to its absolute value.

Differential Revision: https://reviews.llvm.org/D155976
2023-07-21 14:57:31 -07:00
Peter Klausler
afdbf1b731
[flang][runtime] Detect NEWUNIT= without FILE= or STATUS='SCRATCH'
It is an error to open a new unit with OPEN(NEWUNIT=) and have
neither a file name nor a scratch status.  Catch it, and report a
new error code.

Differential Revision: https://reviews.llvm.org/D155967
2023-07-21 13:13:08 -07:00
Slava Zakharin
ea7d6a1bd6 [NFC][flang] Distinguish MATMUL and MATMUL-TRANSPOSE printouts.
When MatmulTranpose reports incorrect shapes of the arguments
it cannot represent itself as MATMUL, because the reading
of the first argument's shape will be confusing.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D155911
2023-07-21 12:56:50 -07:00
Peter Klausler
7cf198f798
[flang][runtime] Don't do partial data transfer on short character read with ADVANCE='NO', PAD='NO'
When a non-advancing formatted READ can't completely fill a CHARACTER
input item with data, and PAD='NO', don't modify the variable at all.
This matters when the error is recoverable.

Fixes https://github.com/llvm/llvm-project/issues/63772

Differential Revision: https://reviews.llvm.org/D155000
2023-07-17 10:04:15 -07:00
Jay Foad
92542f2a40 [AMDGPU] Add targets gfx1150 and gfx1151
This is the target definition only. Currently they are treated the same
as GFX 11.0.x.

Differential Revision: https://reviews.llvm.org/D155429
2023-07-17 13:06:12 +01:00
Slava Zakharin
9a53afd2c6 [flang][runtime] Support in-tree device build of Flang runtime.
I changed the set of files that are built for experimental CUDA/OMP
builds, i.e. the files with enabled device support are built
as such and the rest of the files are built just for the host target.
With this change we can build Flang runtime library that is fully functional
on the host target, so in-tree targets like check-flang become operational.

Reviewed By: klausler, PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D155029
2023-07-13 11:58:39 -07:00
Peter Klausler
16e61eb0c4
[flang][runtime] Fix BACKSPACE over an empty record
The implementation of BACKSPACE on a variable-length sequential formatted
file has a bug that prevents it from working on an empty record.

Differential Revision: https://reviews.llvm.org/D154750
2023-07-07 15:54:34 -07:00
Peter Klausler
c9b31dae56
[flang][runtime] Allow OPEN(n,ENCODING=) to change the encoding
OPEN statements can be used to change some, but not all, attributes
of units that have already been opened.  The I/O runtime library
wasn't allowing ENCODING= to be changed.  Every other Fortran compiler
permits this usage, and it's safe and useful, so allow it.
(Otherwise there's no good way to ensure that the preconnected
unit 6 is in UTF-8 mode.)

Differential Revision: https://reviews.llvm.org/D154379
2023-07-03 11:28:28 -07:00
Slava Zakharin
3212051c91 [RFC][flang] Experimental device build of Flang runtime.
These are initial changes to experiment with building the Fortran runtime
as a CUDA or OpenMP target offload library.

The initial patch defines a set of macros that have to be used consistently
in Flang runtime source code so that it can be built for different
offload devices using different programming models (CUDA, HIP, OpenMP target
offload). Currently supported modes are:
* CUDA: Flang runtime may be built as a fatlib for the host and a set
  of CUDA architectures specified during the build. The packaging
  of the device code is done by the CUDA toolchain and may differ
  from toolchan to toolchain.
* OpenMP offload:
  - host_device mode: Flang runtime may be built as a fatlib for the host
    and a set of OpenMP offload architectures. The packaging
    of the device code is done by the OpenMP offload compiler and may differ
    from compiler to compiler.

OpenMP offload 'nohost' mode is a TODO to match the build setup
of libomptarget/DeviceRTL. Flang runtime will be built as LLVM Bitcode
library using Clang/LLVM toolchain. The host part of the library
will be "empty", so there will be two distributable object: the host
Flang runtime and dummy host library with device Flang runtime pieces
packaged using clang-offload-packager and clang.

In all supported modes, enabling parts of Flang runtime for the device
compilation can be done iteratively to make the patches observable.
Note that at any point in time the resulting library may have unresolved
references to not yet enabled parts of Flang runtime.

Example cmake/make commands for building with Clang for NVPTX target:
cmake \
-DFLANG_EXPERIMENTAL_CUDA_RUNTIME=ON \
-DCMAKE_CUDA_ARCHITECTURES=80 \
-DCMAKE_C_COMPILER=/clang_nvptx/bin/clang \
-DCMAKE_CXX_COMPILER=/clang_nvptx/bin/clang++ \
-DCMAKE_CUDA_COMPILER=/clang_nvptx/bin/clang \
/llvm-project/flang/runtime/
make -j FortranRuntime

Example cmake/make commands for building with Clang OpenMP offload:
cmake \
-DFLANG_EXPERIMENTAL_OMP_OFFLOAD_BUILD="host_device" \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DFLANG_OMP_DEVICE_ARCHITECTURES="sm_80" \
../flang/runtime/
make -j FortranRuntime

Differential Revision: https://reviews.llvm.org/D151173
2023-06-27 17:38:01 -07:00
Slava Zakharin
3a4e9f7ae5 [flang][hlfir] Do not dereference unallocated entities in structure constructor.
Component-by-component assignment must be able to handle unallocated
allocatable values in structure constructor. F2018 7.5.10 p. 7 states
that the component must have unallocated status as a result of such
construction. The structure constructor temporary is initialized
such that all the allocatable components are unallocated, so we just
need to make sure not to do the component assignment if RHS is deallocated.

Depends on D152482  (the same LIT test is affected)

Reviewed By: jeanPerier, tblah

Differential Revision: https://reviews.llvm.org/D152493
2023-06-27 14:08:35 -07:00
Slava Zakharin
6e4984a9d5 [flang][hlfir] Enable assignments with allocatable components.
The TODO was left there to verify that Assign() runtime handles
overlaps of allocatable components. It did not, and this change-set
fixes it. Note that the same Assign() issue can be reproduced
without HLFIR. In the following example the LHS would be reallocated
before value of RHS (essentially, the same memory) is read:
```
program main
  type t1
     integer, allocatable :: a(:)
  end type t1
  type(t1) :: x, y
  allocate(x%a(10))
  do i =1,10
     x%a(i) = 2*i
  end do
  x = x
  print *, x%a
  deallocate(x%a)
end program main
```

The test's output would be incorrect (though, this depends on the memory
reuse by malloc):
0 0 0 0 10 12 14 16 18 20

It is very hard to add a Flang unittest exploiting derived types.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D152306
2023-06-06 20:25:07 -07:00
Peter Klausler
e468f07550
[flang] Set "undefined" NEXTREC=n variable to 0 rather than random garbage
12.10.2.17 defines that a INQUIRE statement's NEXTREC=n output value
for a unit that is not connected for direct access becomes undefined,
but the current I/O runtime can fail in a confusing manner by trying
to return uninitialized stack garbage.

Reported on Slack by Tarun Prabhu as an intermittent failure in
the gfortran regression test inquire_pre.f90.

Differential Revision: https://reviews.llvm.org/D152295
2023-06-06 11:58:01 -07:00
Peter Klausler
885b904a70
[flang] Pad output correctly after tabbing with ADVANCE='no' (bug#63111)
Correct the code that implements the production of spaces to bring the
furthestPositionInRecord up to a positionInRecord that was tabbed forward
by a T or TR control edit descriptor.

Fixes bug https://github.com/llvm/llvm-project/issues/63111.

Differential Revision: https://reviews.llvm.org/D152201
2023-06-05 15:35:58 -07:00
Peter Klausler
763e036cc9
[flang] Detect output field width overflow for Inf/NaN
The output editing code paths for F and E/D output that handle
IEEE-754 infinities and NaNs fail to check for overflow of the
output field, which should cause the field to be filled with
asterisks instead.  Catch these cases.

Differential Revision: https://reviews.llvm.org/D151738
2023-05-31 09:08:58 -07:00
Fangrui Song
43bec3376c Remove HAVE_STRERROR
Most systems support strerror_r. For the remaining systems (e.g. MSVC) strerror_s and
strerror can be used as fallbacks. We don't have a supported operating
system/compiler that doesn't provide `strerror`.

Close https://github.com/llvm/llvm-project/issues/62804

https://github.com/flang-compiler/f18/pull/1068 added a fallback
when strerror is unavailable, but I think the code path is dead.

Reviewed By: serge-sans-paille, vzakhari

Differential Revision: https://reviews.llvm.org/D151718
2023-05-30 14:12:20 -07:00
Muhammad Omair Javaid
6cf7fe4a9a Revert "[flang][runtime] Support all non-ASCII characters in temporary path on Windows"
This reverts commit fd0d846633b05e1d0072754aea7f3985be36c0dc.

It seems to have broken various flang unit tests on AArch64 Windows platform.

https://lab.llvm.org/buildbot/#/builders/65/builds/9856
https://lab.llvm.org/buildbot/#/builders/120/builds/4883

Differential Revision: https://reviews.llvm.org/D151571
2023-05-29 12:26:01 +04:00
Markus Mützel
fd0d846633 [flang][runtime] Support all non-ASCII characters in temporary path on Windows
If the path to the TEMP folder contains (non-ASCII) characters that cannot be
encoded in the current 8-bit locale of the user, openfile_mkstemp might fail
on Windows.
That is an unlikely scenario. But given that the path to the default TEMP
folder on Windows contains the Windows user name, it is still possible.

Use the wide character Windows API to avoid that (unlikely) issue.

Reviewed By: vzakhari

Differential Revision: https://reviews.llvm.org/D151571
2023-05-27 14:54:18 +02:00
Mark de Wever
cbaa3597aa Reland "[CMake] Bumps minimum version to 3.20.0.
This reverts commit d763c6e5e2d0a6b34097aa7dabca31e9aff9b0b6.

Adds the patch by @hans from
https://github.com/llvm/llvm-project/issues/62719
This patch fixes the Windows build.

d763c6e5e2d0a6b34097aa7dabca31e9aff9b0b6 reverted the reviews

D144509 [CMake] Bumps minimum version to 3.20.0.

This partly undoes D137724.

This change has been discussed on discourse
https://discourse.llvm.org/t/rfc-upgrading-llvms-minimum-required-cmake-version/66193

Note this does not remove work-arounds for older CMake versions, that
will be done in followup patches.

D150532 [OpenMP] Compile assembly files as ASM, not C

Since CMake 3.20, CMake explicitly passes "-x c" (or equivalent)
when compiling a file which has been set as having the language
C. This behaviour change only takes place if "cmake_minimum_required"
is set to 3.20 or newer, or if the policy CMP0119 is set to new.

Attempting to compile assembly files with "-x c" fails, however
this is workarounded in many cases, as OpenMP overrides this with
"-x assembler-with-cpp", however this is only added for non-Windows
targets.

Thus, after increasing cmake_minimum_required to 3.20, this breaks
compiling the GNU assembly for Windows targets; the GNU assembly is
used for ARM and AArch64 Windows targets when building with Clang.
This patch unbreaks that.

D150688 [cmake] Set CMP0091 to fix Windows builds after the cmake_minimum_required bump

The build uses other mechanism to select the runtime.

Fixes #62719

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D151344
2023-05-27 12:51:21 +02:00
V Donaldson
6c9c69bd76 [flang] Retain the sign of the argument for the result of fraction(0)
The f18 clause 16.9.80 description of the FRACTION(X) intrinsic states:

    Result Value. The result has the value ....
    If X has the value zero, the result is zero.
    If X is an IEEE NaN, the result is that NaN.
    If X is an IEEE infinity, the result is an IEEE NaN.

This clause does not specify whether fraction(-0.0) should be -0.0 or +0.0.
However, a folded result and a runtime result should be consistent, and
returning -0.0 is more in line with the result for fraction(NaN).

For this test:

  print '(2f6.1)', 0.0, fraction(0.0)
  call f(0.0)
  print '(2f6.1)', -0.0, fraction(-0.0)
  call f(-0.0)
  end

  subroutine f(x)
    print '(2f6.1)', x, fraction(x)
  end

Current output is:

   0.0   0.0
   0.0   0.0
  -0.0  -0.0
  -0.0   0.0

Change that to:

   0.0   0.0
   0.0   0.0
  -0.0  -0.0
  -0.0  -0.0
2023-05-26 09:24:30 -07:00
Peter Klausler
d71297ce74
[flang] Fix SPACING() of very small values
SPACING() must return TINY() for zero arguments (which we do)
and also for subnormal values smaller than TINY() in absolute value,
which we get wrong.  Fix folding and the runtime.

Differential Revision: https://reviews.llvm.org/D151272
2023-05-24 08:04:39 -07:00
Peter Klausler
472913c7ef
[flang][runtime] Complete partial output records when positioning/closing after non-advancing output
Before positioning or closing a unit after a non-advancing output statement
has left a partial record in its buffer, complete the record by calling
AdvanceRecord().  Fixes https://github.com/llvm/llvm-project/issues/59761.

Differential Revision: https://reviews.llvm.org/D151134
2023-05-23 15:54:57 -07:00
Slava Zakharin
da60b9e7dc [flang] Fixed managing copy-in/copy-out temps.
There are several observations regarding the copy-in/copy-out:
  * Actual argument associated with INTENT(OUT) dummy argument that
    requires finalization (7.5.6.3 p. 7) may be read by the finalization
    function, so a copy-in is required.
  * A temporary created for the copy-in/copy-out must be destroyed
    without finalization after the call (or after the corresponding copy-out),
    otherwise, memory leaks may occur.
  * The copy-out assignment must not perform finalization for the LHS.
  * The copy-out assignment from the temporary to the actual argument
    may or may not need to initialize the LHS.

This change-set introduces new runtime methods: CopyOutAssign and
DestroyWithoutFinalization. They are called by the compiler generated
code to match the behavior described above.

Reviewed By: jeanPerier

Differential Revision: https://reviews.llvm.org/D151135
2023-05-23 09:35:17 -07:00
Tom Eccles
c01937296b [flang][runtime] Add dynamically allocated temporary storage
These functions will be used as part of the HLFIR lowering for
forall/where. The contents of the API were requested by @jeanPerier.

The API is designed around that use case, assuming that the caller knows
through some side channel what size to allocate for boxes returned from
the pop() function.

Differential Revision: https://reviews.llvm.org/D150050
2023-05-18 10:48:45 +00:00
V Donaldson
6f7a3b0781 [flang] Non-type-bound defined IO lowering
Generate supporting data structures and calls to new runtime IO functions
for defined IO that accesses non-type-bound procedures, such as `wft` in:

module m1
  type t
    integer n
  end type
  interface write(formatted)
    module procedure wft
  end interface
 contains
  subroutine wft(dtv, unit, iotype, v_list, iostat, iomsg)
    class(t), intent(in) :: dtv
    integer, intent(in) :: unit
    character(*), intent(in) :: iotype
    integer, intent(in) :: v_list(:)
    integer, intent(out) :: iostat
    character(*), intent(inout) :: iomsg
    iostat = 0
    write(unit,*,iostat=iostat,iomsg=iomsg) 'wft was called: ', dtv%n
  end subroutine
end module

module m2
 contains
  subroutine test1
    use m1
    print *, 'test1, should call wft: ', t(1)
  end subroutine
  subroutine test2
    use m1, only: t
    print *, 'test2, should not call wft: ', t(2)
  end subroutine
end module

use m1
use m2
call test1
call test2
print *, 'main, should call wft: ', t(3)
end
2023-05-17 09:22:13 -07:00
Nico Weber
d763c6e5e2 Revert "Reland "[CMake] Bumps minimum version to 3.20.0.""
This reverts commit 65429b9af6a2c99d340ab2dcddd41dab201f399c.

Broke several projects, see https://reviews.llvm.org/D144509#4347562 onwards.

Also reverts follow-up commit "[OpenMP] Compile assembly files as ASM, not C"

This reverts commit 4072c8aee4c89c4457f4f30d01dc9bb4dfa52559.

Also reverts fix attempt  "[cmake] Set CMP0091 to fix Windows builds after the cmake_minimum_required bump"

This reverts commit 7d47dac5f828efd1d378ba44a97559114f00fb64.
2023-05-17 10:53:33 -04:00
Slava Zakharin
bf53645634 [flang][runtime] Fixed memory leak in Assign().
The temporary descriptor must be either Pointer or Allocatable,
otherwise its memory will not be freed.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D150534
2023-05-15 10:48:46 -07:00
Slava Zakharin
7c7ffa7bab [flang][runtime] Fixed dimension offset computation for MayAlias.
Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D150533
2023-05-15 10:48:45 -07:00
Mark de Wever
65429b9af6 Reland "[CMake] Bumps minimum version to 3.20.0."
The owner of the last two failing buildbots updated CMake.

This reverts commit e8e8707b4aa6e4cc04c0cffb2de01d2de71165fc.
2023-05-13 11:42:25 +02:00
Peter Klausler
27cf6ba1d7
[flang][runtime] Initialize uninitialized pointer components
Pointer components without default initialization pose some
difficult (or impossible) problems when they appear as right-hand
side targets in pointer assignment statements; they may contain
garbage or stale data that looks enough like a valid descriptor
to cause a crash.  Solve the problem by avoiding it -- ensure
that pointers' descriptors are at least minimally established.

Differential Revision: https://reviews.llvm.org/D149979
2023-05-08 15:08:37 -07:00
Mark de Wever
e8e8707b4a Revert "Reland "[CMake] Bumps minimum version to 3.20.0.""
Unfortunatly not all buildbots are updated.

This reverts commit ffb807ab5375b3f78df198dc5d4302b3b552242f.
2023-05-06 17:03:56 +02:00
Mark de Wever
ffb807ab53 Reland "[CMake] Bumps minimum version to 3.20.0."
All build bots should be updated now.

This reverts commit 44d38022ab29a3156349602733b3459df5beef93.
2023-05-06 11:43:02 +02:00
Slava Zakharin
1aff61ecbf [flang][runtime] Initialize LHS temporary in AssignTemporary.
If LHS is of derived type that needs initialization, then it must be
initialized before doing the assignment. Otherwise, the assignment
might behave incorrectly based on uninitialized components that are
descriptors themselves.

Differential Revision: https://reviews.llvm.org/D149681
2023-05-03 09:19:35 -07:00
Markus Mützel
3299647699 [flang] Avoid dependency of runtime library on pthread for MinGW
When building the Fortran runtime on MinGW, `clock_gettime` is currently used. That function is provided by the `pthread` library on that platform. That means that all programs that link `libFortranRuntime` also require to be linked with `pthread` on that platform.

There is already a code path (for MSVC) that doesn't use `clock_gettime` in the implementation of the Fortran library.
Use the same code path also on MinGW by undefining `CLOCKID`.

Reviewed By: vzakhari

Differential Revision: https://reviews.llvm.org/D149051
2023-04-25 10:12:41 -07:00
Slava Zakharin
55c88aafa6 [flang][runtime] Added Clang CMake modules include path.
Fortran runtime standalone build is broken after D140998
because of the missing CMake modules path. This is a fix.

Differential Revision: https://reviews.llvm.org/D149090
2023-04-25 09:26:48 -07:00
Jean Perier
1ac31a0bfa [flang][runtime] Fix padding in CHARACTER(4) assignments.
One piece of pointer arithmetic was adding the number of bytes instead
of the number of characters. This caused failures in CHARACTER(KIND>1)
that required padding.
This was caught using HLFIR that currently uses the runtime for array
assignment where the current lowering does everything inline.

Reviewed By: vzakhari, klausler

Differential Revision: https://reviews.llvm.org/D149062
2023-04-25 09:05:46 +02:00
Slava Zakharin
a2e1257589 [flang] Added missing _Complex for COMPLEX(10) C reduction API.
I noticed _Complex was missing for the long double case.
I might be missing something, but it looks like the compiler
does not call the C wrappers directly. Do we need to keep
the complex-reduction.[ch] at all?

Differential Revision: https://reviews.llvm.org/D148479
2023-04-17 18:02:03 -07:00
Mark de Wever
44d38022ab Revert "Revert "Revert "[CMake] Bumps minimum version to 3.20.0."""
This reverts commit 1ef4c3c859728008cf707cad8d67f45ae5070ae1.

Two buildbots still haven't been updated.
2023-04-15 20:12:24 +02:00
Mark de Wever
1ef4c3c859 Revert "Revert "[CMake] Bumps minimum version to 3.20.0.""
This reverts commit 92523a35a827539db8557bbc3ecab7f9ea3f6ade.

Reland to see whether CIs are updated.
2023-04-15 13:12:04 +02:00
Peter Klausler
7cf1608b4d
[flang] Rework handling of non-type-bound user-defined I/O
A fairly recent introduction of runtime I/O APIs called OutputDerivedType()
and InputDerivedType() didn't cover NAMELIST I/O's need to access
non-type-bound generic interfaces for user-defined derived type I/O
when those generic interfaces are defined in some scope other than the
one that defines the derived type.

The patch adds a new data structure shared between lowering
and the runtime that can represent all of the cases that can
arise with non-type-bound defined I/O.  It can represent
scopes in which non-type-bound defined I/O generic interfaces
are inaccessible, too, due to IMPORT statements.

The data structure is now an operand to OutputDerivedType() and
InputDerivedType() as well as a data member in the NamelistGroup
structure.

Differential Revision: https://reviews.llvm.org/D148257
2023-04-13 15:35:01 -07:00
Peter Klausler
52a0b02c25
[flang][runtime] Reset the left tab limit when flushing output
When flushing output to a non-positionable tty or socket file, reset the
left tab limit.  Otherwise, non-advancing output to that file will contain
an increasing amount of leading spaces in each flush.  Also, detect
newline characters in stream output, and treat them as record
advancement.

Differential Revision: https://reviews.llvm.org/D148157
2023-04-13 09:43:40 -07:00
Valentin Clement
3acdd596c0
[flang] Handle correctly user defined assignment for allocatable component
In the Fortran standard 2018 section 10.2.1.3 (13), it is mentioned
that all noncoarray allocatable component must follow this sequence of
operations:

1) If the component of the variable is allocated, it is deallocated.
2) If the component of the value of expr is allocated, the corresponding
   component of the variable is allocated with the same dynamic type and
   type parameters as the component of the value of expr. If it is an
   array, it is allocated with the same bounds. The value of the
   component of the value of expr is then assigned to the corresponding
   component of the variable using defined assignment if the declared type
   of the component has a type-bound defined assignment consistent with the
   component, and intrinsic assignment for the dynamic type of that component
   otherwise.

This patch updates the code to make use of the user defined assignment for
allocatable component and make sure the component is allocated correctly.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D147797
2023-04-07 11:47:54 -07:00
Shao-Ce SUN
77d667b114 [flang][runtime] Support L editing of Logical
I tested gfortran and flang(old). https://godbolt.org/z/c89foro4G

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D146989
2023-04-06 01:11:12 +08:00