7315 Commits

Author SHA1 Message Date
Peter Klausler
a5eb6bdd8e
[flang] Relax overindexing error to warning for last dummy dimension (#71725)
Compilation-time subscript value range checking should emit a warning,
not an error, when the indexed array is a dummy argument; there's
old-school codes out there that should have used assumed-size dummy
arguments but didn't.
2023-11-13 15:59:34 -08:00
Peter Klausler
8b5eacb4a6
[flang][NFC] Document an extension (#71609)
Fortran free form line continuation with '&' works with this compiler
even across the end of an included source file, as it does with most
other Fortran compilers. This extension should be documented.
2023-11-13 15:50:49 -08:00
Peter Klausler
f06ea103e7
[flang] Do definability checking in RANK() clauses (#71607)
I explicitly skipped definability checking for construct entities under
a RANK() clause. I don't know what I was thinking at the time; it's
obviously incorrect! Fix, and add tests.
2023-11-13 15:37:54 -08:00
Peter Klausler
f2bf44b6ec
[flang][preprocessor] Finesse disabling of function-like macros (#71589)
During function-like macro expansion in a standard C/C++ preprocessor,
the macro being expanded is disabled from recursive macro expansion. The
implementation in this compiler's preprocessor, however, was too broad;
the macro expansion needs to be disabled for the "rescanning" phase
only, not for actual argument expansion.

(Also corrects an obsolete comment elsewhere that was noticed during
reduction of an original test case.)
2023-11-13 15:25:10 -08:00
Peter Klausler
36ad3431bb
[flang] Don't accept NULL() actual for assumed-rank dummy (#71574)
A NULL() pointer without MOLD= cannot be allowed to be associated with
an assumed-rank dummy argument, as its rank is not well-defined and
neither the RANK() intrinsic function or the SELECT RANK construct will
work in the callee.
2023-11-13 15:14:05 -08:00
Peter Klausler
13893a08d9
[flang] Compile-time checking of substring bounds (#71453)
When the bounds of a substring reference are known during compilation,
and are outside the valid range for the character base object, issue an
error message.
2023-11-13 15:03:17 -08:00
Peter Klausler
ec4ba0f5fe
[flang][runtime] Correct automatic parenthesized format repetition case (#71436)
In Fortran, a format automatically repeats, with a line break, until all
the data items of a data transfer statement have been consumed. PRINT
"(3I4)", 1, 2, 3, 4, 5, 6 prints two lines, for example, three values
each.

When there are nested parentheses in a format, the rightmost set of
parentheses at the top level are used for automatic repetition. PRINT
"(I4,2(I4))" 1, 2, 3, 4, 5, 6, 7 print three lines, with three values on
the first and two each on the later ones.

Fix a bug in format interpretation that causes the detection of the
"rightmost" set of parentheses to take place on each pass, leading to
problems when parentheses are even further nested.
2023-11-13 14:52:51 -08:00
Peter Klausler
9652e9b741
[flang] Catch non-CONTIGUOUS assumed-rank with ASYNCHRONOUS/VOLATILE … (#71243)
…forwarded to CONTIGUOUS dummy

No object with the ASYNCHRONOUS or VOLATILE attribute can go through the
copy-in/copy-out protocol necessary for argument association with a
contiguous dummy array argument. The check for this constraint missed
the case of an assumed-rank array without an explicit CONTIGUOUS
attribute being forwarded on to a CONTIGUOUS dummy argument.
2023-11-13 14:41:50 -08:00
Peter Klausler
b288b412ed
[flang] Enforce C839 (#71239)
An assumed-rank array may not be a coarray and may not have the VALUE
attribute.
2023-11-13 14:31:20 -08:00
Peter Klausler
3de9aa6b36
[flang] Catch READ(... SIZE=) with NML= or FMT=* (#71235)
The SIZE= specifier may not appear on a list-directed or namelist READ
statement.
2023-11-13 14:20:43 -08:00
Peter Klausler
67f15e76eb
[flang] Fold IS_IOSTAT_END() & IS_IOSTAT_EOR() (#70971)
These intrinsic functions are not particularly valuable -- one can just
compare a value to IOSTAT_END or IOSTAT_EOR directly -- but they are in
the standard and are allowed to appear in constant expressions, so
here's code to fold them.
2023-11-13 14:07:38 -08:00
Peter Klausler
e4589ea2a5
[flang] Correct dummy argument names for C_ASSOCIATED() for C_FUNPTR (#70961)
The dummy argument names used for the interface to C_ASSOCIATED() were
wrong.
2023-11-13 13:53:46 -08:00
Peter Klausler
29fd3e2aa8
[flang] Allow polymorphic actual to implicit interface (#70873)
Semantics is emitting an error when an actual argument to a procedure
that has an implicit interface has a polymorphic type. This is too
general; while TYPE(*) and CLASS(*) unlimited polymorphic items require
the presence of an explicit procedure interface, CLASS(T) data can be
passed over an implicit interface to a procedure expecting a
corresponding dummy argument with TYPE(T), so long as T is not
parameterized.

(Only XLF handles this usage correctly among other Fortran compilers.)

(Making this work in the case of an actual CLASS(T) array may well
require additional changes in lowering to copy data to/from a temporary
buffer to ensure contiguity when the actual type of the array is an
extension of T.)
2023-11-13 13:31:58 -08:00
Yi Wu
de58aa8372
[flang] GETPID runtime and lower intrinsic implementation (#70442)
Runtime function GetPID calls the function getpid
from unistd.h or process.h base on the OS.
2023-11-13 10:31:36 +00:00
Tom Eccles
a207e6307a
[flang] add fveclib flag (#71734)
-fveclib= allows users to choose a vectorized libm so that loops
containing math functions are vectorized.

This is implemented as much as possible in the same way as in clang. The
driver test in veclib.f90 is copied from the clang test.
2023-11-13 10:04:50 +00:00
jeanPerier
f35f863a88
[flang][NFC] Use hlfir=false and flang-deprecated-no-hlfir in legacy tests (#71957)
Patch 2/3 of the transition step 1 described in

https://discourse.llvm.org/t/rfc-enabling-the-hlfir-lowering-by-default/72778/7.

All the modified tests are still here since coverage for the direct
lowering to FIR was still needed while it was default. Some already have
an HLFIR version, some have not and will need to be ported in step 2
described in the RFC.

Note that another 147 lit tests use -emit-fir/-emit-llvm outputs but do
not need a flag since the HLFIR/no HLFIR output is the same for what is
being tested.
2023-11-13 09:14:05 +01:00
David Truby
cf1e3420b0
[flang][windows] Add option to link against specific MSVC CRT (#70833)
Currently flang's runtime libraries are only built for the specific CRT
that LLVM itself was built against. This patch adds the cmake logic for
building a separate runtime for each CRT configuration and adds a flag
for selecting a CRT configuration to link against.
2023-11-10 16:13:49 +00:00
NimishMishra
c4d7321615
[flang][OpenMP] Skip default privatization for crashing cases (#71922)
This patch skips default privatization for crashing cases like
namelists, reduction instrinsics, and structure constructor.

Fixes: https://github.com/llvm/llvm-project/issues/67332,
https://github.com/llvm/llvm-project/issues/66454, and
https://github.com/llvm/llvm-project/issues/65569

Co-Authored-By: kiranchandramohan <kiran.chandramohan@arm.com>
2023-11-10 05:24:21 -08:00
jeanPerier
9f265c3871
[flang][driver] add -flang-deprecated-no-hlfir hidden option (#71820)
Patch 1/3 of the transition to use the HLFIR step by default in lowering
as described in
https://discourse.llvm.org/t/rfc-enabling-the-hlfir-lowering-by-default/72778/7

This option will allow to lower code without the HLFIR step during a
grace period as described in the RFC. It is not meant to be a long term
switch for flang.
2023-11-10 11:54:10 +01:00
NimishMishra
91f92e6a6b
[flang][OpenMP] Fix common block missing symbol crash (#67330)
Fixes #65034 by skipping copy of host-association information if the
concerned symbol is missing from the inner construct
2023-11-10 00:17:47 -08:00
Valentin Clement (バレンタイン クレメン)
90da688bac
[flang][openacc] Avoid creation of duplicate global ctor (#71846)
PR #70698 relax the duplication rule in acc declare clauses. This lead
to potential duplicate creation of the global constructor/destructor.
This patch make sure to not generate a duplicate ctor/dtor.
2023-11-09 12:57:30 -08:00
Kiran Chandramohan
848ae10cd2
[Flang][OpenMP] Finalize Statement context of clauses before op creation (#71679)
Currently Statement context used during processing of clauses is
finalized after the OpenMP operation creation. This causes the
finalization to go inside the OpenMP region and this can lead to
multiple finalizations in a parallel region. This fix proposes to
finalize them before the OpenMP op creation.

Fixes #71342
2023-11-09 14:22:20 +00:00
Kiran Chandramohan
cace7159ca
[Flang][OpenMP] Process reduction only once for parallel do (#70844) 2023-11-09 14:11:46 +00:00
Anthony Cabrera
8803211a32
[flang][hlfir] patch for assumed shape dummy with VALUE keyword when lowering to HLFIR (#70391)
Adds functionality for assumed shape dummy with value keyword when
lowering to HLFIR
2023-11-08 16:21:51 -06:00
Fabian Mora
fd389f46de
[flang] Change uniqueCGIdent separator from . to X (#71338)
Change the separator in the `uniqueCGIdent` method to `X`. This change
is required to enable OpenMP offloading for the NVPTX target, as dots
are not valid identifiers in PTX and `uniqueCGIdent` is used to mangle
some literals. Follow up patches will change the remainder of `.`
appearances in names to `X` and add support for the NVPTX target.
2023-11-08 15:04:00 -05:00
Krzysztof Parzyszek
9cdaeefc45 [flang] Fix typo in ExpressionAnalyzer::CheckIntrinsicKind, NFC 2023-11-08 08:31:58 -06:00
Mitch Phillips
a141a9fa97 Revert "[OpenMP] atomic compare fail : Parser & AST support"
This reverts commit 086b65340cca2648a2a91a0a47d28c7d9bafd1e5.

Reason: Broke under -Werror. More details in
https://reviews.llvm.org/D123235
2023-11-08 11:20:17 +01:00
Sunil Kuravinakop
086b65340c [OpenMP] atomic compare fail : Parser & AST support
This is a support for " #pragma omp atomic compare fail ". It has Parser & AST support for now.

Reviewed By: tianshilei1992, ABataev

Differential Revision: https://reviews.llvm.org/D123235
2023-11-07 16:57:50 -06:00
Valentin Clement (バレンタイン クレメン)
c3629923aa
[flang][openacc] Allow constant variable in data clause (#71580)
The check introduced in #71444 was to restrictive and this patch relax
it so data clause can accept constant.
2023-11-07 14:28:30 -08:00
Kiran Chandramohan
d0ef94bc83 Revert "Revert "[Flang][OpenMP] Fix to support privatisation of alloc strings (#71204)""
This reverts commit ba116ff41d525a4b6c931664f1b4437a7dd55b1d.

This relands https://github.com/llvm/llvm-project/pull/71204 with a fix
in the test.
2023-11-07 12:25:24 +00:00
Kiran Chandramohan
ba116ff41d Revert "[Flang][OpenMP] Fix to support privatisation of alloc strings (#71204)"
This reverts commit 192bee0db1dfb8b2f570031102a2326037b75fa1.
Reverting to fix the CI.  https://lab.llvm.org/buildbot/#/builders/21/builds/84995
2023-11-07 11:50:24 +00:00
Kiran Chandramohan
192bee0db1
[Flang][OpenMP] Fix to support privatisation of alloc strings (#71204) 2023-11-07 11:40:25 +00:00
jeanPerier
0b3d54973c
[flang][hlfir] Lower parent component in constant structure constructors (#71421)
Simply remove TODO. Since parent components are now fields of the
extended types fir.type<> in HLFIR, there is nothing specific to do to
deal with the appearance of a parent component value in a structure
constructor value that must be turned into a fir.global initial value:
it can simply be inserted as a normal field value.
2023-11-07 09:21:09 +01:00
Shraiysh
6846258aa6
[flang][OpenMP] Add semantic check for declare target (#71425)
This patch adds a semantic check for the following:

```
If a list item is a procedure name, it must not be a generic name,
procedure pointer, entry name, or statement function name.
```
2023-11-06 20:42:05 -06:00
Valentin Clement (バレンタイン クレメン)
ba2f40a775
[flang][openacc] Allow acc routine before implicit part (#71460)
Allow position of the acc routine in the implicit part.
2023-11-06 17:49:04 -08:00
Valentin Clement (バレンタイン クレメン)
edfaae8726
[flang][openacc] Correctly lower acc routine in interface block (#71451)
When the acc routine directive was in an interface block in a
subroutine, the routine information was attached to the wrong
subroutine. This patch fixes this be retrieving the subroutine name in
the interface.
2023-11-06 17:48:45 -08:00
Valentin Clement (バレンタイン クレメン)
3c356eef31
[flang][openacc] Support variable from equivalence in data clauses (#71434)
The value for a var in an equivalence is represented by a `fir.ptr`.
Support this type in the recipe creation.
2023-11-06 15:49:40 -08:00
Shraiysh
ee1000573e
[flang][OpenMP] Add semantic check for target update (#71305)
This patch adds the following semantic check for target update
construct.

```
A list item can only appear in a to or from clause, but not in both.
```
2023-11-06 17:16:14 -06:00
Valentin Clement (バレンタイン クレメン)
6be6081610
[flang][openacc] Issue an error when TBP are used in data clause (#71444)
Putting a type-bound procedure in a data clause was crashing the
lowering. Issue a proper semantic error in this case.
2023-11-06 14:52:41 -08:00
Slava Zakharin
ecb1fbaa13
[flang][openacc] Generate data bounds for array addressing. (#71254)
In cases like `copy(array(N))` it is still useful to represent
the data operand uniformly with `copy(array(N:N))`.
This change generates data bounds even if it is not an array
section with the triplets. The lower and the upper bounds
are the same and the extent is one in this case.
2023-11-06 14:45:46 -08:00
Valentin Clement
ad584a27f2
[flang][openacc][NFC] Remove unused variable 2023-11-06 14:43:36 -08:00
Valentin Clement (バレンタイン クレメン)
fdf3823c0e
[flang][openacc] Support variable in equivalence in declare directive (#71242)
A variable in equivalence share the storage units with one or more
objects. When lowered to FIR, the global created for the equivalence has
the name of one of the object. The variable also has an offset in the
storage unit.
This patch takes all of this into account for variable part of
equivalence used in a declare directive.
2023-11-06 14:36:24 -08:00
kkwli
cc05b47f55
[flang] Add more scenarios for Cray pointer in HLFIR (NFC) (#69839)
Add the scenarios of loading Cray pointees.
2023-11-06 15:10:25 -05:00
Shraiysh
d6b69a1bb9
[flang][OpenMP] Add semantic checks for is_device_ptr (#71255)
This patch adds the following semantic check for is_device_ptr

```
A list item that appears in an is_device_ptr clause must be a
dummy argument that does not have the ALLOCATABLE, POINTER or
VALUE attribute.
```
2023-11-06 12:07:31 -06:00
Akash Banerjee
8b3c071b6f [Flang][OpenMP] Small fix to handle CharBoxValue types for implicit target maps
Original commit: fbaf2c6cf7b207145dbda0d1cbadd0b446a21199
Original PR: #67164
2023-11-06 16:50:09 +00:00
Kiran Chandramohan
742d8eb96d
[Flang][OpenMP] Dont add PreDetermined Flag if symbol is privatized already (#70931)
If the symbol is already privatized due to a user specification then it
is not required to mark it as PreDetermined. This happens if there is a
sequential loop in a parallel region that has the private specification
for the index of the sequential loop.

Fixes #63143
2023-11-06 16:07:22 +00:00
kkwli
5fc69134a1
[flang] Match argument types for std::min (#71102)
PR #68342 causes build breakage on MacOS due to uint64_t being defined
as unsigned long long instead of unsigned long. It leads to type
mismatch in the arguments for std::min.
2023-11-06 11:02:19 -05:00
Kiran Chandramohan
12756831e4
[Flang][OpenMP] Mark mergeable and untied clauses as unsupported (#71209)
These two clauses are not supported in the OpenMP Dialect to LLVM
conversion. Mark as TODO till support is added.
2023-11-06 15:01:57 +00:00
Akash Banerjee
63752399f8 [OpenMP][MLIR]OMPEarlyOutliningPass removal
This patch removes the OMPEarlyOutliningPass as it is no longer required. The implicit map operand capture has now been moved to the PFT lowering stage.

Depends on #67318.
2023-11-06 13:24:02 +00:00
Akash Banerjee
fbaf2c6cf7 [OpenMP][Flang] Add "IsolatedFromAbove" trait to omp.target
This patch adds the PFT lowering changes required for adding the IsolatedFromAbove trait to omp.target.

Key Changes:
	- Add IsolatedFromAbove trait to target op in MLIR.
	- Main reason for this change is to prevent CSE and other similar optimisations from crossing region boundaries for target operations. The link below has the discourse discussion surrounding this issue.
	- Move implicit operand capturing to the PFT lowering stage.
	- Implicit operands are first added as implicitly captured map_operands with their map_types set accordingly to indicate this. Later, all map_operands including implicit ones are added as block arguments.
	- Remove `implicit` attribute from the `MapInfoOp`. This information is already captured by the `map_type`.
	- The custom printer and parser for the map_types have been updated to show the `implicit` and `literal` map_types.
	- Update related tests.
	- This fixes #63555.
	- This fixes #70488.
2023-11-06 13:24:02 +00:00