Commit Graph

6727 Commits

Author SHA1 Message Date
Peter Klausler
ff56b7474f
[flang] Add two llvm_unreachable() calls to new code to silence compiler warning
This gets our -Werror build working again.

Differential Revision: https://reviews.llvm.org/D156745
2023-07-31 16:04:51 -07:00
Peter Klausler
fa4a304d51
[flang] Cope with homonymous generic/specific in generic resolution
When a generic interface X has a specific procedure Y that is also a specific
procedure of another generic with the same name (Y), ensure that
generic resolution of a call to X that resolves to Y points to the
symbol of the specific procedure Y, not the generic.

Differential Revision: https://reviews.llvm.org/D156341
2023-07-31 14:39:22 -07:00
Valentin Clement
887b69c1f1
[flang][openacc] Disallow the zero modifier on the create clause with the declare directive
The OpenACC 3.3 specification does not allow the `zero` modifier
on the `create` clause used with the declare directive.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156703
2023-07-31 14:29:56 -07:00
Peter Klausler
6fac3f7b2e
[flang] Stricter "implicit continuation" in preprocessing
The prescanner performs implicit line continuation when it looks
like the parenthesized arguments of a call to a function-like macro
may span multiple lines.  In an attempt to work more like a
Fortran-oblivious C preprocessor, the prescanner will act as if
the following lines had been continuations so that the function-like
macro could be invoked.

This still seems like a good idea, but a recent bug report on
LLVM's GitHub issue tracker shows one way in which it could trigger
inadvertently and mess up a program.  So this patch makes the
conditions for implicit line continuation much more strict.

First, the leading parenthesis has to have been preceded by an
identifier that's known to be a macro name.  (It doesn't have to
be a function-like macro, since it's possible for a keyword-like
macro to expand to the name of a function-like macro.)  Second,
no macro definition can ever have had unbalanced parentheses in
its replacement text.

Also cleans up some parenthesis recognition code to fix some
issues found in testing, so that a token with leading or trailing
spaces can still be recognized as a parenthesis or comma.

Fixes https://github.com/llvm/llvm-project/issues/63844.

Differential Revision: https://reviews.llvm.org/D155499
2023-07-31 14:22:43 -07:00
Peter Steinfeld
478e0b5860 [flang] Quadmath 128 bit floating point intrinsics
This update allows constant folding for many 128 bit floating point intrinsics
through the library quadmath, which is only available on some platforms.

Differential Revision: https://reviews.llvm.org/D156435
2023-07-31 11:12:29 -07:00
cabreraam
a033bf242f [flang][hlfir] work towards handling char_convert in hlfir
This patch aims to address the TODO for handling character conversion in HLFIR found [here](1defa78124/flang/lib/Lower/ConvertExprToHLFIR.cpp (L1388)) using [this similar operation but for FIR as inspiration](3ea673a97b/flang/lib/Lower/ConvertExpr.cpp (L1212-L1271)).

Reviewed By: vzakhari, tblah

Differential Revision: https://reviews.llvm.org/D155650
2023-07-31 10:45:10 -04:00
Nimish Mishra
da1f1b2292 Prevent extraneous copy in f752265231
Commit f752265231 uses
extraneous copy to the loop variable. Fixing the same
2023-07-31 17:31:19 +05:30
Nimish Mishra
f752265231 [flang][OpenMP] Support for privatization in common block
This patch provides support for usage of common block
in private/firstprivate and lastprivate clauses.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D156120
2023-07-31 16:46:18 +05:30
Peixin Qiao
b4c54b2027 [flang][OpenMP] Support common block in OpenMP private clause
This supports the common block in OpenMP privat clause by making
each common block member host-associated privatization and
adds the test case.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D127215
2023-07-31 16:24:12 +05:30
Sergio Afonso
fcb6a9c07c
[Flang][OpenMP][Lower] Refactor implementation of PFT to MLIR lowering
This patch makes the following non-functional changes:
  - Extract OpenMP clause processing into a new internal `ClauseProcessor`
    class. Atomic and reduction-related clauses processing is kept unchanged,
    since atomic clauses are stored in `OmpAtomicClauseList` rather than
    `OmpClauseList` and there are many TODO comments related to the current
    implementation of reduction lowering. This has been left unchanged to avoid
    merge conflicts and work duplication.
  - Reorganize functions into sections in the file to improve readability.
  - Explicitly use mlir:: namespace everywhere, rather than just most places.
  - Spell out uses of `auto` in which the type wasn't explicitly stated as part
    of the initialization expression.
  - Normalize a few function names to match the rest and renamed variables in
    'snake_case' to 'camelCase'.

The main purpose is to reduce code duplication and simplify the implementation
of upcoming work to support loop-attached target constructs and teams/
distribute lowering to MLIR.

Differential Revision: https://reviews.llvm.org/D155981
2023-07-31 10:51:39 +01:00
Fangrui Song
beb89e7fc0 Revert "[flang][test] Update %flang tests after D156363"
This reverts commit 7141c5b113
after the base commit D156363 was reverted.
2023-07-30 20:16:56 -07:00
Fangrui Song
7141c5b113 [flang][test] Update %flang tests after D156363 2023-07-29 20:37:39 -07:00
Valentin Clement
c57d249cd9
[flang][NFC] Fix typo 2023-07-28 13:50:31 -07:00
Valentin Clement
b5f7852c22
[flang][openacc] Fix acc-declare test 2023-07-28 10:17:28 -07:00
Valentin Clement
27f39ad499
[flang][openacc] Set structured to false for entry operation in declare ctor
Fix the value of the structured attribute for entry operation in the
global constructor noted in D156353.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156481
2023-07-28 09:48:14 -07:00
Andrzej Warzynski
e88ff8a79b [flang][nfc] Simplify option forwarding
Use `AddAllArgs` to keep the implementation succinct. Also adds missing
'-flang-experimental-hlfir` in "frontend-forwarding.f90"

Differential Revision: https://reviews.llvm.org/D156524
2023-07-28 14:23:58 +00:00
Victor Kingi
f04ccadf35 [Flang] Add support for fsave-optimization-record
Add support for generating and saving the optimization record.
Optimization record lists the optimizations performed by LLVM.

This patch enables the flag in Flang. Clang handles this functionality
using the BackendConsumer which Flang doesn't have, hence, was
implemented in CodeGenAction::executeAction

FlangOption added to all variants of fsave-optimization-record in
clang/include/clang/Driver/Options.td . Clang handles it the
same way.

opt_record_file, opt_record_passes and opt_record_format flags
in Options.td were moved out of the group [CC1Option, NoDriverOption]
to allow flang -fc1 support.

The renderRemarksOptions and willEmitRemarks functions in
clang/lib/Driver/ToolChains/Flang.cpp follow same syntax as clang.
In flang/lib/Frontend/CompilerInvocation.cpp we update the field
OptRecordFile with the provided optimization file value. Clang
doesn't do this as it processes the Options.td, mapping the
OptRecordFile earlier on.

Reviewed By: awarzynski, tblah

Differential Revision: https://reviews.llvm.org/D155452
2023-07-28 09:26:40 +00:00
Valentin Clement
723e424e56
[flang][openacc][NFC] Remove unused variables 2023-07-27 14:06:18 -07:00
Valentin Clement
2a81925163
[flang][openacc][NFC] Move declare lowering for module in its own function 2023-07-27 14:03:32 -07:00
Slava Zakharin
fb7366cab1 [flang] Fixed shape computation for elementals with optional dummys.
It looks like a regression after D151737: shape of the elemental
call became rank-0.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D156386
2023-07-27 13:56:13 -07:00
Slava Zakharin
c78b528f99 [flang][runtime] Handle conflicts for derived types with dynamic components.
When creating a temporary for conflicting LHS and RHS we have to deep copy
the dynamic (allocatable, automatic) components from RHS to the temp.
Otherwise, the conflict may still be present between LHS and temp.

gfortran/regression/alloc_comp_assign_1.f90 is an example where the current
runtime code produces wrong result:
7b5b5dcbf9/Fortran/gfortran/regression/alloc_comp_assign_1.f90 (L50)

Reviewed By: klausler, tblah

Differential Revision: https://reviews.llvm.org/D156364
2023-07-27 13:56:13 -07:00
Valentin Clement
a2b92017d3
[flang][openacc] Lower acc declare link for module variable
This patch adds support to lower the link clause on OpenACC
declare construct in module declaration.

Depends on D156463

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156464
2023-07-27 13:04:00 -07:00
Valentin Clement
bbd214d997
[flang][openacc] Lower acc declare device_resident for module variable
This patch adds support to lower the device_resident clause on OpenACC
declare construct in module declaration.

Depends on D156457

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156463
2023-07-27 13:01:22 -07:00
Valentin Clement
5f2c585b10
[flang][openacc] Lower acc declare copyin for module variable
This patch adds support to lower the copyin clause on OpenACC
declare construct in module declaration.

Depends on D156353

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156457
2023-07-27 13:00:20 -07:00
Valentin Clement
e25d7f1688
[flang][openacc] Add global destructor for acc declare construct
Add the acc.global_dtor when lowering the OpenACC declare
construct.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156353
2023-07-27 12:59:01 -07:00
Kelvin Li
2c2d427ca3 [flang] Add a subset of PowerPC MMA (Matrix Multiply Accelerate) intrinsics
This patch includes the a subset of MMA intrinsics that are included in
the mma intrinsic module:

mma_assemble_acc
mma_assemble_pair
mma_build_acc
mma_disassemble_acc
mma_disassemble_pair

Submit on behalf of Daniel Chen <cdchen@ca.ibm.com>

Differential Revision: https://reviews.llvm.org/D155725
2023-07-27 14:30:06 -04:00
Alex Zinenko
b2b7efb96d [mlir] NFC: rename XDataFlowAnalysis to XForwardDataFlowAnalysis
This makes naming consisnt with XBackwardDataFlowAnalysis.

Reviewed By: Mogball, phisiart

Differential Revision: https://reviews.llvm.org/D155930
2023-07-27 11:11:40 +00:00
Valentin Clement
c217ff8794
[flang][openacc] Add basic lowering for OpenACC declare construct in module
This patch adds the skeleton and the basic lowering for OpenACC declare
construct when located in the module declaration. This patch just lower the
create clause with or without modifier. Other clause and global descrutor
lowering will come in follow up patches to keep this one small enough for
review.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156266
2023-07-26 09:56:19 -07:00
V Donaldson
7ba2ac2828 [flang] test update 2023-07-25 11:27:51 -07:00
V Donaldson
f1ada999e2 [flang] build test failure 2023-07-25 11:08:34 -07:00
V Donaldson
ba531a55c6 [flang] Implement procedure IEEE_COPY_SIGN with mlir::math::CopySignOp 2023-07-25 10:52:48 -07:00
Johannes Doerfert
08a220764b Reapply "[OpenMP] Add the ompx_attribute clause for target directives"
This reverts commit 0d12683046 and
reapplies ef9ec4bbcc with an extension to
fix the Flang build.

Differential Revision: https://reviews.llvm.org/D156184
2023-07-25 10:40:35 -07:00
Tobias Hieta
4706251a31
Clear release notes for 18.x 2023-07-25 13:58:49 +02:00
Kelvin Li
447c3a358d [flang] Add PowerPC vec_abs, vec_nmadd, vec_msub and vec_sel intrinsics
Co-authored-by: Paul Scoropan <1paulscoropan@gmail.com>

Differential Revision: https://reviews.llvm.org/D154985
2023-07-24 14:03:50 -04:00
Slava Zakharin
60f02aa7f7 [flang][hlfir] Fixed KindMapping for HLFIR intrinsics lowering.
hlfir.count lowering was using incorrect default integer kind
by ignoring the kind specified in the ModuleOp.

Reviewed By: tblah

Differential Revision: https://reviews.llvm.org/D156017
2023-07-24 10:12:39 -07:00
Slava Zakharin
3eedff3c04 [flang][hlfir] Inherit constant length for the result of hlfir.transpose.
Character length may be unknown for the type of Fortran::evaluate::FunctionRef
expression, but we can try to propagate it from the argument of
TRANSPOSE if it is known constant. Alternatively, we could relax
hlfir.transpose verification (i.e. allow character types mismatch
for the argument and the result).

Depends on D155912

Reviewed By: tblah

Differential Revision: https://reviews.llvm.org/D155913
2023-07-24 10:12:39 -07:00
Valentin Clement
be5ac66643
[flang][openacc] Keep original array size in reduction init region with slice
Keep the original array size when materializing the private copy.

Depends on D155882

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D155893
2023-07-24 09:34:31 -07:00
Valentin Clement
9d8e4759a8
[flang][openacc] Update materialization recipe for private copy in reduction init region
Update the code generated in the init region to materialize the private
copy.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D155882
2023-07-24 09:33:39 -07:00
Fangrui Song
4c73549ebf [test] Fix compiler_version.f90 for -DLLVM_APPEND_VC_REV=OFF builds after D152572
Checking the patch version is too strict. Just check major and minor
versions as in clang/test/Driver/immediate-options.c.
2023-07-22 16:06:29 -07:00
Fangrui Song
bd0aab5a15 [Frontend] Sort featuresVec for AMDGPU target features
D145579 leverages the iteration order of StringSet, which is not
guaranteed to be deterministic.
2023-07-22 15:57:41 -07:00
Valentin Clement
d4f2416398
[flang][openacc] Fix hasDynamicShape logic
Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D155897
2023-07-21 21:46:50 -07:00
Peter Klausler
24d293913c
[flang] Fix portability warning that was incorrectly an "else if"
A semantics check for an assumed-length dummy procedure pointer was
inappropriately part of an "else" clause for a preceding check,
causing it to not be applied in all situations.

Differential Revision: https://reviews.llvm.org/D155975
2023-07-21 15:34:53 -07:00
Peter Klausler
cfa032cea0
[flang] Emit just one warning for a bad format edit descriptor
An attempt to use an edit descriptor (other than A or L) in a FORMAT
statement without arequired 'w' width will elicit warnings from both
the parser and the I/O checker in semantics.  Remove the warning from
the parser.

Differential Revision: https://reviews.llvm.org/D155977
2023-07-21 15:16:59 -07:00
Peter Klausler
b7585c75ee
[flang][runtime] Fix NORM2([negative, ...])
NORM2 is broken for arrays that start with a negative number
because it sets the initial running max_ value to that number
rather than to its absolute value.

Differential Revision: https://reviews.llvm.org/D155976
2023-07-21 14:57:31 -07:00
Peter Klausler
f7e4304120
[flang] Strengthen procedure compatibility checking
Add more checks to procedure compatibility testing for procedure pointer
assignments, actual procedure arguments, &c.  Specifically, don't
allow corresponding dummy data objects to differ in their use
of polymorphism, assumed size arrays, or assumed shape arrays.

Differential Revision: https://reviews.llvm.org/D155974
2023-07-21 14:44:10 -07:00
Peter Klausler
28eec1bd85
[flang] Portability warning and documentation for an obscure extension
A quotation mark can appear in a Fortran character literal by doubling
it; for example, PRINT *, "'""'" prints '"'.  When those doubled
quotation marks are split by a free form line continuation, the
continuation line should have an ampersand before the second quotation
mark.  But most compilers, including this one, allow the second
quotation mark to appear as the first character on the continuation
line, too.

So this works:

  print *, "'"&
"'"

but it really should be written as:

  print *, "'"&
&"'"

Emit a portability warning and document that we support this near-universal
extension.

Differential Revision: https://reviews.llvm.org/D155973
2023-07-21 14:30:40 -07:00
Peter Klausler
b26dd42458
[flang] Rename new test file
A recent patch added a new test file whose name conflicts with an existing
test on case-insensitive filesystems.  Rename it.
2023-07-21 14:16:56 -07:00
Peter Klausler
8ceba5980c
[flang] Ensure that NULL(without MOLD=) not passed to dummy argument with assumed type parameters
A dummy argument with an assumed (*) character length or derived type parameter
value specification needs to be associated with an actual argument that can
supply a value for it, so make sure that a NULL without a MOLD= is not being
passed.

Differential Revision: https://reviews.llvm.org/D155971
2023-07-21 14:13:16 -07:00
Peter Klausler
24445fc15c
[flang] Disallow ASYNCHRONOUS for subroutine
The check for inappropriate usage of the ASYNCHRONOUS attribute
needed to be moved in declaration checking so that it can catch
attempts to use it on a subroutine.

Differential Revision: https://reviews.llvm.org/D155970
2023-07-21 13:40:30 -07:00
Peter Klausler
e7cb677800
[flang] Enforce F'2023 C7125
An item whose declared type is ABSTRACT may not appear in an
array constructor.

Differential Revision: https://reviews.llvm.org/D155969
2023-07-21 13:39:28 -07:00