19 Commits

Author SHA1 Message Date
Thirumalai Shaktivel
e73ec1a74a
[Flang][OpenMP] Add some semantic checks for Linear clause (#111354)
This PR adds all the missing semantics for the Linear clause based on
the OpenMP 5.2 restrictions. The restriction details are mentioned
below.

OpenMP 5.2:
5.4.6 linear Clause restrictions
- A linear-modifier may be specified as ref or uval only on a declare
simd directive.
- If linear-modifier is not ref, all list items must be of type integer.
- If linear-modifier is ref or uval, all list items must be dummy
arguments without the VALUE attribute.
- List items must not be Cray pointers or variables that have the
POINTER attribute. Cray pointer support has been deprecated.
- If linear-modifier is ref, list items must be polymorphic variables,
assumed-shape arrays, or variables with the ALLOCATABLE attribute.
- A common block name must not appear in a linear clause.
- The list-item cannot appear more than once

4.4.4 ordered Clause restriction
- If n is explicitly specified, a linear clause must not be specified on
the same directive.

5.11 aligned Clause restriction
- Each list item must have C_PTR or Cray pointer type or have the
POINTER or ALLOCATABLE attribute. Cray pointer support has been
deprecated.
2024-12-06 12:11:46 -06:00
Krzysztof Parzyszek
00ab44ee66
[flang][OpenMP] Add version checks for clauses (#110015)
If there is a clause that is allowed on a given directive in a later
version of the OpenMP spec, report an error and provide the minimal spec
version that allows the clause.

The case where a clause is not allowed on a directive at all is already
handled elsewhere.
2024-09-26 08:56:41 -05:00
Jean Perier
54881c9225 [flang] Remove test from #69121 to fix gcc build with gcc < 10.0
ISO_Fortran_binding.h was only added to in gcc 10.0. Flang should be
buildable with older versions. Remove the test until a safe way to
check that the compiler can run the test (that it is clang from the
build for instance).

Fix bots failure https://lab.llvm.org/buildbot/#/builders/181/builds/24526
Also in:

https://lab.llvm.org/buildbot/#/builders/160
https://lab.llvm.org/buildbot/#/builders/268
https://lab.llvm.org/buildbot/#/builders/181
2023-10-20 10:13:04 +02:00
Pete Steinfeld
e6e9084070
[flang] Put ISO_Fortran_binding.h where it can be easily used (#69121)
The update stems from the discussion in

https://discourse.llvm.org/t/adding-flang-specific-header-files-to-clang/72442

This is my second attempt at this. My first attempt was in pull request
#68756.

I decided to put ISO_Fortran_binding.h in a place where it would be
accessible with the include: "#include<ISO_Fortran_binding.h>" rather
than "#include<fortran/ISO_Fortran_binding.h>" because this is what
gfortran implements.

Note that the file is also installed into ".../include/flang", so if a
user wanted to access the file from a compiler other than clang, it
would be available.

I added a test in ".../flang/test/Examples". To make the test work, I
also needed to put ISO_Fortran_binding.h into the build area.

Although the flang project depends on clang, clang may not always be
available in a flang build. For example, when building just the
"check-flang" target, the "clang" executable may not be available at the
time the new test gets run. To account for this, I made the test's
script check for the existence of the "clang" executable. If "clang" is
not available, it simply prints "PASS". If it is available, it fully
builds and executes the test. On success, this will also print "PASS"
2023-10-19 07:43:10 -07:00
Ethan Luis McDonough
00d0749f92
[flang] Feature list plugin
Plugin that counts the number of times each tree node occurs in a given program.  Used for test coverage.

Updated to fix build issues.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D143704
2023-04-24 23:41:32 -05:00
Ethan Luis McDonough
22293a3d85
Revert "[flang] Feature list plugin" due to failing build
This reverts commit 823ddba1b325f30fc3fb2e9d695c211b856a4d5d.
2023-03-22 15:49:50 -05:00
Ethan Luis McDonough
823ddba1b3
[flang] Feature list plugin
Plugin that counts the number of times each tree node occurs in a given program.  Used for test coverage.

Updated to fix build issues.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D143704
2023-03-22 01:27:55 -05:00
Valentin Clement
9be446588e
Revert "[flang] Feature list plugin"
This reverts commit bde91fd03f72a25151caa9f8ee2d4572ff14619b.

Failing buildbot: https://lab.llvm.org/buildbot/#/builders/181/builds/15552
2023-03-17 17:59:22 +01:00
Ethan Luis McDonough
bde91fd03f
[flang] Feature list plugin
Plugin that counts the number of times each tree node occurs in a given program.  Used for test coverage.

> One thing we need...is a way to determine what features a code uses. Preferably we would also be able to determine if they are implemented or not. Just the former could be done with a visitor for the parse tree. For the latter we would continue compilation and somehow ignore todo errors but collect them - @jdoerfert

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D143704
2023-03-17 02:28:59 -05:00
Slava Zakharin
1c5d121440 [flang] Handle Flang examples consistently with LLVM.
Without this change the problem is that flangOmpReport and
flangPrintFunctionNames libraries are not built under 'all',
but they are imported targets via LLVMExports.cmake so that
any out-of-tree build that configures upon LLVM+Flang package
will get this CMake error:
```
  The imported target "flangPrintFunctionNames" references the file

     ".../lib/flangPrintFunctionNames.so"

  but this file does not exist.
```

flang-aarch64-out-of-tree buildbot (https://lab.llvm.org/buildbot/#/builders/175)
does not catch this issue, because it does not enable Flang on the first stage.

This change gets rid of FLANG_BUILD_EXAMPLES in favor of LLVM_BUILD_EXAMPLES
and uses available LLVM CMake macros to add example executables/libraries.

Differential Revision: https://reviews.llvm.org/D145992
2023-03-14 13:08:43 -07:00
Kavitha Natarajan
a7d352c76d [flang][OpenMP] Add parser support for order clause
Added parser support for OpenMP 5.0 & 5.1 feature
ORDER([order-modifier :]concurrent) clause for all
applicable and supported OpenMP directives.

Reviewed By: kiranchandramohan, abidmalikwaterloo

Differential Revision: https://reviews.llvm.org/D142524
2023-02-21 19:31:19 +05:30
Fangrui Song
3f17dc89d3 [flang][test] Remove RUN COMMAND/EXPECTED OUTPUT/INPUT markers from other directories 2022-06-29 22:10:59 -07:00
Nimish Mishra
6a3c4a40f4 [flang][OpenMP] Added parser support for in_reduction clause
OpenMP 5.0 adds a new clause `in_reduction` on OpenMP directives.
This patch adds parser support for the same.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D124156
2022-06-06 14:55:27 +05:30
Shraiysh Vaishay
ae1623b306 [flang][Parser] Add a node for individual sections in sections construct
This patch adds parser nodes for each indivudual section in sections
construct. This should help with the translation to FIR. `!$omp section`
was not recognized as a construct and hence needed special handling.

`OpenMPSectionsConstruct` contains a list of `OpenMPConstruct`. Each
such `OpenMPConstruct` wraps an `OpenMPSectionConstruct`
(section, not sections). An `OpenMPSectionConstruct` is a wrapper around
a `Block`.

Reviewed By: kiranchandramohan, peixin

Differential Revision: https://reviews.llvm.org/D121680
2022-03-18 21:55:35 +05:30
Josh Mottley
2aec2549e8 [flang][flang-omp-report] Remove the loop workarounds for nowait clause
In a "Worksharing-loop construct", one can add a nowait clause at the end
of the loop (i.e. at the loop tail). This clause wasn't associated with
the corresponding loop when originally worked on in flang-omp-report.
Note that this refers to parsing and parse-tree generation. To work
around it, it was needed to track such clauses and the loops.
This should no longer be required (and in fact no longer works) and so
was removed. This results in 'curLoopLogRecord' and 'loopLogRecordStack' and
all references to them being removed. This also allows for
'constructClauses' to be swapped from std::deque to llvm::SmallVector.
Lastly a new test has been added testing the "nowait" clauses in a
variety of ways.

Reviewed By: awarzynski, kiranchandramohan

Differential Revision: https://reviews.llvm.org/D112217
2021-11-04 14:23:50 +00:00
Josh Mottley
0a95abb7dc [flang][flang-omp-report] Removed unnecessary comments in flang-omp-report plugin tests
This patch removes unnecessary comments in the flang-omp-report
plugin tests which can be implied from the file name and run command.

Reviewed By: awarzynski

Differential Revision: https://reviews.llvm.org/D112817
2021-11-04 13:46:19 +00:00
Andrzej Warzynski
5c52753d9f [Flang] Fix failing plugin tests
The updated tests were originally added in
https://reviews.llvm.org/D109890 and are currently causing some
buildbots to fail.

This patch:
* adds missing items in the `REQUIRERS` list in tests
* adds `flangOmpReport` (the plugin library added in D109890) as a CMake
  dependency for tests (only when examples are enabled)

Differential Revision: https://reviews.llvm.org/D110682
2021-09-29 09:27:11 +00:00
Stuart Ellis
38c42d42eb Flang OpenMP Report Plugin
This plugin parses Fortran files and creates a
YAML report with all the OpenMP constructs and
clauses seen in the file.

The following tests have been modified to be
compatible for testing the plugin, hence why
they are not reused from another directory:

- omp-atomic.f90
- omp-declarative-directive.f90
- omp-device-constructs.f90

The plugin outputs a single file in the same
directory as the source file in the following format:
`<source-file-name>.yaml`

Building the plugin:
`ninja flangOmpReport`

Running the plugin:
`./bin/flang-new -fc1 -load lib/flangOmpReport.so -plugin flang-omp-report -fopenmp <source_file.f90>`

Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com>
Co-authored-by: Stuart Ellis <stuart.ellis@arm.com>

Reviewed By: awarzynski, kiranchandramohan

Differential Revision: https://reviews.llvm.org/D109890
2021-09-28 22:57:17 +01:00
Stuart Ellis
520e5db26a [flang][driver] Add print function name Plugin example
Replacing Hello World example Plugin with one that counts and prints the names of
functions and subroutines.
This involves changing the `PluginParseTreeAction` Plugin base class to
inherit from `PrescanAndSemaAction` class to get access to the Parse Tree
so that the Plugin can walk it.
Additionally, there are tests of this new Plugin to check it prints the correct
things in different circumstances.

Depends on: D106137

Reviewed By: awarzynski

Differential Revision: https://reviews.llvm.org/D107089
2021-08-19 08:25:34 +00:00