Commit graph

2547 commits

Author SHA1 Message Date
compinder 594dec2884 [FLANG] Fix issues in SELECT TYPE construct when intrinsic type specification is specified in TYPE GUARD statement.
Fix of PR46789 and PR46830.

Differential Revision: https://reviews.llvm.org/D84290
2020-08-03 09:24:42 +05:30
River Riddle 2a6c8b2e95 [mlir][PassIncGen] Refactor how pass registration is generated
The current output is a bit clunky and requires including files+macros everywhere, or manually wrapping the file inclusion in a registration function. This revision refactors the pass backend to automatically generate `registerFooPass`/`registerFooPasses` functions that wrap the pass registration. `gen-pass-decls` now takes a `-name` input that specifies a tag name for the group of passes that are being generated. For each pass, the generator now produces a `registerFooPass` where `Foo` is the name of the definition specified in tablegen. It also generates a `registerGroupPasses`, where `Group` is the tag provided via the `-name` input parameter, that registers all of the passes present.

Differential Revision: https://reviews.llvm.org/D84983
2020-07-31 13:20:37 -07:00
Sourabh Singh Tomar bf812c145c [flang][OpenMP] Added initial support for lowering OpenMP parallel construct
This patch lower `!OMP PARALLEL` construct from PFT to OpenMPDialect operations.
This is first patch in this direction(lowering parallel construct).

OpenMP parallel construct can have multiple clauses and parameters. This patch
only implements lowering of an empty(contains no code in body) parallel construct
without any clauses or parameters.

Patch is carved out of following approved PR:
https://github.com/flang-compiler/f18-llvm-project/pull/322

Reviewed By: kiranchandramohan, DavidTruby

Differential Revision: https://reviews.llvm.org/D84965
2020-07-31 23:59:46 +05:30
sameeran joshi b752a8ca49 [flang][NFC] Verify C781 from - Clause 7 constraint checks for f18.
Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D84503
2020-07-31 23:58:18 +05:30
sameeran joshi 8830f1170d [flang]Verify C7107, C7108, C7109 from - Clause 7 constraint checks for f18.
1.  Annotate the sources with constraint numbers.
   2.  Add tests for

    *C7107 (R765) digit shall have one of the values 0 or 1.
    *C7108 (R766) digit shall have one of the values 0 through 7.
    *C7109 (R764) A boz-literal-constant shall appear only as a data-stmt-constant in a DATA statement, or where explicitly allowed in 16.9 as an actual argument of an intrinsic procedure.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D84504
2020-07-31 23:45:20 +05:30
Tim Keith 765b81f6b9 Revert "[flang] Fix multi-config generator builds."
This reverts commit 332170356e.

The change breaks out-of-tree builds.
Discussion in https://reviews.llvm.org/D84022
2020-07-31 11:10:44 -07:00
sameeran joshi 49660234db [Flang] Checks for constraint C7110-C7115.
Added more tests.
	 Annotate sources and tests.
	 Improve error message.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D85014
2020-07-31 23:27:57 +05:30
Richard Barton 30e45f339e [flang] Add -h as a synonym for help
As expected by user in http://lists.llvm.org/pipermail/flang-dev/2020-June/000404.html

Depends on D84856

Differential Revision: https://reviews.llvm.org/D84857
2020-07-31 15:56:37 +01:00
Richard Barton b068d19a15 [flang] Add details to --help screen on default behaviour
Add a usage string and a defaults section that clarifies:
 * If no input files are given, f18 reads from stdin
 * If no input files are given, f18 dumps the parse tree.
 * The default behaviour is to exec F18_FC.
 * The fefault F18_FC setting is 'gfortran'

Adds a simple regression test which tests the top and tail of the help
screen and the exit status.

Depends on D84855

Differential Revision: https://reviews.llvm.org/D84856
2020-07-31 15:56:37 +01:00
Richard Barton dd5ea5674b [flang] Make interactive behaviour more obvious
When flang is invoked with no files it waits for input on stdin. Make it
print a message saying this to prevent the user being surprised.

Differential Revision: https://reviews.llvm.org/D84855
2020-07-31 15:56:37 +01:00
Jean Perier a50cec71ec [flang] Fix CMPLX folding with complex arguments
CMPLX folding was expecting only one arguments in case X argument
is complex. This is wrong since there is also the optional KIND
argument.

Reviewed By: schweitz

Differential Revision: https://reviews.llvm.org/D84936
2020-07-31 10:26:08 +02:00
Peter Steinfeld 2cf52504bb [flang] Fixes for RESHAPE()
I fixed an assert caused by passing an empty array as the source= argument to
RESHAPE().  In the process, I noticed that there were no tests for RESHAPE(),
so I wrote a test that covers all the description in 16.9.163.  In the process,
I made the error messages more consistent and descriptive.  I also changed the
test to see if a reference to an intrinsic function was a constant to say that
it is a constant if it's a refererence to an invalid intrinsic.  This avoids
emitting multiple messages for the same erroneous source.

Differential Revision: https://reviews.llvm.org/D84904
2020-07-30 19:05:06 -07:00
Peter Steinfeld fac84536bc [flang] Fix an assert on duplicate initializations
When declaring the same variable twice with an initialization, we were failing
an internal check.  I fixed this by checking to see if the associated symbol
already had an error.

I added tests for pointer and non-pointer initialization of duplicate names.

Differential Revision: https://reviews.llvm.org/D84969
2020-07-30 12:58:28 -07:00
Tim Keith 38272f45fe [flang] Create HostAssoc symbols for uplevel references
To make it easier for lowering to identify which symbols from the host
are captured by internal subprograms, create HostAssocDetails for them.

In particular, if a symbol is referenced and it is contained in a
subprogram or main program that is not the same as the containing
program unit of the reference, a HostAssocDetails symbol is created
in the current scope.

Differential Revision: https://reviews.llvm.org/D84889
2020-07-30 07:12:26 -07:00
Jean Perier 67e41df4e0 [flang] Expose specific to generic intrinsic name mapping
The intrinsic lowering facility is based on the generic intrinsic names to avoid
duplicating implementations. Specific intrinsics call are re-written to call to
the generic versions by the front-end but this cannot be done when specific intrinsics
are passed as arguments (the rewrite would give illegal/ambiguous unparsed Fortran).
Solve the issue by making the specific to generic name mapping accessible to lowering
and can be later used to generate the unrestricted intrinsic functions.

Reviewed By: schweitz

Differential Revision: https://reviews.llvm.org/D84842
2020-07-30 14:30:12 +02:00
David Truby 332170356e [flang] Fix multi-config generator builds.
Summary:
Currently the binaries are output directly into the bin subdirectory of the
build directory. This doesn't work correctly with multi-config generators which
should output the binaries into <CONFIG_NAME>/bin instead.

Reviewers: sscalpone, richard.barton.arm

Subscribers: mgorny, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D84022
2020-07-30 09:56:52 +01:00
Tim Keith 2c662f3d3d [flang] Fix bug with intrinsic in type declaration stmt
When an instrinsic function is declared in a type declaration statement
we need to set the INTRINSIC attribute and (per 8.2(3)) ignore the
specified type.

To simplify the check, add IsIntrinsic utility to BaseVisitor.

Also, intrinsics and external procedures were getting assigned a size
and offset and they shouldn't be.

Differential Revision: https://reviews.llvm.org/D84702
2020-07-29 07:23:31 -07:00
Tim Keith 9500d48de3 [flang][NFC] Extract name resolution for OpenACC & OpenMP into new file
Move `ResolveAccParts` and `ResolveOmpParts` from resolve-names.cpp to
resolve-directives.{h,cpp}. Move the implementation in the classes
`DirectiveAttributeVisitor`, `AccAttributeVisitor`, and
`OmpAttributeVisitor` to resolve-directives.cpp as well.

To allow this to happen, move `EvaluateIntExpr` and introduce
`EvaluateInt64` to resolve-names-utils.h. The latter is also useful
elsewhere in resolve-names.cpp for converting an Expr to std::int64_t.

The other problem was that `ResolveDesignator` was called from the code
that was moved. At the moment it doesn't seem to be doing anything so I
removed the calls (and no tests failed). If it proves to be needed, we
can either resolve those designators in resolve-names.cpp or pass the
`ResolveDesignator` function in to the code that needs to call it.

Differential Revision: https://reviews.llvm.org/D84768
2020-07-28 16:38:36 -07:00
Camille Coti ca0bf440db Order of libraries and source files in the f18 frontend
When the f18 frontend calls the link editor, put the libraries and object files in the correct order.

Fixes the issues reported here https://github.com/flang-compiler/flang/issues/897

Reviewed By: sscalpone, AlexisPerry

Differential Revision: https://reviews.llvm.org/D84340
2020-07-28 09:03:04 -06:00
peter klausler e57464151d [flang] Allow omission of comma in FORMAT(1PE5.2) in runtime
A comma is not required between a scale factor and a following
data edit descriptor (C1302).

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D84369
2020-07-27 15:02:54 -07:00
AlexisPerry 4a4cafabc9 [flang] Temp Driver - pass the flag to change the default integer kind through to F18_FC
fixes BUG 46307

Differential Revision: https://reviews.llvm.org/D84266
2020-07-27 09:57:34 -07:00
Valentin Clement ff25b2da2a [flang][openacc] Basic name resolution infrastructure for OpenACC construct
Reviewed By: tskeith, klausler, ichoyjx

Differential Revision: https://reviews.llvm.org/D83998
2020-07-26 20:01:35 -04:00
Tim Keith 7454acdf3b [flang] Fix implicit declarations in statement functions
If a symbol (that is not a dummy argument) is implicitly declared inside
a statement function, don't create it in the statement function's scope.
Instead, treat statement functions like blocks when finding the inclusive
scope and create the symbol there.

Add a new flag, StmtFunction, to symbols that represent statement functions.

Differential Revision: https://reviews.llvm.org/D84588
2020-07-26 12:13:39 -07:00
David Truby 4ef2e594d5 [flang] Run non-gtest unit tests with lit.
Summary:
As a corrollary, these tests are now run as part of the check-flang
target.

Reviewers: sscalpone

Subscribers: mgorny, delcypher, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D83946
2020-07-24 14:49:39 +01:00
Tim Keith 412056e2d0 [flang] Implicitly convert result of statement function
The result of a statement function may require an implicit conversion
to match its result type. Add that to the expression that represents
the statement function body in SubprogramDetails.

Extract the analysis of that expression into a separate function.

Dump the statement function expression as part of the dump of
SubprogramDetails.

Differential Revision: https://reviews.llvm.org/D84452
2020-07-23 17:15:35 -07:00
clementval aca58ef784 [flang][openacc] Add missing comment in header 2020-07-23 14:10:35 -04:00
Pete Steinfeld 83dca19c11 [flang] Fix a crash when a BOZ literal is used as a relational operator
Summary:
Expressions like `iVar==z'fe'` were causing an assertion error  because
the `Relate()` function in `Evaluate/tools.cpp` that processes
relational operators didn't deal with BOZ literals, which are typeless.
I fixed this by checking to see if the operands are BOZ literals.  If
so, if the other operand is REAL, I convert them to REAL.  Otherwise, I convert
them to integers with default kind.

I also added a test to resolve63.f90 that triggers the problem.

Reviewers: tskeith, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D83917
2020-07-23 09:14:10 -07:00
Sourabh Singh Tomar 9e4ab439c2 [flang][OpenMP] Added support for lowering OpenMP taskyield construct
Summary:
This patch lower `!OMP TASKYIELD` construct from PFT to
OpenMPDialect operations.
Construct is lowered with conformance to OpenMP 5.0 spec.

Patch is carved out of following merged PR:
https://github.com/flang-compiler/f18-llvm-project/pull/297

Reviewed: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D84350
2020-07-23 07:16:34 +05:30
Valentin Clement b27ab9ce74 [flang][openacc] Skeleton for OpenACC construct lowering
Summary:
This patch introduce the basic infrastructure to be able to lower
OpenACC constructs to the future OpenACC dialect.

Reviewers: schweitz, kiranchandramohan, DavidTruby, sscalpone, jdoerfert, ichoyjx

Reviewed By: ichoyjx

Subscribers: ichoyjx, SouraVX, mgorny, jfb, sstefan1, llvm-commits

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D84195
2020-07-22 21:34:22 -04:00
Valentin Clement 3b8ffdec07 [flang][openmp] Required clauses are allowed
Summary:
This patch fix a problem where clause needed to be in the allowed set even
they were in the required set. A required clause is allowed obvisouly. This allow
to remove the duplicate in OMP.td

Reviewers: kiranchandramohan, DavidTruby, richard.barton.arm, jdoerfert, sscalpone, kiranktp, ichoyjx

Reviewed By: kiranchandramohan

Subscribers: yaxunl, guansong, sstefan1, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D84353
2020-07-22 21:31:35 -04:00
peter klausler 3bc2ae951a [flang] Add runtime I/O APIs for COMPLEX formatted input
It turns out that COMPLEX formatted input needs its own runtime APIs
so that null values in list-directed input skip the entire COMPLEX
datum rather than just a real or imaginary part thereof.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D84370
2020-07-22 17:52:19 -07:00
Logan Smith 77e0e9e17d Reapply "Try enabling -Wsuggest-override again, using add_compile_options instead of add_compile_definitions for disabling it in unittests/ directories."
add_compile_options is more sensitive to its location in the file than add_definitions--it only takes effect for sources that are added after it. This updated patch ensures that the add_compile_options is done before adding any source files that depend on it.

Using add_definitions caused the flag to be passed to rc.exe on Windows and thus broke Windows builds.
2020-07-22 17:50:19 -07:00
Logan Smith 97a0f80c46 Revert "Try enabling -Wsuggest-override again, using add_compile_options instead of add_compile_definitions for disabling it in unittests/ directories."
This reverts commit 388c9fb1af.
2020-07-22 15:07:01 -07:00
Logan Smith 388c9fb1af Try enabling -Wsuggest-override again, using add_compile_options instead of add_compile_definitions for disabling it in unittests/ directories.
Using add_compile_definitions caused the flag to be passed to rc.exe on Windows and thus broke Windows builds.
2020-07-22 14:19:34 -07:00
Pete Steinfeld f72106e2a3 [flang] Fix an assert when RESHAPE() is called on empty strings
Summary:
When a constant array of empty strings goes through contant folding, the result
is something that contains no bytes.  If this array is passed to the intrinsic
function `RESHAPE()`, we were not handling things correctly.  I fixed this by
checking for an empty destination when calling the function `CopyFrom()` on an
array of strings.

I also added a test with a couple of different examples that trigger the
problem.

Reviewers: klausler, tskeith, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D84352
2020-07-22 12:21:58 -07:00
Louis Dionne afa1afd410 [CMake] Bump CMake minimum version to 3.13.4
This upgrade should be friction-less because we've already been ensuring
that CMake >= 3.13.4 is used.

This is part of the effort discussed on llvm-dev here:

  http://lists.llvm.org/pipermail/llvm-dev/2020-April/140578.html

Differential Revision: https://reviews.llvm.org/D78648
2020-07-22 14:25:07 -04:00
Hans Wennborg 3eec657825 Revert "Enable -Wsuggest-override in the LLVM build" and the follow-ups.
After lots of follow-up fixes, there are still problems, such as
-Wno-suggest-override getting passed to the Windows Resource Compiler
because it was added with add_definitions in the CMake file.

Rather than piling on another fix, let's revert so this can be re-landed
when there's a proper fix.

This reverts commit 21c0b4c1e8.
This reverts commit 81d68ad27b.
This reverts commit a361aa5249.
This reverts commit fa42b7cf29.
This reverts commit 955f87f947.
This reverts commit 8b16e45f66.
This reverts commit 308a127a38.
This reverts commit 274b6b0c7a.
This reverts commit 1c7037a2a5.
2020-07-22 20:23:58 +02:00
peter klausler c6cb726a8c [flang] Replay a FORMAT at the right position
When FORMAT control reaches the final parenthesis and data items
remain, we advance a record and revert to the beginning of the
FORMAT for further items.  But when the FORMAT contains any
nested parenthesized group of editing descriptors, possibly
repeated, reversion must be to the beginning of the last such
top-level parenthesized group, including its repetition count.

Reviewed By: sscalpone, PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D84281
2020-07-21 18:59:49 -07:00
peter klausler 320389e849 [flang] Fix source line continuation in potential macro calls (bugzilla 46768)
The prescanner looks for implicit continuation lines when
there are unclosed parentheses at the end of a line, so that
source preprocessing macro references with arguments that span
lines are recognized.  The condition that determines this
implicit continuation has been put into a predicate member
function and corrected to apply only when the following line
is source (not a preprocessing directive, comment, &c.).

Fixes bugzilla #46768.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D84280
2020-07-21 18:21:35 -07:00
peter klausler 8f2c5c4314 [flang] Implement byte-swapped external unformatted I/O in runtime
Add SetConvert() to the OPEN statement's runtime API.
Add ByteswapOption() to the main program's runtime API.
Check a $FORT_CONVERT environment variable, too, for
a swapping specifier.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D84284
2020-07-21 18:14:46 -07:00
peter klausler 9bb091a8fc [flang] Handle leading zeroes after decimal in REAL formatted input
Leading zero digits after the decimal mark were being dropped.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D84282
2020-07-21 18:03:24 -07:00
peter klausler 26330a0c7c [flang] Check for misplaced labels
In fixed form source, complain when a label digit appears
outside the label field & when a non-digit appears in the label
field.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D84283
2020-07-21 18:00:16 -07:00
Logan Smith 21c0b4c1e8 Disable -Wsuggest-override for all remaining unittests/ directories 2020-07-21 17:48:36 -07:00
peter klausler cbff0c75b9 [flang] Improve output from a STOP statement
Add a missing newline to IEEE FP flag formatting, and
don't neglect to emit STOP when there's no code number.

Reviewed By: tskeith

Differential Revision: https://reviews.llvm.org/D84060
2020-07-18 11:33:46 -07:00
peter klausler e79a86e45b [flang] Insert leading blanks in LOGICAL formatted output fields
Summary: For Lw output editing, emit (w-1) blanks before the T or the F.

Reviewed By: sscalpone, PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D84059
2020-07-18 10:44:16 -07:00
peter klausler b0a971d25c [flang] Prevent bogus runtime I/O error message
The runtime was requiring that STATUS='OLD' be explicitly specified
on an OPEN statement for a connected unit.  There error should issue
only if a STATUS= other than 'OLD' is specified; an OPEN with no
STATUS= specifier is okay.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D84079
2020-07-17 17:21:54 -07:00
peter klausler 8305a92a47 [flang] Treat tabs like spaces in formatted input.
Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D84078
2020-07-17 17:19:20 -07:00
peter klausler 8e2b4e50f2 [flang] Support <name>=<integer> syntax in compiler directives
Accept name=value as part of a !DIR$ compiler directive.  These
are currently ignored in semantics, but we should recognize
more directive forms to facilitate testing.  In due course,
these placeholding directive parsers will be replaced.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D84077
2020-07-17 17:05:38 -07:00
peter klausler cf2274b779 [flang] Allow ! and // comments after some preprocessing directives
Old-style C /*comments*/ are omitted from preprocessor directive
token sequences by the prescanner, but line-ending C++ and Fortran
free-form comments are not since their handling might depend on
the directive.  Add code to skip these line-ending comments as
appropriate in place of existing code that just skipped blanks.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D84061
2020-07-17 15:28:22 -07:00
peter klausler ea4758a125 [flang] Rework read/write permission management for runtime file opening
Anonymous Fortran unit files (e.g., "./fort.7") need to be created
O_RDWR so that they can be written, rewound, and read.  Other
files opened with no ACTION= specifier need to set read/write
permissions based on the file, if it exists.

Reviewed By: sscalpone

Differential Revision: https://reviews.llvm.org/D84063
2020-07-17 14:44:58 -07:00