Commit Graph

7373 Commits

Author SHA1 Message Date
David Truby
0bc7cd4d51
[flang] Add runtimes using --dependent-lib on MSVC targets (#72519)
This patch uses the added --dependent-lib support to add the relevant
runtimes on MSVC targets as `/DEFAULTLIB:` sections in the object file
rather than on the link line. This should help CMake support for flang
on Windows.

Fixes #63741 
Fixes #68017
2023-11-23 14:19:57 +00:00
Daniel Chen
af09219edd [Flang] Add partial support for lowering procedure pointer assignment. (#70461)
**Scope of the PR:**
1. Lowering global and local procedure pointer declaration statement
with explicit or implicit interface. The explicit interface can be from
an interface block, a module procedure or an internal procedure.
2. Lowering procedure pointer assignment, where the target procedure
could be external, module or internal procedures.
3. Lowering reference to procedure pointers so that it works end to end.

**PR notes:**
1. The first commit of the PR does not include testing. I would like to
collect some comments first, which may alter the output. Once I confirm
the implementation, I will add some testing as a follow up commit to
this PR.
2. No special handling of the host-associated entities when an internal
procedure is the target of a procedure pointer assignment in this PR.

**Implementation notes:**
1. The implementation is using the HLFIR path.
2. Flang currently uses `getUntypedBoxProcType` to get the
`fir::BoxProcType` for `ProcedureDesignator` when getting the address of
a procedure in order to pass it as an actual argument. This PR inherits
the same design decision for procedure pointer as the `fir::StoreOp`
requires the same memory type.

Note: this commit is actually resubmitting the original commit from
PR #70461 that was reverted. See PR #73221.
2023-11-23 13:43:35 +01:00
Muhammad Omair Javaid
49f55d1075 Revert "[Flang] Add partial support for lowering procedure pointer assignment. (#70461)"
This reverts commit e07fec10ac.

This change appears to have broken following buildbots:
https://lab.llvm.org/buildbot/#/builders/176
https://lab.llvm.org/buildbot/#/builders/179
https://lab.llvm.org/buildbot/#/builders/184
https://lab.llvm.org/buildbot/#/builders/197
https://lab.llvm.org/buildbot/#/builders/198

All bots fails in testsuite where following tests seems broken:
(eg: https://lab.llvm.org/buildbot/#/builders/176/builds/7131)

test-suite::gfortran-regression-compile-regression__proc_ptr_46_f90.test
test-suite::gfortran-regression-compile-regression__proc_ptr_37_f90.test
2023-11-23 12:30:40 +05:00
Valentin Clement (バレンタイン クレメン)
7f18f9a28c
[flang][openacc][NFC] Merge acc-declare.f90 tests (#73055) 2023-11-22 22:19:06 -08:00
kkwli
c9e347a0ce
[flang] Make .exe extension of the linker optional (NFC) (#73157) 2023-11-22 19:09:28 -05:00
Shraiysh
8840eb3fb5
[flang][OpenMP] Add semantic check for declare target (#72770) 2023-11-22 16:13:14 -06:00
Valentin Clement (バレンタイン クレメン)
575c9bf940
[flang][openacc] Avoid crash when collapse loop nest has extra directive (#73166)
The compiler was crashing when the collapse loop nest could not be
retrieved because of extra acc loop directive inside it.
2023-11-22 13:01:12 -08:00
Daniel Chen
e07fec10ac
[Flang] Add partial support for lowering procedure pointer assignment. (#70461)
**Scope of the PR:**
1. Lowering global and local procedure pointer declaration statement
with explicit or implicit interface. The explicit interface can be from
an interface block, a module procedure or an internal procedure.
2. Lowering procedure pointer assignment, where the target procedure
could be external, module or internal procedures.
3. Lowering reference to procedure pointers so that it works end to end.

**PR notes:**
1. The first commit of the PR does not include testing. I would like to
collect some comments first, which may alter the output. Once I confirm
the implementation, I will add some testing as a follow up commit to
this PR.
2. No special handling of the host-associated entities when an internal
procedure is the target of a procedure pointer assignment in this PR.

**Implementation notes:**
1. The implementation is using the HLFIR path.
2. Flang currently uses `getUntypedBoxProcType` to get the
`fir::BoxProcType` for `ProcedureDesignator` when getting the address of
a procedure in order to pass it as an actual argument. This PR inherits
the same design decision for procedure pointer as the `fir::StoreOp`
requires the same memory type.
2023-11-22 11:51:12 -05:00
Kiran Chandramohan
c2b3f16fb5
Revert "[Flang][OpenMP] NFC: Minor refactoring of Reduction lowering code" (#73139)
Reverts llvm/llvm-project#70790 to fix CI failure
(https://lab.llvm.org/buildbot/#/builders/268/builds/2884)
2023-11-22 15:47:24 +00:00
Kiran Chandramohan
8c02b34e3b
[Flang][OpenMP] NFC: Minor refactoring of Reduction lowering code (#70790)
Move reduction lowering code into a ReductionProcessor class. Create an
enumeration for Intrinsic Procedure reductions.
2023-11-22 15:26:36 +00:00
NimishMishra
956cf0e5de
[flang][OpenMP] Fix min reduction initialization (#73102)
Initialization of reduction variable for min-reduction is set to largest
negative value. As such, in presence of non-negative operands, min
reduction gives incorrect output. This patch initialises min-reduction
to use the maximum positive value instead, so that it can produce
correct output for the entire range of real valued operands.

Fixes https://github.com/llvm/llvm-project/issues/73101
2023-11-22 03:40:18 -08:00
Valentin Clement (バレンタイン クレメン)
60fa8cf2c3
[flang][openacc][NFC] Check only HLFIR lowering for remaining tests (#73054) 2023-11-21 15:53:57 -08:00
Valentin Clement (バレンタイン クレメン)
bda3409f2c
[flang][openacc][NFC] Check only HLFIR lowering for compute construct tests (#73051) 2023-11-21 15:53:30 -08:00
Valentin Clement (バレンタイン クレメン)
c384888fb3
[flang][openacc][NFC] Check only HLFIR lowering for enter/exit data tests (#73035)
HLFIR lowering as been set by default now and FIR lowering support will
be removed in the near future. This patch removes the specific FIR check
lines on enter/exit data tests.
2023-11-21 15:52:59 -08:00
Valentin Clement (バレンタイン クレメン)
d82b52139a
[flang][openacc][NFC] Remove run line for FIR only checks (#73050)
Remove the run lines that check for the FIR lowering. HLFIR lowering
produce the same check lines.
2023-11-21 15:13:19 -08:00
kkwli
8cf6e940b3
[flang] Remove dead code and update test (NFC) (#73004)
OutputUnformattedBlock and InputUnformattedBlock are not used.
2023-11-21 15:15:20 -05:00
Valentin Clement
219d029490
[flang][NFC] Move lowering test to correct folder 2023-11-21 09:15:58 -08:00
Valentin Clement (バレンタイン クレメン)
1caaec1fa7
[flang][openacc][NFC] Check only HLFIR lowering for declare tests (#73011)
HLFIR lowering as been set by default now and FIR lowering support will
be removed in the near future. This patch removes the specific FIR check
lines on declare tests.
2023-11-21 09:11:44 -08:00
Valentin Clement (バレンタイン クレメン)
d84834a695
[flang][openacc][NFC] Check only HLFIR lowering for data tests (#72926)
HLFIR lowering as been set by default now and FIR lowering support will
be removed in the near future. This patch removes the specific FIR check
lines.
2023-11-20 21:15:12 -08:00
Mehdi Amini
26a0b27736
Make MLIR Value more consistent in terms of const "correctness" (NFC) (#72765)
MLIR can't really be const-correct (it would need a `ConstValue` class
alongside the `Value` class really, like `ArrayRef` and
`MutableArrayRef`). This is however making is more consistent: method
that are directly modifying the Value shouldn't be marked const.
2023-11-20 20:52:15 -08:00
Slava Zakharin
0d77978e75
[flang][doc] Added remark about array element references in data clauses. (#72332) 2023-11-20 18:01:38 -08:00
Shraiysh
525396a3ae
[flang][OpenMP] Add semantic check for device clause (#72789)
This patch adds the following semantic check:

```
The ancestor device-modifier must not appear on the device clause on any
directive other than the target construct.
```
2023-11-20 19:54:22 -06:00
Valentin Clement (バレンタイン クレメン)
dfcf9fe140
[flang][openacc][NFC] Check only HLFIR lowering for atomic tests (#72922)
HLFIR lowering has been set by default now and FIR lowering support will
be removed in the near future. This patch is the first of a series to
update the OpenACC lowering tests to check only the HLFIR lowering and
remove and specific FIR check lines.
2023-11-20 15:44:55 -08:00
David Truby
5e36c64cb6 [flang] Remove extra space added with --dependent-lib option
This patch fixes a bug with the --dependent-lib option where an
extra space is added to the directive causing linking to fail.
2023-11-20 16:51:02 +00:00
Krzysztof Parzyszek
ddfed815c9 Revert "[OpenMP] atomic compare fail : Parser & AST support"
This reverts commit edd675ac28.

This breaks clang build where every component is a shared library.

The file clang/lib/Basic/OpenMPKinds.cpp, which is a part of
libclangBasic.so, uses `getOpenMPClauseName` which isn't:

/usr/bin/ld: CMakeFiles/obj.clangBasic.dir/OpenMPKinds.cpp.o: in functio
n `clang ::getOpenMPSimpleClauseTypeName(llvm::omp::Clause, unsigned int
)':
OpenMPKinds.cpp:(.text._ZN5clang29getOpenMPSimpleClauseTypeNameEN4llvm3o
mp6ClauseEj+0x9b): undefined reference to `llvm::omp::getOpenMPClauseNam
e(llvm::omp::Clause)'
2023-11-20 10:48:06 -06:00
Kiran Chandramohan
882d4006b9 [Flang][OpenMP] NFC: Formatting change 2023-11-20 16:44:43 +00:00
Sunil Kuravinakop
edd675ac28 [OpenMP] atomic compare fail : Parser & AST support
Diff Revision: https://reviews.llvm.org/D123235
2023-11-20 03:05:31 -06:00
Valentin Clement
208a4510d4
[flang][NFC] Fix typo 2023-11-17 10:54:45 -08:00
jeanPerier
915f6c3d6a
[flang][RFC] Adding a design document for assumed-rank objects (#71959)
This patch adds a document describing assumed-rank objects and the
related features as well as how they will be implemented in Flang.
2023-11-17 11:10:15 +01:00
Shraiysh
c06700bd75
Revert "[flang][OpenMP] Add semantic check for declare target" (#72592)
Reverts llvm/llvm-project#71861
2023-11-16 19:17:56 -06:00
Valentin Clement (バレンタイン クレメン)
9365ed1e10
[flang][openacc] Add ability to link acc.declare_enter with acc.declare_exit ops (#72476) 2023-11-16 16:41:50 -08:00
Shraiysh
7ff8094a39
[flang][OpenMP] Add semantic check for declare target (#71861)
This patch adds the following check from OpenMP 5.2.

```
If the directive has a clause, it must contain at least one enter clause
or at least one link clause.
```

Also added a warning for the deprication of `TO` clause on `DECLARE
TARGET` construct.

```
The clause-name to may be used as a synonym for the clause-name enter.
This use has been deprecated.
```

Based on the tests for to clause, the tests for enter clause are added.

This patch does not add tests where both to and enter clause are used together.
2023-11-16 18:03:32 -06:00
Tarun Prabhu
34e4e5eb70
[flang][Driver] Support -rpath, -shared, and -static in the frontend (#66702)
Enable -rpath, -shared, and -static for the flang frontend. This brings
it in line with clang. Fixes issue #65546.
2023-11-16 12:01:17 -07:00
Fabian Mora
be9fa9dee5
[flang][NVPTX] Add initial support to the NVPTX target (#71992)
This patch adds initial support to the NVPTX target, enabling `flang` to
produce OpenMP offload code for NVPTX targets.
2023-11-16 11:34:28 -05:00
Kiran Chandramohan
25d0f9fc3b
[Flang][OpenMP][OpenACC] Hoist nonAtomic Expr in atomic intrinsics (#72131)
Hoist non-atomic expressions in atomic intrinsics. Use a list to collect
the non-atomic expressions since the max and min intrinsics can have
more than two operands.

Hoisting makes the lowering to LLVMIR of iand,ior,ieor intrinsics
trivial. For max and min this still results in multiple instructions in
the atomic region but the loads are removed, which should help improve
performance.
2023-11-16 13:22:26 +00:00
Kiran Chandramohan
aa54851502 [Flang][Docs] NFC: Change cross-reference to href link
This change avoids the following warning:
'myst' cross-reference target not found: 'standards' [myst.xref_missing]
2023-11-15 17:04:23 +00:00
antoine moynault
ab1a7f1057
[flang] fix test dependent-lib.f90 (#72409) 2023-11-15 17:45:36 +01:00
Kiran Chandramohan
f0fbae5041 [Flang][Docs] NFC:Minor fix to section reference 2023-11-15 16:19:59 +00:00
David Truby
77ecb9a49b
[flang] Add dependent-lib option to flang -fc1 on Windows (#72121)
This patch adds a --dependent-lib option to flang -fc1 on Windows to
embed library link options into the object file. This is needed to
properly select the Windows CRT to link against.
2023-11-15 15:26:43 +00:00
Kiran Chandramohan
6d858e2ad3
[Flang][Doc] Trivial fixes for PDT doc (#72306)
Adjust the depth (number of #) for some sections.
Move an underscore prefix to a suffix in an example to let the Fortran
parser in the documentation generator pass.
2023-11-15 13:09:35 +00:00
Kiran Chandramohan
73f1753a95
[Flang][Doc] Fix trivial issues in HighLevelFIR.md (#72278)
Fixes section depth and removes annotation of source as HLFIR since this
is not currently understood by the lexer. Fixing these issues help
reduce warnings in the documentation CI for LLVM.
2023-11-15 09:54:15 +00:00
jeanPerier
aa8af04d0c
[flang] Switch lowering to use the HLFIR step by default (#72090)
Patch 3/3 of the transition step 1 described in

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

This patch changes bbc and flang-new driver to use HLFIR lowering by
default.

`-hlfir=false` can be used with bbc and `-flang-deprecated-no-hlfir`
with flang-new to get the previous default lowering behavior, but these
options will only be available for a limited period of time.

If any user needs these options to workaround bugs, they should open an
issue against flang in llvm github repo so that the regression can be
fixed in HLFIR.
2023-11-15 10:00:34 +01:00
Kiran Chandramohan
3f743fd3a3
[Flang][Docs] Fix lexer issue in Driver and Trampoline doc (#72322)
Allowed lexers are documented in https://pygments.org/docs/lexers/.
2023-11-15 04:53:42 +00:00
Kiran Chandramohan
d7b8ea63b3
[Flang][Docs] Fix GettingStarted.md with correct depth for in-tree build section (#72268)
Just a minor fix for the section depth for the patch in
https://reviews.llvm.org/D155029.
2023-11-15 04:53:21 +00:00
Kiran Chandramohan
d32df98954
[Flang][Docs] Add or exclude documents to the toc (#72302)
This fixes all the warnings of the following type in the CI
(https://lab.llvm.org/buildbot/#/builders/89/builds/50248/steps/5/logs/stdio)
-> WARNING: document isn't included in any toctree.
2023-11-14 22:42:26 +00:00
Valentin Clement (バレンタイン クレメン)
a3700cc29d
[flang][openacc] Make implicit declare region unstructured (#71591)
Using an op with a region cause some issue with unstructured code. This
patch make use of acc.declare_enter and acc.declare_exit to represent
the implicit declare region.
2023-11-14 14:42:11 -08:00
Kiran Chandramohan
70150d5d06
[Flang][Doc] Correct section depth in IntrinsicTypes.md (#72271)
Fixes flang documentation CI build.
2023-11-14 22:41:36 +00:00
Kiran Chandramohan
1d60d54a88
[Flang][Doc] Add a FIROperations section (#72252)
Adding this section ensures that the documentation generated by
mlir-tblgen for all the FIR operations are at the correct depth.
FIROperations are at depth 3, the new section is at depth 2. This fixes
the "Non-consecutive header level increase; H1 to H3" warning in
FIRLangRef.md.
2023-11-14 22:41:20 +00:00
Peter Klausler
0fdf9123bd
[flang] Fold MATMUL() (#72176)
Implements constant folding for matrix multiplication for all four
accepted type categories.
2023-11-14 14:37:23 -08:00
Valentin Clement (バレンタイン クレメン)
447af1ce99
[flang][openacc][openmp] Update stride computation for bounds (#72168)
This patch updates the stride computation for the outer dimensions of
multidimensional arrays where the stride is read from the descriptor.
For the inner dimension, the stride is the element size in bytes. Then
it is multiplied by the n-1 extent for outer dimensions.
2023-11-14 13:55:39 -08:00