Changes

Summary

  1. [flang][runtime] Don't crash after surviving internal output overflow (details)
  2. [flang] Don't crash on initialization with a zero-sized derived type (details)
  3. [flang][runtime] Fix edge case discrepancies with EN output editing (details)
  4. [flang][runtime] Fix WRITE after OPEN(.., ACCESS="APPEND") (details)
  5. [flang] When folding FINDLOC, convert operands to a common type (details)
  6. [flang][runtime] Fix deadlock in error recovery (details)
  7. [flang][runtime] Emit error message rather than crashing for MOD(ULO)(x,P=0) (details)
  8. [flang][runtime] Catch OPEN of connected file (details)
  9. [mlir] Use context provided rather than getContext (details)
  10. [VPlan] Update vector latch terminator edge to exit block after execution. (details)
Commit ea5b205bb89508613ee0a57ccbfd6924c4a9586b by pklausler
[flang][runtime] Don't crash after surviving internal output overflow

After the program has survived its attempt to overflow the output buffer
with an internal WRITE using ERR=, IOSTAT=, &/or IOMSG=, don't crash
by accidentally blank-filling the next record that usually doesn't exist.

Differential Revision: https://reviews.llvm.org/D127024
The file was modifiedflang/runtime/internal-unit.cpp
Commit d484fe93d4e827b4986b15f9db52099c925139b0 by pklausler
[flang] Don't crash on initialization with a zero-sized derived type

Avoid calls to memcpy with zero byte counts if their address argument
calculations may not be valid expressions.

Differential Revision: https://reviews.llvm.org/D127027
The file was modifiedflang/include/flang/Evaluate/initial-image.h
The file was modifiedflang/lib/Evaluate/initial-image.cpp
Commit dfcccc6dee90e08b9ae0f53c42c9c239fe4031a1 by pklausler
[flang][runtime] Fix edge case discrepancies with EN output editing

The "engineering" ENw.d output editing descriptor has some difficult
edge case behavior for values that might format into a bunch of 9's
or round up to a 1 for a given scale factor.  Fix the algorithm,
and add tests to protect against regressions.

Differential Revision: https://reviews.llvm.org/D127028
The file was modifiedflang/unittests/Runtime/NumericalFormatTest.cpp
The file was modifiedflang/runtime/edit-output.cpp
Commit 9a163ffe1a507c1f5a3d29b896224112d7e54f62 by pklausler
[flang][runtime] Fix WRITE after OPEN(.., ACCESS="APPEND")

The initial size of the file was not being captured as the file position
on which the first output buffer should be framed.

Differential Revision: https://reviews.llvm.org/D127029
The file was modifiedflang/runtime/file.cpp
The file was modifiedflang/runtime/unit.cpp
Commit ed71a0b45b6c927333fa2c91e16f75a251408691 by pklausler
[flang] When folding FINDLOC, convert operands to a common type

For example, FINDLOC(A,X) should convert both A and X to COMPLEX(8)
if the operands are REAL(8) and COMPLEX(4), so that comparisons
can be done without losing inforation.  The current implementation
unconditionally converts X to the type of the array A.

Differential Revision: https://reviews.llvm.org/D127030
The file was modifiedflang/lib/Evaluate/fold-integer.cpp
The file was modifiedflang/include/flang/Evaluate/type.h
The file was modifiedflang/lib/Evaluate/type.cpp
Commit 11f928af9bfaefc0965a43f5ad6d480ded3de4a5 by pklausler
[flang][runtime] Fix deadlock in error recovery

When an external I/O statement is in a recoverable error
state before any data transfers take place (for example,
an unformatted transfer with ERR=/IOSTAT=/IOMSG= attempted on
a formatted unit), ensure that the unit's mutex is still
released at the end of the statement.

Differential Revision: https://reviews.llvm.org/D127032
The file was modifiedflang/runtime/io-stmt.cpp
The file was modifiedflang/runtime/io-api.cpp
The file was modifiedflang/runtime/io-stmt.h
Commit 562fd2c99b70691affe7776a1900e95ee7da0b3b by pklausler
[flang][runtime] Emit error message rather than crashing for MOD(ULO)(x,P=0)

Add extra arguments and checks to the runtime support library so that
a call to the intrinsic functions MOD and MODULO with "denominator"
argument P of zero will cause a crash with a source location rather
than an uninformative floating-point error or integer division by
zero signal.

Additional work is required in lowering to (1) pass source file path and
source line number arguments and (2) actually call these runtime
library APIs instead of emitting inline code for MOD &/or MODULO.

Differential Revision: https://reviews.llvm.org/D127034
The file was modifiedflang/runtime/numeric.cpp
The file was modifiedflang/include/flang/Runtime/numeric.h
Commit 03c066ab134f02289df1b61db00294c1da579f9c by pklausler
[flang][runtime] Catch OPEN of connected file

Diagnose OPEN(FILE=f) when f is already connected by the same name to
a distinct external I/O unit.

Differential Revision: https://reviews.llvm.org/D127035
The file was modifiedflang/runtime/unit-map.h
The file was modifiedflang/runtime/unit.cpp
The file was modifiedflang/runtime/unit.h
The file was modifiedflang/include/flang/Runtime/iostat.h
The file was modifiedflang/runtime/iostat.cpp
The file was modifiedflang/runtime/file.h
The file was modifiedflang/runtime/unit-map.cpp
The file was modifiedflang/runtime/file.cpp
The file was modifiedflang/runtime/io-api.cpp
Commit 29794ab0fae526073cb1f0f8cd4662243c7e3c3a by jpienaar
[mlir] Use context provided rather than getContext

Avoids "pass state was never initialized" assertion failure.
The file was modifiedmlir/test/lib/Tools/PDLL/TestPDLL.cpp
Commit 416a5080d89066029f9889dc23f94de47c2fa895 by flo
[VPlan] Update vector latch terminator edge to exit block after execution.

Instead of setting the successor to the exit using CFG.ExitBB, set it to
nullptr initially. The successor to the exit block is later set either
through createEmptyBasicBlock or after VPlan execution (because at the
moment, no block is created by VPlan for the exit block, the existing
one is reused).

This also enables BranchOnCond to be used as terminator for the exiting
block of the topmost vector region.

Depends on D126618.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D126679
The file was modifiedllvm/lib/Transforms/Vectorize/VPlan.cpp