346 Commits

Author SHA1 Message Date
Carlos Seo
98b2bc5b08 [Flang][Docs] Update information about AArch64 trampolines (#100391)
Commits c4b66bf and 7647174 add support for AArch64 trampolines. Updated
documentation to reflect the changes.

(cherry picked from commit c6e69b041a7e6d18463f6cf684b10fd46a62c496)
2024-07-26 09:26:46 +02:00
Peter Klausler
40ed6ba016
[flang][NFC] Document an intentional violation of the standard (#99073)
The Fortran standard committees passed an "interp" request at their June
2024 meetings that is distinct from nearly every other Fortran compiler
that I tried (6) in an an ambiguous case (parent component naming when
the base type has been renamed via USE association). Document this case
in flang/docs/Extensions.md as an intentional instance of
non-conformance chosen for portability and better usability.
2024-07-18 15:59:24 -07:00
Tom Eccles
60ec6868ea
[flang] Implement SECOND intrinsic (#98881)
The SECOND intrinsic is a gnu extension providing an alias for CPU_TIME:
https://gcc.gnu.org/onlinedocs/gfortran/SECOND.html

This cannot be implemented as a straightforward alias because there is
both a function and a subroutine form.
2024-07-16 11:29:36 +01:00
Michael Klemm
a5a29a26aa
[Flang] Implement RENAME intrinsic (code-gen + runtime entry point) (#98359)
This PR implements the RENAME intrinsic, which is a GFortran extension
(see
https://gcc.gnu.org/onlinedocs/gfortran/intrinsic-procedures/rename.html).
2024-07-15 08:39:19 +02:00
David Truby
1afd4b7d1e
[flang] Allow getenv as alternate spelling for get_environment_variable (#95777)
This patch adds getenv as an alternate spelling for
get_environment_variable.
This spelling is allowed by multiple other compilers and is used in
OpenRadioss.
2024-07-10 13:18:02 +01:00
Tarun Prabhu
390f9b11d1
[flang][docs] Remove passwords for bi-weekly flang calls from documen… (#98161)
…tation

The passwords are moved to the Google Doc containing the agenda and
minutes for the calls. A note has been added mentioning where to find
the meeting ID's and passwords.

Fixes #96121
2024-07-09 10:10:42 -06:00
Yi Wu
dfd2711f8f
Revert "Revert "[flang] Fix execute_command_line cmdstat is not set when error occurs" (#96365)" (#96774)
The fix broke llvm-test-suite, so it was reverted previously. With test
fixes added in https://github.com/llvm/llvm-test-suite/pull/137, it
should now pass the tests

This reverts commit 435635652fd226fa292abcff6a10d3df9dbd74e3.
2024-06-27 10:53:56 +01:00
Kiran Chandramohan
435635652f
Revert "[flang] Fix execute_command_line cmdstat is not set when error occurs" (#96365)
Reverts llvm/llvm-project#93023

Reverting due to buildbot failure.
https://lab.llvm.org/buildbot/#/builders/41/builds/227
test-suite ::
Fortran/gfortran/regression/gfortran-regression-execute-regression__execute_command_line_3_f90
2024-06-21 23:47:13 +01:00
Yi Wu
4232dd586b
[flang] Fix execute_command_line cmdstat is not set when error occurs (#93023)
Fixes: https://github.com/llvm/llvm-project/issues/92929
Also added cmdstat for common linux return code 1, 126, 127
2024-06-21 14:42:07 +01:00
David Truby
c6b6e18c4d
[flang] Implement !DIR$ VECTOR ALWAYS (#93830)
This patch implements support for the VECTOR ALWAYS directive, which
forces
vectorization to occurr when possible regardless of a decision by the
cost
model. This is done by adding an attribute to the branch into the loop
in LLVM
to indicate that the loop should always be vectorized.

This patch only implements this directive on plan structured do loops 
without labels. Support for unstructured loops and array
expressions is planned for future patches.
2024-06-14 14:10:41 +01:00
Peter Klausler
f3c227b797
[flang] Support BIND(C, NAME="...", CDEFINED) extension (#94402)
This CDEFINED keyword extension to a language-binding-spec signifies
that static storage for an interoperable variable will be allocated
outside of Fortran, probably by a C/C++ external object definition.
2024-06-11 16:56:30 -07:00
jiajie zhang
68413219db
[flang] Add GETCWD runtime and lowering intrinsics implementation (#92746)
This patch add support of intrinsics GNU extension GETCWD
https://github.com/llvm/llvm-project/issues/84203. Some usage info and
example has been added to `flang/docs/Intrinsics.md`. The patch contains
both the lowering and the runtime code and works on both Windows and
Linux.


|   System   |   Implmentation  |
|-----------|--------------------|
| Windows | _getcwd               |
| Linux       |getcwd                  |
2024-06-06 12:28:02 +08:00
Peter Klausler
caa0a2695e
[flang] Add warnings about undefinable actuals for ASYNCHRONOUS/VOLAT… (#93851)
…ILE dummies

There's language in the standard (F'2023 15.5.2.5 p21) disallowing an
actual argument with a vector subscript from associating with a dummy
argument with either the ASYNCHRONOUS or VOLATILE attributes. This is a
bug in the standard, as (1) these attributes are actually relevant only
over the scope of the called procedure, (2) they can be applied in
nested scopes (internal subprograms and BLOCK) within the called
procedure, and (3) can be implicit within the called procedure and its
nested scopes in the case of ASYNCHRONOUS as a side effect of using a
dummy argument in an asynchronous data transfer statement. So issue a
warning. This new warning about undefinable actual arguments being
associated with ASYNCHRONOUS and VOLATILE dummy arguments subsumes an
existing warning about passing a constant actual to a VOLATILE dummy.

Resolves https://github.com/llvm/llvm-project/issues/93600.
2024-06-03 14:02:07 -07:00
Peter Klausler
b61d7ec16b
[flang] Relax constraints on PURE/ELEMENTAL dummy arguments (#93748)
The standard requires that dummy arguments to PURE functions be
INTENT(IN) or VALUE, but PURE subroutines are allowed to have modifiable
dummy arguments. This makes it impossible to declare atomic operations
as PURE functions, which consequently makes such atomic operations
ineligible for use in parallel constructs and DO CONCURRENT.

This patch downgrades this error to a warning by default, which can be
seen with -pedantic & al. and remain an error with -Werror.
2024-06-03 13:46:31 -07:00
Peter Klausler
68f4e46c43
[flang] Adjust "doubled operator" expression extension (#93353)
Most Fortran compilers accept "doubled operators" as a language
extension. This is the use of a unary '+' or '-' operator that is not
the first unparenthesized operator in an expression, as in 'x*-y'.

This compiler has implemented this extension, but in a way that's
different from other compilers' behavior. I interpreted the unary
'+'/'-' as a unary operator in the sense of C/C++, giving it a higher
priority than any binary (dyadic) operator.

All other compilers with this extension, however, give a unary '+'/'-' a
lower precedence than exponentiation ('**'), a binary operator that
C/C++ lacks. And this interpretation makes more sense for Fortran,
anyway, where the standard conforming '-x**y' must mean '-(x**y)'
already.

This patch makes 'x*-y**z' parse as 'x*-(y**z)', not 'x*(-y)**z)', and
adds a test to ensure that it does.
2024-06-03 11:58:18 -07:00
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
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
jiajie zhang
dc8d70acf7
[reland][flang] Add ETIME runtime and lowering intrinsics implementation (#92571)
This is same as https://github.com/llvm/llvm-project/pull/90578 with an
added fix. This PR updated tests of etime intrinsic due to Lowering
changes for assigning dummy_scope to hlfir.declare. Referring to
https://github.com/llvm/llvm-project/pull/92472 and
https://github.com/llvm/llvm-project/pull/90989
2024-05-18 01:00:25 +08:00
Mehdi Amini
6706aebefa
Revert "[flang] Add ETIME runtime and lowering intrinsics implementation" (#92354)
Reverts llvm/llvm-project#90578

This broke the premerge linux buildbot.
2024-05-15 23:26:07 -07:00
jiajie zhang
245b7b65cb
[flang] Add ETIME runtime and lowering intrinsics implementation (#90578)
This patch add support of intrinsics GNU extension ETIME
https://github.com/llvm/llvm-project/issues/84205. Some usage info and
example has been added to `flang/docs/Intrinsics.md`. The patch contains
both the lowering and the runtime code and works on both Windows and
Linux.


|   System  |   Implmentation  |
|-----------|--------------------|
| Windows| GetProcessTimes |
| Linux      |times                     |
2024-05-16 12:42:01 +08:00
Jay Foad
1650f1b3d7
Fix typo "indicies" (#92232) 2024-05-15 13:10:16 +01:00
Andrew Gozillon
435e850ba9 [Flang][OpenMP][MLIR] Initial derived type member map support
This patch is one in a series of four patches that seeks to refactor
slightly and extend the current record type map support that was
put in place for Fortran's descriptor types to handle explicit
member mapping for record types at a single level of depth.

For example, the below case where two members of a Fortran
derived type are mapped explicitly:

''''
  type :: scalar_and_array
    real(4) :: real
    integer(4) :: array(10)
    integer(4) :: int
  end type scalar_and_array
  type(scalar_and_array) :: scalar_arr

  !$omp target map(tofrom: scalar_arr%int, scalar_arr%real)
''''

Current cases of derived type mapping left for future work are:
  > explicit member mapping of nested members (e.g. two layers of
     record types where we explicitly map a member from the internal
     record type)
  > Fortran's automagical mapping of all elements and nested elements
     of a derived type
  > explicit member mapping of a derived type and then constituient members
     (redundant in Fortran due to former case but still legal as far as I am aware)
  > explicit member mapping of a record type (may be handled reasonably, just
     not fully tested in this iteration)
  > explicit member mapping for Fortran allocatable types (a variation of nested
     record types)

This patch seeks to support this by extending the Flang-new OpenMP lowering to
support generation of this newly required information, creating the neccessary
parent <-to-> member map_info links, calculating the member indices and
setting if it's a partial map.

The OMPDescriptorMapInfoGen pass has also been generalized into a map
finalization phase, now named OMPMapInfoFinalization. This pass was extended
to support the insertion of member maps into the BlockArg and MapOperands of
relevant map carrying operations. Similar to the method in which descriptor types
are expanded and constituient members inserted.

Pull Request: https://github.com/llvm/llvm-project/pull/82853
2024-05-10 14:16:26 -05:00
Peter Klausler
90501be35b
[flang] Accept interoperable types without BIND(C) (#91363)
A derived type that meets (most of) the requirements of an interoperable
type but doesn't actually have the BIND(C) attribute can be accepted as
an interoperable type, with optional warnings.
2024-05-09 11:04:50 -07:00
Peter Klausler
22c59e01cd
[flang] Don't crash on bad inherited implied DO type (#91073)
Fortran has an ambiguously defined rule about the typing of index
variables of implied DO loops in DATA statements and array constructors
that omit an explicit type specification. Such indices have the type
that they would have "if they were variables" in the innermost enclosing
scope. Although this could, and perhaps should, be read to mean that
implicit typing rules active in that innermost enclosing scope should be
applied, every other Fortran compiler interprets that language to mean
that if there is a type declaration for that name that is visible from
the enclosing scope, it is applied, and it is an error if that type is
not integer.

Fixes https://github.com/llvm/llvm-project/issues/91053.
2024-05-09 10:17:15 -07:00
Vijay Kandiah
86ab10c4d9
[flang] Added extension point callbacks to default FIR optimizer pipeline. (#90674)
This change inserts a few extension point callbacks in the
DefaultFIROptimizerPassPipeline. As an example usage of callbacks in the
FIR optimizer pipeline, the FIRInlinerCallback is now used to register
the default MLIR inliner pass in flang-new, tco, and bbc compilation
flows. Other compilation flows can use these callbacks to add extra
passes at different points of the pass pipeline.

---------

Co-authored-by: Vijay Kandiah <vkandiah@sky6.pgi.net>
2024-05-02 13:15:37 -05:00
David Truby
8d5386669e
[flang] Generate main only when a Fortran program statement is present (#89938)
This patch changes the behaviour for flang to only create and link to a
`main` entry point when the Fortran code has a program statement in it.

This means that flang-new can be used to link even when the program is
a mixed C/Fortran code with `main` present in C and no entry point
present in Fortran.

This also removes the `-fno-fortran-main` flag as this no longer has any
functionality.
2024-04-29 14:16:25 +01:00
Peter Klausler
8b512e525d
[flang][preprocessor] Support \ as line continuation (#89970)
When prescanning a Fortran source file with preprocessing enabled in
free source form, interpret a line-ending backslash as a source line
continuation marker as a C preprocessor would. This usage isn't
completely portable, but it is supported by GNU Fortran and appears in
the source for FPM package manager.
2024-04-24 15:47:29 -07:00
Michael Klemm
4841d70a4b
[flang] Remove obsolete flang-to-external-fc tool (#88904)
It seems like the `flang-to-external-fc` tool is no longer needed,
because Flang is now a full compiler in its own right. After PR #85249
has landed, this tool will not be able to pick up the `.f18.mod` files.
2024-04-19 19:44:53 +02:00
Tom Eccles
668a58b892
[flang][runtime] Add ACCESS library procedure (#88517)
Re-land https://github.com/llvm/llvm-project/pull/88395

Two build-bots were broken by the old version:
 - https://lab.llvm.org/buildbot/#/builders/285/builds/245
 - https://lab.llvm.org/buildbot/#/builders/21/builds/96988

The problem in both cases was that the compiler did not support
`std::filesystem` (which I use in the unit test).

I have removed the dependency upon std::filesystem because there isn't
an easy way to add the right linker options so that this is supported
correctly in all build environments [1]

[1] https://gitlab.kitware.com/cmake/cmake/-/issues/17834

---

This is a GNU extension:
https://gcc.gnu.org/onlinedocs/gfortran/ACCESS.html

Used in SALMON:
https://salmon-tddft.jp/download.html

Unfortunately the intrinsic takes a file path to operate on so there
isn't an easy way to make the test robust. The unit test expects to be
able to create, set read write and execute permissions, and delete files
called
std::filesystem::temp_directory_path() / <test_name>.<pid>

The test will fail if a file already exists with that name.

I have not implemented the intrinsic on Windows because this is wrapping
a POSIX system call and Windows doesn't support all of the permission
bits tested by the intrinsic. I don't have a Windows machine easily
available to check if Gfortran implements this intrinsic on Windows.
2024-04-16 10:25:26 +01:00
Tom Eccles
7e7468c9ed
Revert "[flang][runtime] Add ACCESS library procedure" (#88507)
Reverts llvm/llvm-project#88395

This broke the powerpc buildbot. That build doesn't support using
`std::filesystem` in flang unit tests.
2024-04-12 13:50:39 +01:00
Tom Eccles
f220d26eb1
[flang][runtime] Add ACCESS library procedure (#88395)
This is a GNU extension:
https://gcc.gnu.org/onlinedocs/gfortran/ACCESS.html

Used in SALMON:
https://salmon-tddft.jp/download.html

Unfortunately the intrinsic takes a file path to operate on so there
isn't an easy way to make the test robust. The unit test expects to be
able to create, set read write and execute permissions, and delete files
called
  `std::filesystem::temp_directory_path() / <test_name>.<pid>`

The test will fail if a file already exists with that name.

I have not implemented the intrinsic on Windows because this is wrapping
a POSIX system call and Windows doesn't support all of the permission
bits tested by the intrinsic. I don't have a Windows machine easily
available to check if Gfortran implements this intrinsic on Windows.
2024-04-12 13:43:48 +01:00
abidh
357f6c7826
[flang] Add design document for debug info generation. (#86939)
This document discusses some options where the debug metadata can be
generated. It also goes through various language constructs and explains
how the debug metadata will look like for that construct and how we can
extract that information.

The real point of discussion is how and where to extract the information
about various language features to generate the debug metadata. The
structure of the metadata itself is mostly settled as that is dictated by
the DWARF and structure of LLVM IR metadata. The classic flang
and gfortran generate quite similar DWARF for the various language
constructs.

This document is based on what Kiran posted in
https://reviews.llvm.org/D138534.

---------

Co-authored-by: Tom Eccles <t@freedommail.info>
Co-authored-by: Kiran Chandramohan <kiranchandramohan@gmail.com>
2024-04-11 17:53:25 +01:00
Michael Klemm
a1cd5e6954
[flang] Do not create .f18.mod files for each compiled module (#85249)
The default CMake scripts had a copy operation to copy a compiled `.mod`
file to also be available with suffix `.f18.mod`. This seems no longer
needed. Also updated ModFiles.md to point to `-module-suffix`.

---------

Co-authored-by: Kiran Chandramohan <kiranchandramohan@gmail.com>
2024-04-11 10:18:34 +02:00
Daniel Chen
e248f0df14
[Flang] Update Extensions.md for supported BIND(C) LOGICAL kind. (#88159)
Flang also supports non-scalar logical dummy argument with a different
KIND from C_BOOL to a bind(c) routine as well as a component in a
bind(c) derived type. Update the document.

```
subroutine sub(arg)
logical(4) :: arg(4)
end
```

```
type dt
logical(4) :: comp
end type
end
```
2024-04-09 15:05:12 -04:00
Peter Klausler
97e3f605d5
[flang] Don't allow non-standard data conversions of potentially abse… (#87391)
…nt arguments

Arguments to the intrinsic functions MAX and MIN after the first two are
optional. When these actual arguments might not be present at run time,
emit a compilation time error if they require data conversion (a
non-standard but nearly universal language extension); such a conversion
would crash if the argument was absent.

Other compilers either disallow data conversions entirely on MAX/MIN or
crash at run time if a converted argument is absent.

Fixes https://github.com/llvm/llvm-project/issues/87046.
2024-04-08 11:56:36 -07:00
jeanPerier
3c210d1cfd
[flang][NFC] document BOZ error in DIM, MOD, MODULO, and SIGN (#87779)
It is highly ambiguous to what type BOZ should be resolved in DIM, MOD,
MODULO, and SIGN intrinsic arguments. Some other compilers accept them,
but none agree. See table below.

List them explicitly as non supported extensions (semantics already
reject them, this is an NFC).

Table listing the resolved types of the intrinsic results when there is
a BOZ argument:

|                     | gfortran | nvfortran | ifort | nagfor | xlf    |
| ------------------- | -------- | --------- | ----- | ------ | ------ |
|  DIM(INT4, BOZ)     |  INT16   |  INT4     |  INT8 | crash  |  INT4  |
|  DIM(BOZ, REAL4)    | error    |  INT8     | error | error  |  REAL4 |
|  DIM(REAL4, BOZ)    | error    |  REAL4    | error | error  |  REAL4 |
|  DIM(BOZ, INT4)     |  INT16   |  INT8     |  INT8 | INT8   |  INT4  |
|  DIM(BOZ, BOZ)      |  INT16   |  INT8     |  INT8 | INT8   |  REAL4 |
|  MOD(INT4, BOZ)     |  INT16   |  INT4     |  INT8 | crash  |  INT4  |
|  MOD(BOZ, REAL4)    | error    |  INT8     | error | error  |  REAL4 |
|  MOD(REAL4, BOZ)    | error    |  REAL4    | error | error  |  REAL4 |
|  MOD(BOZ, INT4)     |  INT16   |  INT8     |  INT8 | INT8   |  INT4  |
|  MOD(BOZ, BOZ)      |  INT16   |  INT8     |  INT8 | INT8   |  INT4  |
|  MODULO(INT4, BOZ)  |  INT16   |  INT4     |  INT8 | crash  |  INT4  |
|  MODULO(BOZ, REAL4) | error    |  INT8     | error | error  |  REAL4 |
|  MODULO(REAL4, BOZ) | error    |  REAL4    | error | error  |  REAL4 |
|  MODULO(BOZ, INT4)  |  INT16   |  INT8     |  INT8 | INT8   |  INT4  |
|  MODULO(BOZ, BOZ)   |  INT16   |  INT8     |  INT8 | INT8   |  INT8  |
|  SIGN(INT4, BOZ)    | error    |  INT4     |  INT8 | INT4   |  INT4  |
|  SIGN(BOZ, REAL4)   | error    |  INT8     | error | error  |  REAL4 |
|  SIGN(REAL4, BOZ)   | error    |  REAL4    | error | error  |  REAL4 |
|  SIGN(BOZ, INT4)    | error    |  INT8     |  INT8 | INT8   |  INT4  |
|  SIGN(BOZ, BOZ)     |  INT16   |  INT8     |  INT8 | INT8   |  REAL4 |
2024-04-08 10:19:34 +02:00
Slava Zakharin
25ebbe3851
[flang][doc] Added information about REAL(16) math intrinsics support. (#87710) 2024-04-05 12:14:55 -07:00
Sergio Afonso
d84252e064
[MLIR][OpenMP] NFC: Uniformize OpenMP ops names (#85393)
This patch proposes the renaming of certain OpenMP dialect operations with the
goal of improving readability and following a uniform naming convention for
MLIR operations and associated classes. In particular, the following operations
are renamed:

- `omp.map_info` -> `omp.map.info`
- `omp.target_update_data` -> `omp.target_update`
- `omp.ordered_region` -> `omp.ordered.region`
- `omp.cancellationpoint` -> `omp.cancellation_point`
- `omp.bounds` -> `omp.map.bounds`
- `omp.reduction.declare` -> `omp.declare_reduction`

Also, the following MLIR operation classes have been renamed:

- `omp::TaskLoopOp` -> `omp::TaskloopOp`
- `omp::TaskGroupOp` -> `omp::TaskgroupOp`
- `omp::DataBoundsOp` -> `omp::MapBoundsOp`
- `omp::DataOp` -> `omp::TargetDataOp`
- `omp::EnterDataOp` -> `omp::TargetEnterDataOp`
- `omp::ExitDataOp` -> `omp::TargetExitDataOp`
- `omp::UpdateDataOp` -> `omp::TargetUpdateOp`
- `omp::ReductionDeclareOp` -> `omp::DeclareReductionOp`
- `omp::WsLoopOp` -> `omp::WsloopOp`
2024-03-20 11:19:38 +00:00
Peter Klausler
af964c7e31
[flang][runtime] Let FORT_CHECK_POINTER_DEALLOCATION=0 disable runtime … (#84956)
…check

Add an environment variable by which a user can disable the pointer
validation check in DEALLOCATE statement handling. This is not safe, but
it can help make a code work that allocates a pointer with an extended
derived type, associates its target with a pointer to one of its
ancestor types, and then deallocates that pointer.
2024-03-13 14:52:25 -07:00
agozillon
afb05cd646
[Flang][MLIR][OpenMP] Create a deferred declare target marking process for Bridge.cpp (#78502)
This patch seeks to create a process that happens on module finalization
for OpenMP, in which a list of operations that had declare target
directives applied to them and were not generated at the time of
processing the original declare target directive are re-checked to apply
the appropriate declare target semantics.

This works by maintaining a vector of declare target related data inside
of the FIR converter, in this case the symbol and the two relevant
unsigned integers representing the enumerators. This vector is added to
via a new function called from Bridge.cpp, insertDeferredDeclareTargets,
which happens prior to the processing of the directive (similarly to
getDeclareTargetFunctionDevice currently for requires), it effectively
checks if the Operation the declare target directive is applied to
currently exists, if it doesn't it appends to the vector. This is a
seperate function to the processing of the declare target via the
overloaded genOMP as we unfortunately do not have access to the list
without passing it through every call, as the AbstractConverter we pass
will not allow access to it (I've seen no other cases of casting it to a
FirConverter, so I opted to not do that).

The list is then processed at the end of the module in the
finalizeOpenMPLowering function in Bridge by calling a new function
markDelayedDeclareTargetFunctions which marks the latently generated
operations. In certain cases, some still will not be generated, e.g. if
an interface is defined, marked as declare target, but has no definition
or usage in the module then it will not be emitted to the module, so due
to these cases we must silently ignore when an operation has not been
found via it's symbol.

The main use-case for this (although, I imagine there is others) is for
processing interfaces that have been declared in a module with a declare
target directive but do not have their implementation defined in the
same module. For example, inside of a seperate C++ module that will be
linked in. In cases where the interface is called inside of a target
region it'll be marked as used on device appropriately (although,
realistically a user should explicitly mark it to match the
corresponding definition), however, in cases where it's used in a
non-clear manner through something like a function pointer passed to an
external call we require this explicit marking, which this patch adds
support for (currently will cause the compiler to crash).

This patch also adds documentation on the declare target process and 
mechanisms within the compiler currently.
2024-03-05 17:27:16 +01:00
jeanPerier
74dfded444
[flang] Deallocate structure constructor allocatable components (#83824)
Allocatable components of structure constructors were not deallocated.
Deallocate them without calling final subroutines.
This was already properly done for array constructors.
2024-03-05 09:25:17 +01:00
cor3ntin
7d55a3ba92
[Docs] Allow building man pages without myst_parser (#82402)
The man pages do not depend on the doc present in markdown files, so
they can be built without myst_parser.
Doing so might allow llvm distributions to have less development
dependencies.

As we do not have the ennvironment to test these configuration, this
capability is provided on a best-effort basis.

This restores a capability accidentally lost in #65664.
2024-03-04 13:31:26 +01:00
Peter Klausler
463fb9f214
[flang] Support INDEX as a procedure interface (#83073)
The specific intrinsic function INDEX should work as a PROCEDURE
interface in the declaration of a procedure pointer or dummy procedure,
and it should be compatible with a user-defined interface.

Fixes https://github.com/llvm/llvm-project/issues/82397.
2024-03-01 16:59:36 -08:00
Peter Klausler
f31ac3cb1f
[flang] Handle implied ASYNCHRONOUS attribute (#82638)
The standard states that data objects involved in an asynchronous data
transfer statement gain the ASYNCHRONOUS attribute implicitly in the
surrounding subprogram or BLOCK scope. This attribute affects the checks
in call semantics, as an ASYNCHRONOUS actual object associated with an
ASYNCHRONOUS dummy argument must not require data copies in or out.

(Most compilers don't implement implied ASYNCHRONOUS attributes
correctly; XLF gets these right, and GNU is close.)
2024-03-01 14:43:31 -08:00
Mats Petersson
601a9587a1
[Flang] Add support for assume_aligned directive (#81747)
This adds the parsing (and unparse) of the compiler drective assume_aligned.

The compiler will issue a warning that the directive is ignored.
2024-03-01 15:28:20 +00:00
David Spickett
d31406b394
[flang][docs] Update llvm-test-suite docs (#81596)
With some missing config options and a link to the test suite docs that
explain how to setup `ISO_FORTRAN_C_HEADER` and set the stop message
variable.
2024-02-21 10:20:02 +00:00
David Spickett
09b80e6145
[clang][flang][driver] Correct program names in option group descriptions (#81726)
Currently https://flang.llvm.org/docs/FlangCommandLineReference.html
refers to "Clang" in several of the group descriptions for example:
```
Compilation options

Flags controlling the behavior of Clang during compilation...
```

This is pretty confusing. I'm fixing this by making use of `Program`
from the existing GlobalDocumentation object to substitute in the
program name to these descriptions.

This `Program` has been changed to a proper noun given that it's easier
to lower case a string than capitalise one character (syntax wise). The
tablegen backend has been changed to lower it so that links in the
RST/HTML remain the same as they were before.

To make sure the file is valid when not generating docs, I'm checking a
#define and providing a default GlobalDocumentation if it's not defined.
(I looked for a way to check if a def exists, but tablegen doesn't seem
to have one)

This means that if the DocBrief are used outside of documentation,
they'll say "Clang", which is the same as it always was.

This change does not aim fix option descriptions that refer to clang.
Though we can use parts of this for that, there is only one driver
library so it needs a different approach.

This change also fixes the warning:
```
/home/buildbot/as-worker-4/publish-sphinx-docs/build/tools/flang/docs/Source/FlangCommandLineReference.rst:194: WARNING: unknown document: 'DiagnosticsReference'
```
Which is due to flang docs trying to link to clang docs. Now it will
just tell the reader to go to Clang's page, which is not ideal but it is
easy to find with Google at least.
2024-02-15 10:27:43 +00:00
David Spickett
e79ad7bb94 [flang][docs] Fix a couple of warnings 2024-02-13 11:28:30 +00:00
Tarun Prabhu
85598ae35a
[flang][docs] Update meeting link for technical call and some cleanup (#81147)
Added the meeting numbers and passcodes for both the technical and
community calls, just in case. Removed an obsolete reference to "LLVM
flang and current flang". Some minor stylistic edits.
2024-02-12 07:58:44 -07:00
Tarun Prabhu
10cd0e7a8b
[flang][docs] Update flang documentation regarding the test suite (#80755)
Remove redundant reference to flang not being able to generate code. Add
a reference to the gfortran tests that are part of the LLVM Test Suite.
2024-02-08 07:56:16 -07:00