Commit Graph

2564 Commits

Author SHA1 Message Date
peter klausler 0e9e06a6d4 [flang][NFC] Reformat files with current clang-format
Differential Revision: https://reviews.llvm.org/D85489
2020-08-07 12:10:26 -07:00
Tim Keith cf03bcf929 [flang] Remove extra CMAKE_CXX_FLAGS in Lower and Optimizer
`-Wno-error` and `-Wno-unused-parameter` appear to no longer be needed
for Lower and Optimizer.

Differential Revision: https://reviews.llvm.org/D85465
2020-08-07 10:21:54 -07:00
Tim Keith d8713523a2 [flang] Improve message for assignment to subprogram
In the example below we were producing the error message
"Assignment to constant 'f' is not allowed":
```
function f() result(r)
  f = 1.0
end
```

This changes it to a more helpful message when the LHS is a subprogram
name and also mentions the function result name when it's a function.

Differential Revision: https://reviews.llvm.org/D85483
2020-08-06 20:34:00 -07:00
Michael Kruse f81bae9ff4 [flang][msvc] Do not use gcc/clang command line options for msvc.
The command line options `-Wno-error` and `-Wno-unused-parameter` are specific to gcc/clang, do not use them when compiling with other compilers.

This patch is part of the series to [[ http://lists.llvm.org/pipermail/flang-dev/2020-July/000448.html | make flang compilable with MS Visual Studio ]].

Reviewed By: isuruf

Differential Revision: https://reviews.llvm.org/D85355
2020-08-06 15:46:52 -05:00
Tim Keith 08c7d570d3 [flang] Add options to control IMPLICIT NONE
Add `-fimplicit-none-type-always` to treat each specification-part
like it has `IMPLICIT NONE`. This is helpful for enforcing good Fortran
programming practices. We might consider something similar for
`IMPLICIT NONE(EXTERNAL)` as well.

Add `-fimplicit-none-type-never` to ignore occurrences of `IMPLICIT NONE`
and `IMPLICIT NONE(TYPE)`. This is to handle cases like the one below,
which violates the standard but it accepted by some compilers:
```
subroutine s(a, n)
  implicit none
  real :: a(n)
  integer :: n
end
```

Differential Revision: https://reviews.llvm.org/D85363
2020-08-06 06:48:01 -07:00
Irina Dobrescu e355f85bdf [flang] Add parser support for OpenMP allocate clause
Differential Revision: https://reviews.llvm.org/D85212
2020-08-06 10:45:34 +01:00
Tim Keith 6d2d73059f [flang] Fix compilation warning in check-directive-structure.h
Clang 9 gets the following warning after revision `D85104`.
```
../../flang/lib/Semantics/check-directive-structure.h:36:7: error: 'Fortran::semantics::DirectiveStructureChecker<llvm::omp::Directive, llvm::omp::Clause, Fortran::parser::OmpClause, 77>' has virtual functions but non-virtual destructor [-Werror,-Wnon-virtual-dtor]
```

The fix is the make the destructor virtual. Neither it nor the
constructor need to be public, so make them protected.

Differential Revision: https://reviews.llvm.org/D85383
2020-08-05 18:03:41 -07:00
Valentin Clement 40626184cf [flang][NFC] Unify OpenMP and OpenACC structure checker
This patch remove duplicated code between the check-omp-structure and the check-acc-structure
and unify it into a check-directive-structure templated class.

Reviewed By: kiranchandramohan, sscalpone, ichoyjx

Differential Revision: https://reviews.llvm.org/D85104
2020-08-05 14:25:49 -04:00
Andrzej Warzynski 621681e3e5 [Flang] Fix multi-config generator builds
Based on https://reviews.llvm.org/D84022 with additional changes to
maintain out-of-tree builds.

Original commit message:
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.

The original patch was implemented by David Truby and the additional
changes added here were also proposed by David Truby.

Differential Revision: https://reviews.llvm.org/D85078/

Co-authored-by: David Truby <david.truby@arm.com>
2020-08-05 08:59:11 +01:00
Rahul Joshi 1d6a724aa1 [MLIR] Change FunctionType::get() and TupleType::get() to use TypeRange
- Moved TypeRange into its own header/cpp file, and add hashing support.
- Change FunctionType::get() and TupleType::get() to use TypeRange

Differential Revision: https://reviews.llvm.org/D85075
2020-08-04 12:43:40 -07:00
peter klausler 675ad1bc6a [flang] Implement runtime support for INQUIRE statements
Differential Revision: https://reviews.llvm.org/D85166
2020-08-03 17:15:08 -07:00
peter klausler d879ac8a6e [flang] Defer "next input record" processing until handlers established
External input was detecting "end of file" conditions in
BeginExternal...Input() and BeginUnformattedInput() routines
before EnableHandlers() could have been called.  Defer the
"start next record" processing to the input data item
handlers (and EndIoStatement() for when there are no data
items).

Differential Revision: https://reviews.llvm.org/D85161
2020-08-03 16:44:37 -07:00
peter klausler d8334c4360 [flang] Acquire file accessibility, size, positioning
Extend the raw file wrapper to get accessibility, positioning,
and size information.  This is needed for INQUIRE (to follow).

Differential Revision: https://reviews.llvm.org/D85160
2020-08-03 16:42:48 -07:00
peter klausler 49bbb8b60e Remove unneeded RoundDefault enumerator, and fix spelling in comments 2020-08-03 16:14:24 -07:00
peter klausler 7c5630fe99 [flang] Handle spaces (more) correctly in REAL input
Fixes problems in FCVS test fm110.f.
Add more comments, too.

Differential Revision: https://reviews.llvm.org/D85163
2020-08-03 16:12:30 -07:00
peter klausler 089adc339e [flang] Make preprocessing behavior tests runnable as regression tests
And fix a minor bug exposed by doing so.

Differential Revision: https://reviews.llvm.org/D85164
2020-08-03 15:07:38 -07:00
Tim Keith 0d454e8e08 [flang] Fix bug detecting intrinsic function
Don't set the INTRINSIC attribute on a dummy procedure.

Differential Revision: https://reviews.llvm.org/D85136
2020-08-03 12:21:59 -07:00
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