8384 Commits

Author SHA1 Message Date
Michael Kruse
76e7c8f4aa
[flang] Revise IDE folder structure (#89745)
Update the folder titles for targets in the monorepository that have not
seen taken care of for some time. These are the folders that targets are
organized in Visual Studio and XCode (`set_property(TARGET <target>
PROPERTY FOLDER "<title>")`) when using the respective CMake's IDE
generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically
deduce the folder. This reduces the number of
`set_property`/`set_target_property`, but are still necessary when
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's
root CMakeLists.txt.
2024-05-25 17:24:58 +02:00
Stephan T. Lavavej
25f4ead966
[flang] [lldb] [llvm] Fix 'destory' comment typos [NFC] (#93260) 2024-05-24 23:57:12 -07:00
Peter Klausler
82bd7adb97
[flang] Fix bug introduced by PR#93106 (#93326)
https://github.com/llvm/llvm-project/pull/93106 introduced some
necessary fixes to module file generation, but has also caused a
regression. The module file output can include bogus attempts to
USE-associate symbols local to derived type scopes, like components and
bindings. Fix, and extend a test.
2024-05-24 14:26:54 -07:00
Kiran Chandramohan
57be0d2c86
[Flang][OpenMP] Remove the orphan section test (#93343)
Remove this test since it is marked as XFAIL and has some
non-deterministic behaviour which causes it to spuriously pass on
out-of-tree builds.

Capturing this in https://github.com/llvm/llvm-project/issues/93342 to
make a proper fix and a test later.
2024-05-24 21:21:01 +01:00
Slava Zakharin
1126657af5
[flang][runtime] Enable REAL printing in F18 offload runtime. (#87851) 2024-05-24 12:14:28 -07:00
Peter Klausler
b8b90c2a20
[flang] Silence bogus error about NULL() actual for assumed-rank dummy (#93225)
A NULL(without MOLD=) actual argument can be associated with an OPTIONAL
assumed-rank non-allocatable non-pointer dummy argument; it simply
signifies that the corresponding actual argument is absent, and thus
none of its dynamic attributes, including rank, are meaningful.
2024-05-24 09:24:25 -07:00
Kiran Chandramohan
879b7268b8
[Flang][OpenMP] Reenable and fix final few tests 6/6 (#93295)
Add do02.f90 and taskloop03.f90 that were removed in
https://github.com/llvm/llvm-project/pull/92739
Replace shell script tests with python.
2024-05-24 14:31:09 +01:00
Abid Qadeer
5434b04234
[flang][debug] Add support for fixed size arrays. (#92568)
This PR adds the type conversion support for fixed size arrays. Mostly
mechanical changes converting dimension values to subrange fields. A
limitation is that lower bound is always one for the moment as that
information is missing in `SequenceType`.

With this change in place, I can evaluate fixed size arrays in debugger.
```

(gdb) p x
$1 = ((2, 3, 4, 5) (3, 4, 5, 6) (4, 5, 6, 7) (5, 6, 7, 8) (6, 7, 8, 9))
(gdb) ptype x
type = integer (4,5)
```

---------

Co-authored-by: Tom Eccles <t@freedommail.info>
2024-05-24 12:55:54 +01:00
Kiran Chandramohan
5287bb97f9
[Flang][OpenMP] Re-enable more OpenMP tests 5/n (#93246)
Enables a few sections, simd, taskloop, use_device tests.
2024-05-24 06:41:55 +01:00
Peter Klausler
dc78329dbb
[flang] Extension: associating polymorphic pointer/allocatable actual… (#93211)
… with monomorphic dummy

The relevant standard requires (F'2023 15.5.2.6 p2) that when a pointer
or allocatable actual argument is associated with an
identically-attributed dummy argument, either both are polymorphic or
neither is. We already relax this requirement in the case of an
INTENT(IN) dummy argument, since a change of type cannot occur. Further,
like other compilers do, we can also relax this requirement in the case
of a limited polymorphic actual argument being associated with a
monomorphic dummy, as our implementation always passes a reference to
the actual descriptor, where any change of type that occurs during the
call due to reallocation will be properly recorded.
2024-05-23 16:45:04 -07:00
Peter Klausler
e2a3880d7f
[flang] Revert two new interoperability semantic checks (#93112)
Two checks related to BIND(C) vs non-BIND(C) entry points with the same
dummy argument added by https://github.com/llvm/llvm-project/pull/92474
have turned out to be unnecessary. Revert them and adjust the tests.
2024-05-23 16:36:18 -07:00
Peter Klausler
79c2a1e4ef
[flang][runtime] Correct SELECTED_LOGICAL_KIND() (#93108)
The implementation of the runtime version of this intrinsic function in
https://github.com/llvm/llvm-project/pull/89691 was incorrect. Fix it to
interpret its argument as a bit count.
2024-05-23 16:31:17 -07:00
Peter Klausler
9ce8e63ceb
[flang] Better renaming in module files (#93106)
When a symbol from one module is used in another without an explicit USE
association, the module file output code may need to use another name
for it -- either with a name that is already available via USE
association with renaming, or by means of a new private USE association,
possibly with renaming to avoid a clash.

Module file output was dealing properly with names of derived types, but
wasn't accounting for symbols that appear in expressions other than
initializations. This was specifically a problem with an application
module that had a call to a NOPASS type-bound procedure in an array
bound specification expression, which semantics had resolved to the name
of a private module function.

This patch implements renaming, when necessary, for all symbols
appearing in expressions and type names, and replaces the previous
implementation of derived type renaming. It also gets a little smarter
about avoiding the creation of compiler-generated names when a name from
another module has been brought into scope already by means of USE
association with renaming.
2024-05-23 16:20:51 -07:00
Peter Klausler
47b485c052
[flang] Fix type of array constructor triplet (extension) (#92970)
The type of "[lo:hi:str]" is being forced to INTEGER(8), ignoring the
types of the operands to the triplet. The type of a triplet should be
whatever the type of "lo+hi+str" would be.

(Array constructor triplets are a syntactic sugar extension for an
implied DO loop.)
2024-05-23 16:09:45 -07:00
Peter Klausler
8ccb56cf35
[flang] Fix bad shape analysis of assumed-rank dummy (#92936)
Shape analysis for the results of SHAPE, LBOUND, and UBOUND (without
DIM=) needs to account for an assumed-rank dummy argument, and return a
shape vector with a single unknown element.
2024-05-23 15:56:08 -07:00
Peter Klausler
c24f881340
[flang] Silence warnings from module files after recent change (#92834)
I modified declaration checking for interoperable objects to buffer its
generated messages as I had previously done for derived types and
procedure interfaces, but failed to modify all of the message creation
statements to use the new buffer, so some are now escaping when a module
file is being compiled. Fix to ensure that the new buffer is always
used.
2024-05-23 15:45:19 -07:00
Peter Klausler
975579bd94
[flang] Fix variable unformatted I/O bug with output after input (#92828)
When reading variable-length unformatted records, the external I/O
library frames the input buffer so that the footer of the previous
record remains in frame. This is done so that a BACKSPACE doesn't have
to do an extra read to get the length of the previous record before
repositioning over it.

When switching from input to output to overwrite or append new records
after reading any, it is necessary to undo this framing of the last word
in the previous record, since the new output isn't going to define it in
the buffer and it'll be overwritten in the filesystem with garbage.
2024-05-23 15:32:14 -07:00
Peter Klausler
6d2b23c46e
[flang] Fix crash in error recovery (bad binding) (#92800)
A type-bound procedure that's bound to a name that isn't a procedure is
caught as an error, but can also lead to a crash in compatibility
checking later. Make that code more robust to failure.

Fixes https://github.com/llvm/llvm-project/issues/92678.
2024-05-23 15:14:18 -07:00
Kiran Chandramohan
87452bcb80
[Flang][OpenMP] Reenable a few tests 4/n (#93214)
Re-enable a few simd, critical, workshare tests.
2024-05-23 22:04:00 +01:00
Peter Klausler
c9f94baca5
[flang] Fix crash in error recovery (implicit host association) (#92795)
When a symbol appears in a specification expression in a subprogram
contained in a host program unit, semantics may have to create a symbol
in the host and use host association to it. This shouldn't happen for
nested subprograms that can't import such a symbol, such as interface
blocks by default. Further, when host association fails, semantics
shouldn't crash.

Fixes https://github.com/llvm/llvm-project/issues/92647.
2024-05-23 13:41:08 -07:00
Peter Klausler
70d1844abe
[flang] Fix crash in error recovery (#92786)
EQUIVALENCE set processing assumes that any arrays have explicit shape
and constant lower bounds. When an erroneous program violates those
assumptions, the compiler crashes. Fix.

Fixes https://github.com/llvm/llvm-project/issues/92636.
2024-05-23 13:31:25 -07:00
Slava Zakharin
208544fc70
[flang][runtime] Added noinline for some functions in device build. (#93128)
This helps reducing the compilation time spent by the device
compiler optimizer and then the code generator. Since F18 RT
is going to be distributed as LLVM BC for some targets
(same way as LLVM liboffload device library is distributed)
and linked to the user offload code, the compilation time
of the produced LLVM BC will be critical.
2024-05-23 13:15:53 -07:00
Aaron Ballman
b49ce9c304
Fix more diagnostic wording for style; NFC (#93190)
This tries to fix all of the places where a diagnostic message starts
with a capital letter (other than acroynyms or proper nouns) or ends
with punctuation (other than a question mark).

This is in support of a planned change to tablegen to start diagnosing
incorrect diagnostic message styles.
2024-05-23 14:50:29 -04:00
Abid Qadeer
63a4133912
[flang][debug] Support complex types. (#92559)
This PR adds supports for conversion of complex type to corresponding
DITypeAttr. Both fir and mlir types are supported.

Apart from lit testing, I have also tested the types in debugger and
they work correctly. An exception is 128 bit complex which somehow
requires that its name be different from `complex`. I am going to open a
separate PR to add (kind=n) in the type names similar to what gfortran
does.
2024-05-23 13:23:48 +01:00
Tom Eccles
44086133c5
[flang][HLFIR][NFC] Reduce intrinsic lowering pass boilerplate (#93062)
The pass constructor can be generated automatically.

This pass is module-level and then runs on all relevant intrinsic
operations inside of the module, no matter what top level operation they
are inside of.
2024-05-23 10:28:06 +01:00
Anchu Rajendran S
1a2a0c0dc9
Fixing the location attribute added to mapInfoOp (#90764)
Named location attribute added to `tgt_offload_entry` shall be used by
runtime calls like `ompx_dump_mapping_tables` to print the information
of variables that are mapped to the device. `ompx_dump_mapping_tables`
was printing the wrong location information and this change fixes it.

A sample execution of example before the change:
```
omptarget device 0 info: OpenMP Host-Device pointer mappings after block at libomptarget:0:0:

omptarget device 0 info: Host Ptr           Target Ptr         Size (B) DynRefCount HoldRefCount Declaration

omptarget device 0 info: 0x0000000000206df0 0x00007f02cdc00000 20000000 1           0            <program-file-loc> at unknown:18:35
```

The change replaces unknown to the mapped symbol and location to the
declaration location.
2024-05-23 13:46:35 +05:30
Valentin Clement (バレンタイン クレメン)
66db7c609c
[flang] Lower selected_char_kind to runtime call (#93095)
Runtime support has been added in
https://github.com/llvm/llvm-project/pull/89691. This patch adds
lowering in a similar way than `selected_int_kind`, `selected_real_kind`
and `selected_logical_kind` added in #93091.

Some gfortran tests can be enabled after this patch is landed.

- `Fortran/gfortran/regression/selected_char_kind_1.f90`
- `Fortran/gfortran/regression/selected_char_kind_4.f90`
2024-05-22 14:54:21 -07:00
Valentin Clement (バレンタイン クレメン)
bdbf927a83
[flang] Lower selected_logical_kind to its runtime call (#93091)
Runtime support has been added in #89691. This patch adds lowering in a
similar way than `selected_int_kind` and `selected_real_kind`.
2024-05-22 14:42:51 -07:00
Kiran Chandramohan
0ee6646d6f
[Flang][OpenMP] Re-enable tests on windows 3/n (#93070)
Enables copying, copyprivate, critical, and a few other tests
2024-05-22 22:16:40 +01:00
dpalermo
47ed2bfa71
[flang] cmake fix for FLANG_RUNTIME_F128_MATH_LIB build (#93054)
Remove an extra '-D' in the call to add_compile_definitions. The extra
-D causes -D-DFLANG_RUNTIME_F128_MATH_LIB=libquadmath to appear in
compile options which results in a compilation failure. This occurs only
on systems using cmake versions 3.22.1 or 3.24.3. Using cmake 3.28.1
seems to automatically remove the duplicate -D.

Fixes https://github.com/llvm/llvm-project/pull/81971
2024-05-22 14:00:29 -05:00
Kiran Chandramohan
9f0e59f3c1
[Flang][OpenMP] Re-enable tests on windows 2/n (#93013)
Re-enables the single, symbol and threadprivate tests
2024-05-22 18:02:41 +01:00
Krzysztof Parzyszek
101f977f2c
[flang][CodeGen] Avoid out-of-bounds memory access in SelectCaseOp (#92955)
`SelectCaseOp::getCompareOperands` may return an empty range for the
"default" case. Do not dereference the range until it is expected to be
non-empty.

This was detected by address-sanitizer.
2024-05-22 10:52:17 -05:00
Tom Eccles
eeb9fcddf5
[flang][HLFIR][NFC] Use tablegen to reduce assignment pass boilerplate (#93030)
This pass is module-level and then runs on all operations implementing
the ordered assignment interface. It should not matter which top-level
operation the assignment is inside of.

This commit removes some unnecessary boilerplate that we can generate
automatically with tablegen.
2024-05-22 16:48:50 +01:00
Tom Eccles
b99b6b78f0
[flang][Driver][test] add missing run lines to fopenmp test (#92784)
I believe these were forgotten when copying the clang in #86816.

This was flagged because the CHECK lines for CHECK-LD-ANY* had no
associated RUN line. See
https://github.com/llvm/llvm-project/pull/92387#issuecomment-2119170354
2024-05-22 14:29:30 +01:00
Krzysztof Parzyszek
2aa218c247
[flang][OpenMP] Diagnose invalid reduction modifiers (#92406)
Emit diagnostic messages for invalid modifiers in "reduction" clause.

Fixes https://github.com/llvm/llvm-project/issues/92397
2024-05-22 07:23:14 -05:00
Tom Eccles
9807f25baa
[flang][HLFIR] Adapt OptimizedBufferization to run on all top level ops (#92898)
This means that this pass will also run on hlfir elemental operations
which are not inside of functions.

See RFC:

https://discourse.llvm.org/t/rfc-add-an-interface-for-top-level-container-operations

Some of the changes are from moving the declaration and definition of
the constructor into tablegen (as requested during code review of
another pass).
2024-05-22 11:32:40 +01:00
Abid Qadeer
f156b9ce7a
[flang] Add debug information for module variables. (#91582)
This PR add debug info for module variables. The module variables are
added as global variables but their scope is set to module instead of
compile unit. The scope of function declared inside a module is also set
accordingly.

After this patch, a module variable could be evaluated in the GDB as `p
helper::gli` where helper is name of the module and gli is the name of
the variable. A future patch will add the import module functionality
which will remove the need to prefix the name with helper::.

The line number where is module is declared is a best guess at the
moment as this information is not part of the GlobalOp.
2024-05-22 10:59:29 +01:00
Kiran Chandramohan
15710bbdad
[Flang][OpenMP] Re-enable tests on windows 1/n (#92904)
Re-enable tests starting with a or b.
2024-05-22 10:21:46 +01:00
Valentin Clement (バレンタイン クレメン)
0bc710f7c1
[flang][cuda] Accept constant as src for cuf.data_tranfer (#92951)
Assignment of a constant (host) to a device variable is a special case
that can be further lowered to `cudaMemset` or similar functions. This
patch update the lowering to avoid the creation of a temporary when we
assign a constant to a device variable.
2024-05-21 12:42:30 -07:00
Valentin Clement
7847b1ca00
[flang][cuda][NFC] Silence warning triggered in buildbot 2024-05-21 11:35:51 -07:00
Valentin Clement (バレンタイン クレメン)
1fc3ce1cdb
[flang][cuda] Enable data transfer for descriptors (#92804)
Remove the TODO when data transfer is done with descriptor variables.
2024-05-21 11:23:55 -07:00
Valentin Clement (バレンタイン クレメン)
0eca265584
[flang][cuda] Fix memory side effects on cuf.data_transfer op (#92928)
The memory side effects on the `cuf.data_transfer` operation were
swapped between the src and dst operands. We read from source and write
to destination not the opposite.
2024-05-21 09:59:35 -07:00
Krzysztof Parzyszek
c1b5b7c19b
[flang][Lower] Emit exiting branches from within constructs (#92455)
When lowering IfConstruct, CaseConstruct, and SelectTypeConstruct, emit
branches that exit the construct in each block that is still
unterminated after the FIR has been generated in it.

The same thing may be needed for SelectRankConstruct, once it's
supported.

This eliminates the need for inserting branches in `genFIR(Evaluation)`.

Follow-up to PR https://github.com/llvm/llvm-project/pull/91614.
2024-05-21 08:19:54 -05:00
Tom Eccles
6ff82363df
[flang][HLFIR] Adapt InlineElementals to run on all top level ops (#92734)
This means that this pass will also run on hlfir elemental operations
which are not inside of functions.

See RFC:

https://discourse.llvm.org/t/rfc-add-an-interface-for-top-level-container-operations

Some of the changes are from moving the declaration and definition of
the constructor into tablegen (as requested during code review of
another pass).

While I was updating the tests I noticed that the optimized
bufferization pass and some cse were missing from the optimized pipeline
in flang/test/Driver/mlir-pass-pipeline.f90. I fixed this in this
commit.
2024-05-21 12:09:25 +01:00
Kiran Chandramohan
7cee61c82f
[Flang][OpenMP] Fix lastprivate store issue (#92777)
Fix an issue where the lastprivate variable type is different from the
type used for the index of the loop.

Fixes #79780
2024-05-21 10:48:52 +01:00
Kiran Chandramohan
502bea25bd
[Flang][OpenMP] Re-enable tests without runtime issues on Windows (#92824) 2024-05-21 10:20:59 +01:00
Anchu Rajendran S
6658e1a3fd
Adding parsing and semantic check support for omp masked (#91432)
omp masked directive in OpenMP 5.2 allows to specify code regions which
are expected to be executed by thread ids specified by the programmer.
Filter clause of the directive allows to specify the thread id. This
change adds the parsing support for the directive
2024-05-20 21:32:41 -07:00
Muhammad Omair Javaid
85e1124049 Revert "[flang][OpenMP] Try to unify induction var privatization for OMP regions. (#91116)"
This reverts commit 2a97b507dc643b7ee3bc651b3f21b754cfba433c.

It has broken LLVM testsuite on various bots
https://lab.llvm.org/buildbot/#/builders/184/builds/12760
https://lab.llvm.org/buildbot/#/builders/197/builds/14376
https://lab.llvm.org/buildbot/#/builders/179/builds/10176
2024-05-21 06:51:30 +05:00
Slava Zakharin
bccac125e1
[flang][runtime] Added io-api-minimal.cpp to the offload build. (#92807) 2024-05-20 16:16:26 -07:00
Slava Zakharin
9354045566
[NFC][flang][runtime] Avoid recursion in EditCharacterOutput and EditLogicalOutput. (#92806) 2024-05-20 16:16:07 -07:00