| Age | Commit message (Collapse) | Author |
|
Modify the TypeCategory for quad-precision COMPLEX to
CFI_type_float128_Complex so it matches the TypeCode returned
by SELECT TYPE lowering.
Fixes #134565
|
|
The ISO Fortran standards don't say whether a WRITE to a formatted
stream unit should truncate the unit if there has been any repositioning
(via POS= control list specifiers) to an earlier point in the stream.
But units with sequential records do truncate on writes after BACKSPACE
and REWIND statements, and many compilers (including this one) truncate
stream units too. Since some compilers don't truncate streams, this
patch adds an environment variable FORT_TRUNCATE_STREAM that can be set
to 0 to disable truncation and ease porting to flang-new of codes that
depend on that behavior.
Fixes https://github.com/llvm/llvm-project/issues/167569.
|
|
When a formatted WRITE takes place in a defined output subroutine called
from a context in which record advancement is allowed, such as NAMELIST,
the char-string-edit-descs in the format can trigger record advancement.
Also clean up confusing messiness lingering from the separation of
iostat.h two headers in flang/.../Runtime. iostat.h didn't need to be
put into flang/.../Runtime since it's included only by flang-rt, and
iostat-consts.h doesn't need one of its includes.
Fixes https://github.com/llvm/llvm-project/issues/167757.
|
|
The LLVM-customized GTest has a dependency on LLVM to support
`llvm::raw_ostream` and hence has to link to LLVMSupport. The runtimes
use the LLVMSupport from the bootstrapping LLVM build. The problem is
that the boostrapping compiler and the runtimes target can diverge in
their ABI, even in the runtimes default build. For instance, Clang is
built using gcc which uses libstdc++, but the runtimes is built by Clang
which can be configured to use libcxx by default. Altough it does not
use gcc, this issue has caused
[flang-aarch64-libcxx](https://lab.llvm.org/buildbot/#/builders/89)) to
break, and is still (again?) broken.
This patch makes the runtimes' GTest independent from LLVMSupport so we
do not link any runtimes component with LLVM components.
Runtime projects that use GTest unittests:
* flang-rt
* libc
* compiler-rt: Adds `gtest-all.cpp` with
[GTEST_NO_LLVM_SUPPORT=1](https://github.com/llvm/llvm-project/blob/f801b6f67ea896d6e4d2de38bce9a79689ceb254/compiler-rt/CMakeLists.txt#L723)
to each unittest without using `llvm_gtest`. Not touched by this PR.
* openmp: Handled by #159416. Not touched for now by this PR to avoid
conflict.
The current state of this PR tries to reuse
https://github.com/llvm/llvm-project/blob/main/third-party/unittest/CMakeLists.txt
as much as possible, altough personally I would prefer to make it use
"modern CMake" style. third-party/unittest/CMakeLists.txt will detect
whether it is used in runtimes build and adjaust accordingly. It creates
a different target for LLVM (`llvm_gtest`, NFCI) and another one for the
runtimes (`runtimes_gtest`). It is not possible to reuse `llvm_gtest`
for both since `llvm_gtest` is imported using `find_package(LLVM)` if
configured using LLVM_INSTALL_GTEST. An alias `default_gtest` is used to
select between the two. `default_gtest` could also be used for openmp
which also supports standalone and
[LLVM_ENABLE_PROJECTS](https://github.com/llvm/llvm-project/pull/152189)
build mode.
|
|
|
|
List-directed child input is allowed to advance to new records in some
circumstances, and list-directed output should be as well so that e.g.
NAMELIST output via a defined WRITE(FORMATTED) generic doesn't get
truncated by FORT_FMT_RECL.
Fixes https://github.com/llvm/llvm-project/issues/166804.
|
|
|
|
When skipping blanks during input from an ASCII file, scan the buffered
characters directly when possible rather than using the more general
path. This adds complexity, but shaves a few percent off the runtime of
a code that reads in millions of list-directed integers (best time over
multiple runs goes from 17.56 to 16.84 sec).
|
|
As in https://github.com/llvm/llvm-project/pull/164463, do not do error
checking in the runtime itself but let error go through as user might
want to catch them for error recovery.
|
|
Align behavior with other CUDA compiler.
|
|
Reverts llvm/llvm-project#164321
Align behavior with other CUDA Compiler
|
|
Set block size x and y to 1024 if the given value is higher. Set block z
to 64 if the given value is higher.
|
|
Define the _GLIBCXX_THROW_OR_ABORT macro to not use its _EXC argument. _EXC may contain an expression constructing an std::exception object which is non-inline and therefore require a link dependency on the libstdc++ runtime. In -fno-exceptions builds it is typically optimized away when appearing in unreachable code, but is still present when compiling with -O0 when compiling with Clang.
---------
Co-authored-by: Michael Kruse <github@meinersbur.de>
|
|
|
|
compilation (#161760)
NVCC does more aggressive inlining than Clang/GCC causing the exported
functions in extrema.cpp and findloc.cpp to become extremely large from
function specializations leading to compilation timeouts. Marking the 2
functions in this change as noinline for NVCC alleviates this problem as
it removes the worst of the cross-matrix argument specializations.
Also remove the workaround in
https://github.com/llvm/llvm-project/pull/156542 that opted out
findloc.cpp from the CUDA flang-rt build
Testing:
ninja flang-rt builds in ~30 minutes, these 2 files build in ~3 minutes
|
|
The specialized version has a time complexity of `O(n)`.
|
|
Fixes https://github.com/llvm/llvm-project/issues/155459 by making sure
the cases are considered in the right order. Previously intrinsics types
where overriding the pointer cases which have higher precedence in the
specification.
Also passes the following
[tests](https://github.com/llvm/llvm-test-suite/pull/287).
|
|
The IOTYPE and V_LIST dummy arguments to a defined formatted I/O
subroutine are extracted from a DT edit descriptor in a FORMAT. They are
currently stored in the DataEdit structure, and their maximum sizes are
rather small since DataEdits are sometimes returned or passed by value.
This patch moves their storage into the FormattedIoStatementState
structure and enlarges them a bit.
Fixes https://github.com/llvm/llvm-project/issues/154954.
|
|
Whether list-directed child READ statements should be allowed to advance
to further records is neither explicit in the standard nor consistent in
existing Fortran implementations. We allow child namelist READ
statements to advance, but not other list- directed child input.
This patch refines our interpretation of this case. Child namelist READ
statements continue to be able to advance; in addition, non-namelist
child READ statements can now advance if their parent READ statement is
a list-directed input statement at the top level, or a child that could.
But non-namelist list-directed child input taking place in a context
with explicit format control won't advance to following records, so that
the format-controlled parent READ statement can retain control over
record advancement.
Also corrects two cases of record repositioning in numeric input
editing, which were failing under child input because they weren't
allowing for left tab limits.
Fixes https://github.com/llvm/llvm-project/issues/160351.
|
|
Like on the host allocate 1 byte when zero size is requested.
|
|
Clang on Darwin enables non-POSIX extensions by default.
This causes some macros to leak, such as HUGE from <math.h>, which
causes some conflicts with Flang symbols (but not with Flang-RT, for
now).
It also causes some Flang-RT extensions to be disabled, such as FDATE,
that checks for _POSIX_C_SOURCE. Setting _POSIX_C_SOURCE avoids these
issues. This is already being done in Flang, but it was not ported to
Flang-RT.
This also fixes check-flang-rt on Darwin, as NoArgv.FdateNotSupported
is broken since the flang runtime was moved to flang-rt.
Fixes #82036
|
|
(#159867)
…tion
When scanning list-directed input for nulls and repetition counts, the
current library depends on having each record be prescanned for the
presence of asterisk characters. It turns out that the overhead of
calling memchr(...,'*',...) on each record doesn't pay off, especially
on systems without SIMD-vectorized memchr implementations -- even on
those, it's faster (about 10%) to just scan ahead for asterisks when
decimal digits are encountered. Only when an asterisk is present, which
is not common, should we then bother to convert the digits to their
integer value.
|
|
We compile our monorepo with `/D_MBCS` and flang-rt compilation breaks
as it explicitly uses `wchar_t` (i. e. not TCHAR).
Use STARTUPINFOW / CreateProcessW method explicitly to make the code
work disregarding global settings.
|
|
Summary:
The AMDGPU hack can be removed, and we no longer need to skip 90% of the
`HandleLLVMOptions` if we work around NVPTX earlier. Simplifies the
interface by removing duplicated logic and keeps the GPU targets from
being weirdly divergent on some flags.
|
|
The GNU Fortran library function FNUM(u) returns the UNIX file
descriptor that corresponds to an open Fortran unit number, if any;
otherwise -1.
This implementation is a library extension only, not an intrinsic.
|
|
The RENAME intrinsic did not correctly remove trailing spaces from
filenames. This PR introduces code to remove trailing blanks as
documented by GFortran.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
|
Don't let "hitSlash_" flag in child input propagate back to the parent
input statement's state when the child input was NAMELIST and the
NAMELIST input has properly consumed the terminal '/' character. (It can
get set if NAMELIST item input ran into it.) The current failure to
reset that flag is causing list-directed parent input to stop early.
Fixes https://github.com/llvm/llvm-project/issues/159127.
|
|
Child I/O subroutines are not supposed to use T or TL control edit
descriptors in formats to move the position in the current record to a
point before where it stood at the time of their calls (F'2023
12.6.4.8.3 paragraph 18), but we should also guard against attempts to
do so, using the same means used to prevent such attempts in
non-advancing I/O.
Fixes https://github.com/llvm/llvm-project/issues/158723.
|
|
The runtime supports a near-universal extension to namelist input that
allows reading a sequence of values into a storage sequence beginning at
an array element, e.g. &NML A(2)=1. 2. 3. / .
Disable this extension when the type of the array has a defined
formatted READ subroutine defined. That defined input procedure may
itself not be using list-directed input, and might not notice a
following slash or new input item name as such.
Fixes https://github.com/llvm/llvm-project/issues/158496.
|
|
When compiling headers standalone, we need additional header includes.
|
|
Add support for DSECNDS, the double-precision variant of SECNDS.
The implementation mirrors SECNDS, reusing the shared `SecndsImpl<T>`
runtime template.
Includes:
- Registration in intrinsics table
- Lowering handler and runtime call wiring
- Hook into shared SecndsImpl in extensions.cpp
- Documentation in Intrinsics.md
- Regression test dsecnds.f90
CC @eugeneepshteyn @klausler
---------
Co-authored-by: Eugene Epshteyn <eepshteyn@nvidia.com>
|
|
If the macro was previously defined with `-Wp,-D` then a later `-U` is
*not* going to take effect, the `-Wp` flag takes precedence.
Instead use `-Wp,-U`. This works regardless of whether the original
definition was provided via `-D` or `-Wp,-D`.
Also make sure these flags only get passed to the C++ compiler -- they
are only relevant there, and flang does not support `-Wp`.
|
|
Child list-directed input needs to inherit and return the state used to
process trailing separators (eatComma_) and terminal '/' (hitSlash_)
from any parent list-directed input statement.
Fixes https://github.com/llvm/llvm-project/issues/157509 and
https://github.com/llvm/llvm-project/issues/154971.
|
|
The allocator index is set from the component genre #157731 . There is
no more need of an operation to set it at a later point.
|
|
Allocatable and pointer device components need a different allocator
index to be set in their descriptor when it is establish. This PR adds
two genre for the components `AllocatableDevice` and `PointerDevice` so
the correct allocator index can be set accordingly.
|
|
findloc.cpp is causing memory exhaustion with higher compute
capabilities. Also it is a very expensive file to build. Remove it from
the supported_sources for CUDA build until we can lower its memory
footprint.
|
|
This patch fixes:
flang-rt/lib/runtime/descriptor.cpp:30:19: error: first argument in
call to 'memcpy' is a pointer to non-trivially copyable type
'Fortran::runtime::Descriptor' [-Werror,-Wnontrivial-memcall]
|
|
(#152631)
We have some modifications downstream to compile the flang runtime for
amdgpu using clang OpenMP, some more hacky than others to workaround
(hopefully temporary) compiler issues. The additions here are the
non-hacky alterations.
Main changes:
* Create freestanding versions of memcpy, strlen and memmove, and
replace std:: references with these so that we can default to std:: when
it's available, or our own Flang implementation when it's not. * Wrap
more bits and pieces of the library in declare target wrappers (RT_*
macros). * Fix some warnings that'll pose issues with werror on, in this
case having the namespace infront of variables passed to templates.
Another minor issues that'll likely still pop up depending on the
program you're linking with is that abort will be undefined, it is
perhaps possible to solve it with a freestanding implementation as with
memcpy etc. but we end up with multiple definitions in this case. An
alternative is to create an empty extern "c" version (which can be empty
or forwrd on to the builtin).
Co-author: Dan Palermo Dan.Palermo@amd.com
|
|
This patch enables the lit internal shell by default for testing
flang-rt. The lit internal shell is able to run tests a bit faster as it
avoids having to fork bash for every run line and also produces nicer
debug information on failures.
This is part of #102704.
|
|
FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA (#156078)
When building for the CUDA support sources should be set to the gpu
sources.
|
|
non-void function (#156077)
- Silence warning when using
`FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA`
|
|
further customize the runtime environment. (#155646)
Add the ability to have pre and post call back functions to
ExecutionEnvironment::Configure() to allow further customization of the
flang runtime environment (called from _FortranAStartProgam) in
situations where either the desired features/functionality are
proprietary or are too specific to be accepted by the flang community.
Example:
Custom constructor object linked with flang objects:
```
#include "flang-rt/runtime/environment.h"
#include "flang/Runtime/entry-names.h"
#include "flang/Runtime/extensions.h"
namespace Fortran::runtime {
// Do something specific to the flang runtime environment prior to the
// core logic of ExecutionEnvironment::Configure().
static void
CustomPreConfigureEnv(int argc, const char *argv[], const char *envp[],
const EnvironmentDefaultList *envDefaultList) {
puts(__func__);
}
// Do something specific to the flang runtime environment after running the
// core logic of ExecutionEnvironment::Configure().
static void
CustomPostConfigureEnv(int argc, const char *argv[], const char *envp[],
const EnvironmentDefaultList *envDefaultList) {
puts(__func__);
}
void __attribute__((constructor)) CustomInitCstor(void) {
// Possibilities:
// RTNAME(RegisterConfigureEnv)(&CustomPreConfigureEnv,
// &CustomPostConfigureEnv); RTNAME(RegisterConfigureEnv)(nullptr,
// &CustomPostConfigureEnv);
RTNAME(RegisterConfigureEnv)(&CustomPreConfigureEnv, nullptr);
}
} // namespace Fortran::runtime
```
---------
Co-authored-by: David Parks <dparks@nvidia.com>
|
|
When somebody replaced uses of std::optional<> in the runtime with a new
optional<> defined locally, many needless top-level Fortran:: namespace
qualifiers were added, which are inconsistent with namespace usage in
the runtime. Clean them up.
|
|
Ensure that blank padding takes place when a fixed-length character
allocatable is allocated with a short SOURCE= specifier. While here,
clean up DoFromSourceAssign() so that it uses a temporary descriptor on
the stack rather than allocating one from the heap.
Fixes https://github.com/llvm/llvm-project/issues/155703.
|
|
List-directed input statements maintain two flags ("eatComma_" and
"hitSlash_") in their state that allow GetNextDataEdit() to detect and
handle field separators (usually ',') and slashes in the input stream.
For list-directed input in a defined input subroutine, it's necessary to
copy those flags from the parent list-directed input statement (if any)
and update them afterwards.
Fixes https://github.com/llvm/llvm-project/issues/154791.
|
|
GNU Fortran added support for UNSIGNED ** UNSIGNED power operations; we
should do the same for portability. This actually simplifies semantics a
bit, since I had to go out of my way to exclude Power as a supported
operation for UNSIGNED.
|
|
Fixes #155481
|
|
Since GCC 15.1, libstdc++ enabled assertions/hardening by default in
non-optimized (-O0) builds [1]. That is, _GLIBCXX_ASSERTIONS is defined
in the libstdc++ headers itself so defining/undefining it on the
compiler command line no longer has an effect in non-optimized builds.
As the commit message[2] suggests, define _GLIBCXX_NO_ASSERTIONS
instead.
For libstdc++ headers before 15.1, -U_GLIBCXX_ASSERTIONS still has to be
on the command line as well.
Defining _GLIBCXX_NO_ASSERTIONS was previously proposed in #152223
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112808
[2] https://github.com/gcc-mirror/gcc/commit/361d230fd7800a7e749aba8ed020f54f5c26d504
|
|
Addendum is allocated as part of the descriptor so there is no need for
extra care.
|
|
Reverts llvm/llvm-project#152223
|