Commit Graph

2473 Commits

Author SHA1 Message Date
Mehdi Chinoune 4198874630 [flang] Replace ATTRIBUTE_UNUSED with LLVM_ATTRIBUTE_UNUSED
ATTRIBUTE_UNUSED wasn't defined with MSVC.

Patch by: Mehdi Chinoune <chinoune.mehdi@hotmail.com>

Differential Revision: https://reviews.llvm.org/D78356
2020-06-25 19:53:19 +01:00
Eric Schweitz 84f3805805 [flang] add RTBuilder.h
This is a set of type building models that is specific to the lowering
process. It provides the mechanism of mapping C(++) header file interfaces
to the MLIR+FIR type system.

It also provides some macros to build a constexpr evaluated table to
runtime functions. This code is used to build the interface tables to
various runtime support libraries.

Differential revision: https://reviews.llvm.org/D82387
2020-06-23 14:54:45 -07:00
Eric Schweitz a9c478acd0 add copy of MLIR .clang-tidy to squelch noise in phabricator reviews 2020-06-22 15:26:28 -07:00
Tim Keith 663860f63e [flang] Fix bug checking SAVE attribute
Treat function result like dummy argument: a SAVE statement without an
entity-list does not make it saved.

Differential Revision: https://reviews.llvm.org/D82309
2020-06-22 11:33:04 -07:00
peter klausler 16d24e4543 [flang] Shape analysis for result of MATMUL
Implement shape analysis for the result of the MATMUL
generic transformational intrinsic function, based on
the shapes of its arguments.  Correct the names of the
arguments to match the standard, too.

Reviewed By: PeteSteinfeld
Differential Revision: https://reviews.llvm.org/D82250
2020-06-22 09:45:30 -07:00
Eric Schweitz 3a84d84adc [flang] Finish adding AbstractConverter.h
This adds the abstract converter interface. The abstract converter is an
interface that supports the conversion of front-end data structures to
MLIR. This interface will be instantiated by the bridge in a future
commit.

Differential revision: https://reviews.llvm.org/D82268
2020-06-22 08:18:15 -07:00
sameeran joshi fa5d416efd [flang]Fix individual tests with lit when building out of tree
Summary:

Fix individual check tests with lit when building out-of-tree
`ninja check-flang-<folder>` was not working.
The CMakeLists.txt was looking for the lit tests in the source directory
instead of the build directory.

This commit extends @CarolineConcatto previous patch[D81002]

Reviewers: DavidTruby, sscalpone, tskeith, CarolineConcatto, jdoerfert

Reviewed By: DavidTruby

Subscribers: flang-commits, llvm-commits, CarolineConcatto

Tags: #flang, #llvm

Differential Revision: https://reviews.llvm.org/D82120
2020-06-22 10:30:33 +05:30
Eric Schweitz b938eaec55 [flang] Add BoxValue.h
The bridge uses internal boxes of related ssa-values to track all the
information associated with a Fortran variable. Variables may have a
location and a value, but may also carry other properties such as rank,
shape, LEN parameters, etc. in Fortran.

Differential revision: https://reviews.llvm.org/D82228
2020-06-20 14:13:14 -07:00
Eric Christopher 64b04e4754 Temporarily Revert "[flang][OpenMP] Enhance parser support for flush construct to OpenMP 5.0"
as it's failing Semantics/omp-clause-validity01.f90.

This reverts commit b32401464f.
2020-06-20 01:18:53 -07:00
Kiran Kumar T P b32401464f [flang][OpenMP] Enhance parser support for flush construct to OpenMP 5.0
Summary:
This patch enhances parser support for flush construct to OpenMP 5.0 by including memory-order-clause.

2.18.8 flush Construct
	!$omp flush [memory-order-clause] [(list)]
		where memory-order-clause is
		acq_rel
		release
		acquire

The patch includes code changes and testcase modifications.

Reviewed By: klausler, kiranchandramohan

Differential Revision: https://reviews.llvm.org/D82177
2020-06-20 13:33:29 +05:30
peter klausler 0df6f8fe8e [flang] Fix F5.3 formatting of 0.025
Fix F output editing in the Fortran runtime so that it
respects the 'd' count of digits after the decimal mark.

Reviewed By: tskeith

Differential Revision: https://reviews.llvm.org/D82242
2020-06-19 18:09:10 -07:00
peter klausler a20d48d7d3 [flang] DATA stmt processing (part 4/4): Check & convert DATA
Implement rest of DATA statement semantics and conversion of
DATA statement initializations into static initializers of
objects in their symbol table entries.

Reviewed By: tskeith, PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D82207
2020-06-19 13:26:20 -07:00
Eric Schweitz b5d51c2448 [flang] Add SymbolMap
The symbol map is a data structure for tracking variables in a subprogram during the lowering of that subprogram to FIR/MLIR. These data structures will be used by the bridge, which has not been upstreamed yet.

Differential revision: https://reviews.llvm.org/D82140
2020-06-19 11:47:58 -07:00
peter klausler 4171f80d54 [flang] DATA stmt processing (part 3/4): Remaining prep work
Rolls up small changes across the frontend to prepare for the large
forthcoming patch (part 4/4) that completes DATA statement processing
via conversion to initializers.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D82137
2020-06-19 09:09:05 -07:00
peter klausler 286d7a2159 [flang] DATA statement processing (part 2/4): Initial images
Summary:
Defines a representation for the initialized memory image of
a variable.  This image is populated by DATA statement
processing as designator elements are put into correspondence
with values, then converted into an initializer in the symbol
table so that lowering can pass the initial image to the
code generator.

Reviewers: tskeith, PeteSteinfeld, sscalpone, jdoerfert, DavidTruby

Reviewed By: tskeith

Subscribers: mgorny, llvm-commits, flang-commits

Tags: #flang, #llvm

Differential Revision: https://reviews.llvm.org/D82131
2020-06-18 17:13:59 -07:00
peter klausler d1862eb845 [flang] DATA stmt processing (part 1/4): designator folding
Summary:
Add code to resolve constant Designators at compilation time
into a base Symbol, byte offset, and field size.  This is used in
later DATA statement processing to identify the static storage being
initialized by each object in a DATA statement.  Also implement
the reverse mapping so that Designators can be reconstructed for
use in error messages about (e.g.) duplicate initializers.

Reviewers: tskeith, PeteSteinfeld, sscalpone, jdoerfert, DavidTruby

Reviewed By: PeteSteinfeld

Subscribers: mgorny, llvm-commits, flang-commits

Tags: #flang, #llvm

Differential Revision: https://reviews.llvm.org/D82125
2020-06-18 15:25:21 -07:00
peter klausler 2750556551 [flang] Roll up small fixes to runtime bugs found in testing
Summary:
Fix several bugs in the Fortran runtime found in initial
testing.

Reviewers: tskeith, PeteSteinfeld, sscalpone, jdoerfert, DavidTruby

Reviewed By: tskeith, PeteSteinfeld

Subscribers: llvm-commits, flang-commits

Tags: #flang, #llvm

Differential Revision: https://reviews.llvm.org/D82116
2020-06-18 14:25:04 -07:00
peter klausler 3aee64a9e0 [flang] Fix build problems on osx
Summary:
Fix build problems encountered on osx in two files.
The one in character.cpp fixes a legitimate bug that
elicited a valid warning.

Reviewers: tskeith, PeteSteinfeld, sscalpone, jdoerfert, DavidTruby

Reviewed By: tskeith, PeteSteinfeld

Subscribers: llvm-commits, flang-commits

Tags: #flang, #llvm

Differential Revision: https://reviews.llvm.org/D82107
2020-06-18 11:14:25 -07:00
Pete Steinfeld 3ed2909feb [flang] Fix crash with alternate returns in modules
Summary:
We weren't handling the case of subroutines with alternate returns that
are contained in modules.  I changed the code to add an `*` as the name
of the parameter when creating the `.mod` file.

Reviewers: tskeith, klausler, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D82096
2020-06-18 08:56:12 -07:00
Jean Perier f1fa3b7f6e [flang] AMAX0, MIN1... rewrite to MAX/MIN: make result conversion explicit
Summary:
This patch changes speficic extremum functions rewrite to generic MIN/MAX.
It applies to AMAX0, AMIN0, AMAX1, AMIN1, MAX0, MIN0, MAX1, MIN1, DMAX1,
and DMIN1.

- Do not re-write specific extremums to MAX/MIN in intrinsic Probe and let
folding rewrite it and introduc the conversion on the MIN/MAX result.
- Also make operand promotion explicit in MIN/MAX folding.

For instance, after this patch:
AMAX0(int8, int4) is rewritten to REAL(MAX(int8, INT(int4, 8)))

All this care is to avoid rewritting it to MAX(REAL(int8), REAL(int4))
that may not always be numerically equivalent to the first rewrite.

Reviewers: klausler, schweitz, sscalpone, jdoerfert, DavidTruby

Reviewed By: klausler, schweitz

Subscribers: llvm-commits, flang-commits

Tags: #flang, #llvm

Differential Revision: https://reviews.llvm.org/D81940
2020-06-18 08:14:58 +02:00
peter klausler 3d627d6ff9 [flang] More Fortran runtime support for CHARACTER operations
Summary:
- Remove C++ library dependence from lock.h
- Implement LEN_TRIM, REPEAT, ADJUSTL, ADJUSTR, MAX/MIN
  intrinsic functions for CHARACTER

Reviewers: tskeith, PeteSteinfeld, sscalpone, schweitz, DavidTruby

Reviewed By: PeteSteinfeld

Subscribers: llvm-commits, flang-commits

Tags: #flang, #llvm

Differential Revision: https://reviews.llvm.org/D82054
2020-06-17 15:51:48 -07:00
Eric Schweitz b46e2548b6 [flang] Fix fallout from varous changes to the cmake files.
Differential revision: https://reviews.llvm.org/D82050
2020-06-17 14:40:05 -07:00
Tim Keith f392b75fd8 [flang] Fix out-of-tree builds
Replace two MLIR dependencies with MLIRLinalgOps.

Differential Revision: https://reviews.llvm.org/D82038
2020-06-17 12:02:00 -07:00
Eric Schweitz 30db177693 [flang] Upstream the Mangler module from lowering.
This upstreams the internal name mangling used in the bridge to generate
unique names from symbols.

Replace InternalNamesTest with the actual, functional unittest.

Differential revision: https://reviews.llvm.org/D81764
2020-06-16 15:24:13 -07:00
sameeran joshi 93f602b339 [flang] unit test support for out-of-tree and in-tree using google tests framework
Review comments addressed.
2020-06-15 22:09:56 +05:30
David Truby 9362698450 [flang] Change DIE("unreachable") cases to use llvm_unreachable
Reviewers: sscalpone

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79507
2020-06-15 17:21:35 +01:00
Eric Schweitz 4741835e03 [flang] Add the helper class for building fir.do_loop operations. A fir.do_loop models the semantics of a Fortran DO loop construct. One can use this operation to explicitly capture a DO loop for passing into the high-level optimizer.
Differential revision: https://reviews.llvm.org/D81692
2020-06-12 17:28:00 -07:00
Pete Steinfeld bb2f6f66c7 [flang] Added test for specification expressions
I added a test the exercises all of the cases instances of specification expressions as defined in section 10.1.11.

Summary: [flang] Added test for specification expressions

Reviewers: tskeith, klausler, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D81759
2020-06-12 15:13:24 -07:00
peter klausler a0226f9bff [flang] Dodge bogus uninitialized data warning from gcc 10.1 via code cleanup
G++ 10.1 emits inappropriate "use of uninitialized data" warnings when
compiling f18.  The warnings stem from two sites in templatized code
whose multiple instantiations magnified the number of warnings.

These changes dodge those warnings by making some innocuous changes to
the code.  In the parser, the idiom defaulted(cut >> x), which yields a
parser that always succeeds, has been replaced with a new equivalent
pass<T>() parser that returns a default-constructed value T{} in an
arguably more readable fashion.  This idiom was the only attestation of
the basic parser cut, so it has been removed and the remaining code
simplified.  In Evaluate/traverse.h, a return {}; was replaced with a
return of a default-constructed member.

Differential Revision: https://reviews.llvm.org/D81747
2020-06-12 10:05:05 -07:00
sameeran joshi 70ad73b6b7 [flang] Semantics for SELECT TYPE
Summary:
    Added support for all semantic checks except C1157
    was previously implemented.

    Address review comments.

    Reviewers: PeteSteinfeld, tskeith, klausler, DavidTruby, kiranktp, anchu-rajendran, sscalpone

    Subscribers: kiranchandramohan, llvm-commits, flang-commits

    Tags: #llvm, #flang

    Differential Revision: https://reviews.llvm.org/D79851
2020-06-12 00:12:24 +05:30
Eric Schweitz 8bba0bca72 [flang] Add the complex expression helper class.
The complex expression helper class can be used to generate small,
short-lived instances of a "helper" that can be used to aid the
construction of complex expressions in FIR. The helper class bundles
together these functionally related operations.

Included in this diff is the header for the FIR builder. The
implementation has other dependences and will follow.

Differential Revision: https://reviews.llvm.org/D81287
2020-06-10 09:05:20 -07:00
Tim Keith a27d385209 [flang] Fix bug resolving type in type definition
When we encountered a type name in a derived type definition, we were
sometimes finding a component of that name rather than the type from
the enclosing scope. Fix this by introducing `NonDerivedTypeScope()` to
start the search in the right scope.

Differential Revision: https://reviews.llvm.org/D81493
2020-06-09 14:14:03 -07:00
Valentin Clement 38674030c0 Apply fix from D81179 only from GCC < 8
Summary: Apply workaround done in D81179 only for GCC < 8. As @klausler mentioned in D81179 we want to avoid additional checks for other compilers that do not need them.

Reviewers: DavidTruby, klausler, jdoerfert, sscalpone

Reviewed By: klausler, sscalpone

Subscribers: llvm-commits, tskeith, isuruf, klausler

Tags: #flang, #llvm

Differential Revision: https://reviews.llvm.org/D81208
2020-06-08 15:51:57 -04:00
Isuru Fernando bb73d1b278 [flang] Fix issue of flang/runtime/config.h not being found in out of tree builds
Summary: Fixes https://bugs.llvm.org/show_bug.cgi?id=46078

Reviewers: DavidTruby, jdoerfert, PeteSteinfeld, sscalpone, tskeith

Reviewed By: PeteSteinfeld, sscalpone, tskeith

Subscribers: mgorny, llvm-commits, tskeith

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D81266
2020-06-08 14:16:08 -05:00
Isuru Fernando 3862cbbc65 [flang] Use LLVM's flags
Summary:
The only difference is that LLVM_ENABLE_WERROR is set to OFF
by default, but we enable this in a standalone flang build

This commit fixes some windows issues with the flags

Reviewers: DavidTruby, jdoerfert, sscalpone

Reviewed By: DavidTruby, sscalpone

Subscribers: ormris, richard.barton.arm, mehdi_amini, Meinersbur, ChinouneMehdi, tskeith, mgorny, llvm-commits

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D78306
2020-06-08 15:29:52 +01:00
Pete Steinfeld 4d8c00c059 [flang] Fix crash on erroneous expressions
Summary:
If you create an expression with parse errors, the `parser::Expr.typedExpr`
will be empty, which causes a compiler crash.  The crash is caused by the
check in check-do-forall.cpp that scans all expresssions to see if `DO`
variables are being modified.

It turned out that the problem was that I was fetching subexpressions of type
`parser::Expr`, which are not guaranteed to have a non-null `typedExpr`.  I
fixed this by only grabbing the top-level expression from which to gather
arguments as part of the DO loop analysis.  This, in turn, exposed a problem
where I wasn't collecting all of the actual arguments in an expression.  This
was caused by the fact that I wasn't recursing through the rest of the
expression after finding an argument.  I fixed this by recursing through the
argument in the member function in `CollectActualArgumentsHelper`.

Reviewers: klausler, tskeith, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D81101
2020-06-05 08:46:43 -07:00
Pete Steinfeld 1746c8ed26 [flang] Fixed crash on forward referenced `len` parameter
Summary:
Using a forward reference to define a `len` parameter causes a crash.
The underlying cause was that a previously declared type had an
erroneous expression for its `LEN` param value.  When this expression
was referenced to evaluate a subsequent expression, bad things happened.
I fixed this by putting in code to detect this case.

Reviewers: tskeith, klausler, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D80593
2020-06-04 13:12:11 -07:00
Eric Schweitz baa12ddb6f [flang] Add the conversions for types.
Part of lowering is to convert the front-end types to their FIR dialect representations.  These conversions are done by here in the ConvertType module.

proactively update the code to conform better with LLVM coding conventions

Differential Revision: https://reviews.llvm.org/D81034
2020-06-04 12:54:50 -07:00
Valentin Clement 3d9bb031d1 [flang] avoid GCC < 8 compiler failure after D80794
Summary:
Patch D80794 remove the custom flags for release build for flang.
This leads to build failure with GCC < 8. This patch add upperbound check
in order to avoid the -Werror=array-bounds to trigger a build failure.

```
/home/4vn/versioning/llvm-project/flang/lib/Decimal/big-radix-floating-point.h:183:29: error: array subscript is above array bounds [-Werror=array-bounds]
           digit_[j] = digit_[j + remove];
                       ~~~~~~^
/home/4vn/versioning/llvm-project/flang/lib/Decimal/big-radix-floating-point.h:183:29: error: array subscript is above array bounds [-Werror=array-bounds]
           digit_[j] = digit_[j + remove];
                       ~~~~~~^
/home/4vn/versioning/llvm-project/flang/lib/Decimal/big-radix-floating-point.h:183:29: error: array subscript is above array bounds [-Werror=array-bounds]
           digit_[j] = digit_[j + remove];
                       ~~~~~~^
/home/4vn/versioning/llvm-project/flang/lib/Decimal/big-radix-floating-point.h:183:29: error: array subscript is above array bounds [-Werror=array-bounds]
           digit_[j] = digit_[j + remove];
                       ~~~~~~^
/home/4vn/versioning/llvm-project/flang/lib/Decimal/big-radix-floating-point.h:183:29: error: array subscript is above array bounds [-Werror=array-bounds]
           digit_[j] = digit_[j + remove];
```

```
/home/4vn/versioning/llvm-project/flang/include/flang/Evaluate/integer.h:809:28: error: array subscript is above array bounds [-Werror=array-bounds]
               xy += product[to];
                     ~~~~~~~^
/home/4vn/versioning/llvm-project/flang/include/flang/Evaluate/integer.h:810:22: error: array subscript is above array bounds [-Werror=array-bounds]
               product[to] = xy & partMask;
               ~~~~~~~^
/home/4vn/versioning/llvm-project/flang/include/flang/Evaluate/integer.h:809:28: error: array subscript is above array bounds [-Werror=array-bounds]
               xy += product[to];
                     ~~~~~~~^
```

Reviewers: DavidTruby, sscalpone, jdoerfert

Reviewed By: DavidTruby

Subscribers: llvm-commits

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D81179
2020-06-04 14:48:39 -04:00
Jean Perier 62b127eef6 [flang] Fix IsConstantExpr for division expressions
Summary:
Fortran::evaluate::IsConstantExpr did not check that the numerator
was a constant expression. This patch fixes the issue.

Reviewers: DavidTruby, klausler, schweitz, PeteSteinfeld, jdoerfert, sscalpone

Reviewed By: klausler, PeteSteinfeld, sscalpone

Subscribers: llvm-commits

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D81096
2020-06-04 09:44:44 +02:00
Anchu Rajendran 70f1b4b412 [flang] Implemented 2 Semantic checks for DATA statement and fixed a few bugs
Summary
  - Implemented C876, C877
  - Fixed IsConstantExpr to check C879
  - Fixed bugs in few test cases - data01.f90, block-data01.f90,
  pre-fir-tree02.f90
  - Modified implementation of C8106 to identify all automatic objects
  and modified equivalence01.f90 to reflect the changes

Differential Revision: https://reviews.llvm.org/D78424
2020-06-03 10:33:26 +05:30
David Truby 81bf1e29aa [flang] Fix release build flags.
Summary:
This patch removes the custom CMAKE_RELEASE_CXX_FLAGS variable.
This variable being set was having the effect of removing other important
Release flags, notably `-DNDEBUG`.

This patch may need to be accompanied by fixes for the macOS issues that
the removed comment mentions; I don't have a mac to test this on though so
hopefully a reviewer can help with that.

Reviewers: Andrzej, tskeith, sscalpone

Subscribers: mgorny, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D80794
2020-06-02 16:29:12 +01:00
Eric Schweitz ae6e499d25 [flang] This adds the lowering stubs for Open MP.
The lowering bridge will call these lowering hooks to process the Open
MP directives that it iterates over in the PFT.  This is a mock
interface without an implementation in this patch.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D80815
2020-06-01 09:11:53 -07:00
Tim Keith 14f49599cc [flang][NFC] Remove link-time dependency of Evaluate on Semantics
Summary:
Some Symbol-related functions used in Evaluate were moved to
Evaluate/tools.h. This includes changing some member functions that were
replaced by non-member functions `IsDummy`, `GetUsedModule`, and
`CountLenParameters`.

Some member functions were made inline in `Scope`, `Symbol`,
`ArraySpec`, and `DeclTypeSpec`. The definitions were preceded by a
comment explaining why they are inline.

`IsConstantShape` was expanded inline in `IsDescriptor` because it isn't
used anywhere else

After this change, at least when compiling with clang on macos,
`libFortranEvaluate.a` has no undefined symbols that are satisfied by
`libFortranSemantics.a`.

Reviewers: klausler, PeteSteinfeld, sscalpone, jdoerfert, DavidTruby

Reviewed By: PeteSteinfeld

Subscribers: llvm-commits

Tags: #flang, #llvm

Differential Revision: https://reviews.llvm.org/D80762
2020-05-29 16:39:14 -07:00
Eric Schweitz fbac9ce226 [flang] Batch together the changes to the PFT intermediate data
structure for upstreaming to llvm-project.

These files have had many changes since they were originally upstreamed.
Some of the changes are cosmetic.  Most of the functional changes were
done to support the lowering of control-flow syntax from the front-end
parse trees to the FIR dialect.

This patch is meant to be a reviewable size. The functionality it
provides will be used by code yet to be upstreamed in lowering.

review comments:

[review D80449][NFC] make PFT ParentVariant a ReferenceVariant

ReferenceVariant had to be slightly updated to also support
non constant references (which is required for ParentType).

[review D80449] extend Variable implementation beyond a comment
2020-05-29 15:24:20 -07:00
Pete Steinfeld c4dbe59ae8 [flang] Fixes for problems with declaring procedure entities
Summary:
We were not detecting declaring multiple interfaces to the same procedure.
Also, we were not handling the initialization of entitiies where the associated
Symbol had previously had errors.

I added the function `IsInterfaceSet()` to ProcEntityDetails to see if
the value of `interface_` had been previously set.  I then checked  this
function before calling set_interface() and emitted an error message if
the interface was already set.

Also, in situations where we were emitting error messages for symbols, I
set the Error flag on the Symbol.  Then when performing initialization
on the Symbol, I first check to see if the Symbol had an error.

Reviewers: tskeith, klausler, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D80453
2020-05-26 12:17:20 -07:00
Pete Steinfeld 38095549c6 [flang] Constraint checks C751 to C760
Summary:
Many of these were already implemented, and I just annotated the tests and/or
the code.

C752 was a simple check to verify that CONTIGUOUS components are arrays with

C754 proved to be virtually identical to C750 that I implemented previously.
This caused me to remove the distinction between specification expressions for
type parameters and bounds expressions that I'd previously created.
the POINTER attribute.

I also changed the error messages to specify that errors in specification
expressions could arise from either bad derived type components or type
parameters.

In cases where we detect a type param that was not declared, I created a symbol
marked as erroneous.  That avoids subsequent semantic process for expressions
containing the symbol.  This change caused me to adjust tests resolve33.f90 and
resolve34.f90.  Also, I avoided putting out error messages for erroneous type
param symbols in `OkToAddComponent()` in resolve-names.cpp and in
`EvaluateParameters()`, type.cpp.

C756 checks that procedure components have the POINTER attribute.

Reviewers: tskeith, klausler, DavidTruby

Subscribers: llvm-commits

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D79798
2020-05-15 18:50:14 -07:00
Eric Christopher b1ae13b4e9 Fix flang build after mlir SideEffects.h -> SideEffectInterfaces.h change. 2020-05-15 15:51:32 -07:00
Alex Zinenko 4ead2cf76c [mlir] Rename conversions involving ex-Loop dialect to mention SCF
The following Conversions are affected: LoopToStandard -> SCFToStandard,
LoopsToGPU -> SCFToGPU, VectorToLoops -> VectorToSCF. Full file paths are
affected. Additionally, drop the 'Convert' prefix from filenames living under
lib/Conversion where applicable.

API names and CLI options for pass testing are also renamed when applicable. In
particular, LoopsToGPU contains several passes that apply to different kinds of
loops (`for` or `parallel`), for which the original names are preserved.

Differential Revision: https://reviews.llvm.org/D79940
2020-05-15 10:45:11 +02:00
Valentin Clement 85725a67c7 [Flang][OpenMP] Avoid abort when collapse clause value is negative
Summary:
If the value in the collapse close is negative f18 abort without the correct error message. This PR change the size_t in name resolution to a int64_t and check appropriately for negative or zero before the privatization of induction variable.
The correct error is then catch by the OpenMP structure check.

This diff is migrated from the GitHub pull request https://github.com/flang-compiler/f18/pull/1098

Reviewers: ichoyjx, jdoerfert, sscalpone, DavidTruby

Reviewed By: ichoyjx, sscalpone, DavidTruby

Subscribers: sscalpone, klausler, yaxunl, guansong, llvm-commits

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D77821
2020-05-14 21:37:25 -04:00
Stephen Neuendorffer 661b234cbc [MLIR] Rename SideEffects.td -> SideEffectInterfaces.td
This normalize the name of the tablegen file with the name of the generated
files (SideEffectInterfaces.h.inc) and the other Interface tablegen files,
which all end in Interface(s).td

Differential Revision: https://reviews.llvm.org/D79517
2020-05-12 12:21:42 -07:00
Tim Keith 6f300105d2 [flang] Fix bug with IMPORT of USE of USE
When a module contained an import of a use-association of a
use-association, we weren't recognizing that the symbols was needed.
The fix is the follow all of the use-associations using `GetUltimate()`.

Differential Revision: https://reviews.llvm.org/D79737
2020-05-11 13:28:07 -07:00
Tim Keith 99aa87a5b5 [flang][NFC] Simplify semantics test scripts
There were several different ways of handling the option to f18 to
find predefined modules:
- test_errors.sh was created by cmake substituting
  FLANG_INTRINSIC_MODULES_DIR into test_errors.sh.in
- some tests used the flang script which has the option built it
- some tests used %f18_with_includes which was replaced by the path
  to f18 plus the -I option
- some included -I../../include/flang in their run command

To make this more consistent, change %f18 to include the
-intrinsic-module-directory option and use it everywhere, including
to replace %flang and %f18_with_includes. This requires changing all
of the invocations of the test scripts to put %f18 at the end so that
it can expand to more than one argument.

This eliminates the need to generate test_errors.sh which means we
don't need flang/test/Semantics/CMakeLists.txt or the %B substitution.
That makes the test_errors.sh command like the others, replacing
%B/test/Semantics/test_errors.sh with %S/test_errors.sh.

Also remove the OPTIONS: functionality as custom options can be included
in the RUN: command. And remove -I/../../include/flang as that is now
always included.

Differential Revision: https://reviews.llvm.org/D79634
2020-05-11 11:49:25 -07:00
Valentin Clement 63a4fdda8c [flang] Fix compilation after rename of Loop dialect to scf
Summary: Flang was not compiling correctly after the renaming of Loop dialect to SCF. This patch fixes the problem.

Reviewers: ftynse, DavidTruby

Reviewed By: ftynse

Subscribers: aartbik, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79723
2020-05-11 13:15:33 -04:00
Tim Keith b05c8c5756 [flang] Make implicit conversion explicit in assignment
When intrinsic types are assigned there are some implicit conversions
that take place. This change make them explicit in the types
representation of assignments.

Differential Revision: https://reviews.llvm.org/D79637
2020-05-09 09:11:00 -07:00
sameeran joshi 332e6aea37 [flang]Semantics for SELECT RANK.
Summary:
    Initially on github I worked on semantic checks.Then I tried some compile-time
    test of the rank value, they were failing as there were no symbols
    generated for them inside SELECT RANK's scope.So I went further to
    add new symbol in each scope, also added the respective 'rank: '
    field for a symbol when we dump the symboltable. I added a field to
    keep track of the rank in AssocEntityDetails class.This caused shape
    analysis framework to become inconsistent. So shape analysis framework
    was updated to handle this new representation.

	 *   I added more tests for above changes.

	 *   On phabricator I addressed some minor changes.

	 *   Lastly I worked on review comments.

    Reviewers: klausler,sscalpone,DavidTruby,kiranchandramohan,tskeith,anchu-rajendran,kiranktp

    Reviewed By:klausler, DavidTruby, tskeith

    Subscribers:#flang-commits, #llvm-commits

    Tags: #flang, #llvm

    Differential Revision: https://reviews.llvm.org/D78623
2020-05-08 08:52:31 +05:30
Jacques Pienaar 5eae715a31 [mlir] Add NamedAttrList
This is a wrapper around vector of NamedAttributes that keeps track of whether sorted and does some minimal effort to remain sorted (doing more, e.g., appending attributes in sorted order, could be done in follow up). It contains whether sorted and if a DictionaryAttr is queried, it caches the returned DictionaryAttr along with whether sorted.

Change MutableDictionaryAttr to always return a non-null Attribute even when empty (reserve null cases for errors). To this end change the getter to take a context as input so that the empty DictionaryAttr could be queried. Also create one instance of the empty dictionary attribute that could be reused without needing to lock context etc.

Update infer type op interface to use DictionaryAttr and use NamedAttrList to avoid incurring multiple conversion costs.

Fix bug in sorting helper function.

Differential Revision: https://reviews.llvm.org/D79463
2020-05-07 12:33:36 -07:00
sameeran joshi cc4768f2ec [flang]Add examples in documentation/BijectiveInternalNameUniquing.md
Summary:
    I thought it would be simpler to understand on how the unique names would
    look like when an example is present. So I added some examples.

    I found 2 such places to add examples
    -Common blocks
    -Module scope global data

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

    Reviewed By: schweitz, jeanPerier

    Subscribers: llvm-commits, flang-commits

    Tags: #flang, #llvm

    Differential Revision: https://reviews.llvm.org/D79442
2020-05-08 00:01:35 +05:30
Tim Keith 7ccc7e5672 [flang] Fix to IsDescriptor
IsDescriptor was returning false for a component whose shape depended
on a length parameter. Change it to return true for any array with
non-constant bounds.

Differential Revision: https://reviews.llvm.org/D79349
2020-05-07 07:51:45 -07:00
Tim Keith 54b35c0664 [flang][NFC] Replace "align" with "alignment"
In the places it is used as a noun, replace "align" with "alignment".

Differential Revision: https://reviews.llvm.org/D79520
2020-05-06 15:03:30 -07:00
Pete Steinfeld 07b69dcf66 [flang] Response to Steve Scalpone's suggestion to improve a message
Summary: I updated the code that produces the message and the associated test.

Reviewers: sscalpone, DavidTruby, kiranchandramohan

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79514
2020-05-06 15:00:53 -07:00
Pete Steinfeld cfce9b6760 [flang] Response to Steve Scalpone's suggestion to improve a message
Summary: I updated the code that produces the message and the associated test.

Reviewers: sscalpone, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79514
2020-05-06 12:28:21 -07:00
Tim Keith d5c05ced82 [flang][NFC] Add accessors to equivalence and common blocks
Add a way to get mutable equivalence sets to Scope so that they can
have sizes and offsets assigned to them.

Change CommonBlockDetails to have mutable symbols so that they can have
sizes and offets assigned to them. This also allows the removal of some
`const_cast`s.

Add MutableSymbolRef and MutableSymbolVector as mutable analogs to
SymbolRef and SymbolVector. Replace uses of equivalent types with those
names.

Differential Revision: https://reviews.llvm.org/D79346
2020-05-06 12:22:28 -07:00
Tim Keith 237d0e3c04 [flang] Handle EQUIVALENCE and COMMON in size and offset computations
Objects in common blocks have offsets relative to the start of the
common block, independent of the enclosing scope, so they are processed
first. Add alignment to CommonBlockDetails to record the required
alignment of the common block.

For equivalence sets, each object depends on the one that is forced to
occur first in memory. The rest are recorded in the dependents_ map and
have offsets assigned after the other symbols are done.

Differential Revision: https://reviews.llvm.org/D79347
2020-05-06 11:45:28 -07:00
Tim Keith 0195b3a909 [flang] Fix bug in tests for standalone build
When doing a standalone build of flang against an LLVM that contains a
built flang, the tests were run on the flang from LLVM rather than on
the one that was just built.

The problem was in the lit configuration for finding %flang etc.
Fix it to look only in the directory where it was built.

Differential Revision: https://reviews.llvm.org/D79327
2020-05-05 11:08:23 -07:00
Pete Steinfeld 8d0c3c05f2 [flang] New implementation for checks for constraints C741 through C750
Summary:
Most of these checks were already implemented, and I just added references to
them to the code and tests. Also, much of this code was already
reviewed in the old flang/f18 GitHub repository, but I didn't get to
merge it before we switched repositories.

I implemented the check for C747 to not allow coarray components in derived
types that are of type C_PTR, C_FUNPTR, or type TEAM_TYPE.

I implemented the check for C748 that requires a data component whose type has
a coarray ultimate component to be a nonpointer, nonallocatable scalar and not
be a coarray.

I implemented the check for C750 that adds additional restrictions to the
bounds expressions of a derived type component that's an array.
These bounds expressions are sepcification expressions as defined in
10.1.11.  There was already code in lib/Evaluate/check-expression.cpp to
check semantics for specification expressions, but it did not check for
the extra requirements of C750.

C750 prohibits specification functions, the intrinsic functions
ALLOCATED, ASSOCIATED, EXTENDS_TYPE_OF, PRESENT, and SAME_TYPE_AS. It
also requires every specification inquiry reference to be a constant
expression, and requires that the value of the bound not depend on the
value of a variable.

To implement these additional checks, I added code to the intrinsic proc
table to get the intrinsic class of a procedure.  I also added an
enumeration to distinguish between specification expressions for
derived type component bounds versus for type parameters.  I then
changed the code to pass an enumeration value to
"CheckSpecificationExpr()" to indicate that the expression was a bounds
expression and used this value to determine whether to emit an error
message when violations of C750 are found.

I changed the implementation of IsPureProcedure() to handle statement
functions and changed some references in the code that tested for the
PURE attribute to call IsPureProcedure().

I also fixed some unrelated tests that got new errors when I implemented these
new checks.

Reviewers: tskeith, DavidTruby, sscalpone

Subscribers: jfb, llvm-commits

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D79263
2020-05-05 09:37:39 -07:00
Stephen Neuendorffer f432154d1b [flang] update tools/f18 to use LLVM_LINK_COMPONENTS.
This will prevent conflicts with libLLVM.so when using LLVM_LINK_LLVM_DYLIB=on.

Differential Revision: https://reviews.llvm.org/D79370
2020-05-05 08:55:17 -07:00
peter klausler 6fec2c4402 [flang] Fix x87 binary->decimal
Summary:
Fix decimal formatting of 80-bit x87 values; the calculation ofnearest neighbor values failed to account for the explicitmost significant bit in that format.

Replace MultiplyByRounded with MultiplyBy in binary->decimal conversions,
since rounding won't happen and the name was misleading; then remove
dead code, and migrate LoseLeastSignificantDigit() from one source file
to another where it's still needed.

Reviewers: tskeith, sscalpone, jdoerfert, DavidTruby

Reviewed By: tskeith

Subscribers: llvm-commits, flang-commits

Tags: #flang, #llvm

Differential Revision: https://reviews.llvm.org/D79345
2020-05-04 12:04:08 -07:00
Pete Steinfeld b6f1bad630 [flang] Fixed a crash
Summary:
I found a small test case that caused a crash when derived type
definitions have parameters without definitions.

Reviewers: tskeith, klausler, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79282
2020-05-04 07:54:23 -07:00
River Riddle 1165a35a73 [IndexedAccessorRange] Only offset the base if the index is non-zero.
This is more efficient and removes the need for derived ranges to handle the degenerate empty case.
2020-05-01 11:56:39 -07:00
Eric Schweitz d93ae65253 [flang] Add the header file for the conversion of FIR(MLIR) to LLVM-IR dialect
Summary:
This is the interface to the conversion pass that converts the FIR dialect (and standard dialects) of MLIR to the LLVM-IR dialect. The implementation of this bridge will be forthcoming in subsequent diffs.

The purpose of the code gen bridge is to take the IR, which will be expressed as a mix of higher-level Fortran constructs as expressed in the FIR dialect and the MLIR standard dialect, and convert the representation into the LLVM-IR dialect. At that point, the LLVM-IR dialect can be converted into LLVM IR (proper) by a standard MLIR pass.

Reviewers: jeanPerier, vjayathirtha-nv, sscalpone, jdoerfert, DavidTruby, kiranchandramohan

Reviewed By: sscalpone, kiranchandramohan

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D79177
2020-04-30 11:45:39 -07:00
Eric Schweitz 7875362986 [flang] Add the proposal document and rationale for the internal naming module that was previously added.
Summary:
This document describes how uniquing of internal names is done. This
name uniquing is done to support the constraints and invariants of the FIR
dialect of MLIR.

Reviewers: jeanPerier, mehdi_amini, DavidTruby, jdoerfert, sscalpone, kiranchandramohan

Reviewed By: jeanPerier, sscalpone, kiranchandramohan

Subscribers: tskeith, kiranchandramohan, rriddle, llvm-commits

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D79089
2020-04-30 11:32:01 -07:00
River Riddle 0752d98ccf [mlir] Simplify BranchOpInterface by using MutableOperandRange
This range allows for performing many different operations on successor operands, including erasing/adding/setting. This removes the need for the explicit canEraseSuccessorOperand and eraseSuccessorOperand methods.

Differential Revision: https://reviews.llvm.org/D79077
2020-04-29 16:48:15 -07:00
Rainer Orth 3119bdb5d6 [Flang][CMake] Add explicit libFortranCommon dependency for f18 etc.
When I tried Solaris builds with `-DBUILD_SHARED_LIBS=ON`, some commands failed
to link:

  [ 94%] Linking CXX executable ../../../../bin/f18
  Undefined                       first referenced
   symbol                             in file
  Fortran::common::IntrinsicTypeDefaultKinds::set_sizeIntegerKind(int) CMakeFiles/f18.dir/f18.cpp.o  (symbol belongs to implicit dependency /var/llvm/local-amd64-release-shared-gcc8-make/lib/libFortranCommon.so.11git)
  Fortran::common::IntrinsicTypeDefaultKinds::set_subscriptIntegerKind(int) CMakeFiles/f18.dir/f18.cpp.o  (symbol belongs to implicit dependency /var/llvm/local-amd64-release-shared-gcc8-make/lib/libFortranCommon.so.11git)
  Fortran::common::EnumIndexToString[abi:cxx11](int, char const*) CMakeFiles/f18.dir/f18.cpp.o  (symbol belongs to implicit dependency /var/llvm/local-amd64-release-shared-gcc8-make/lib/libFortranCommon.so.11git)
  Fortran::common::IntrinsicTypeDefaultKinds::set_defaultIntegerKind(int) CMakeFiles/f18.dir/f18.cpp.o  (symbol belongs to implicit dependency /var/llvm/local-amd64-release-shared-gcc8-make/lib/libFortranCommon.so.11git)
  Fortran::common::IntrinsicTypeDefaultKinds::IntrinsicTypeDefaultKinds() CMakeFiles/f18.dir/f18.cpp.o  (symbol belongs to implicit dependency /var/llvm/local-amd64-release-shared-gcc8-make/lib/libFortranCommon.so.11git)
  Fortran::common::IntrinsicTypeDefaultKinds::set_defaultRealKind(int) CMakeFiles/f18.dir/f18.cpp.o  (symbol belongs to implicit dependency /var/llvm/local-amd64-release-shared-gcc8-make/lib/libFortranCommon.so.11git)
  ld: fatal: symbol referencing errors

This patch fixes this by adding explicit dependencies on `libFortranCommon`
to the affected commands.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86-64-pc-linux-gnu`.

Differential Revision: https://reviews.llvm.org/D78761
2020-04-28 13:28:41 +02:00
Alex Zinenko bb1d976feb [mlir][flang] use OpBuilder& instead of Builder* in <Op>::build methods
As we start defining more complex Ops, we increasingly see the need for
Ops-with-regions to be able to construct Ops within their regions in
their ::build methods. However, these methods only have access to
Builder, and not OpBuilder. Creating a local instance of OpBuilder
inside ::build and using it fails to trigger the operation creation
hooks in derived builders (e.g., ConversionPatternRewriter). In this
case, we risk breaking the logic of the derived builder. At the same
time, OpBuilder::create, which is by far the largest user of ::build
already passes "this" as the first argument, so an OpBuilder instance is
already available.

Update all ::build methods in all Ops in MLIR and Flang to take
"OpBuilder &" instead of "Builder *". Note the change from pointer and
to reference to comply with the common style in MLIR, this also ensures
all other users must change their ::build methods.

Differential Revision: https://reviews.llvm.org/D78713
2020-04-28 10:42:08 +02:00
Eric Schweitz bc0342383d [flang] Upstream recent work on FIR to llvm-project.
Summary:

Reviewers: DavidTruby, sscalpone, jeanPerier

Subscribers: mgorny, aartbik, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D78835
2020-04-27 17:48:57 -07:00
River Riddle 7c221a7d4f [mlir][Symbol] Change Symbol from a Trait into an OpInterface.
This provides a much cleaner interface into Symbols, and allows for users to start injecting op-specific information. For example, derived op can now inject when a symbol can be discarded if use_empty. This would let us drop unused external functions, which generally have public visibility.

This revision also adds a new `extraTraitClassDeclaration` field to ODS OpInterface to allow for injecting declarations into the trait class that gets attached to the operations.

Differential Revision: https://reviews.llvm.org/D78522
2020-04-27 13:04:49 -07:00
Alexander Belyaev ed5363a674 [MLIR] Add getBody() method to SingleImplicitBlockTerminator op trait.
Many ops with this trait have `getBody()` and `getBodyBuilder()` methods defined in `extraClassDeclaration` in tablegen. `getBody()` implementation is the same accross all these ops, but `getBodyBuilder()` can return builders with varying insertion points set. In this PR, `getBody()` is moved into `SingleImplicitBlockTerminator` struct and `getBodyBuilder()` is replaced with `OpBuilder::atBlock(End|Terminator)(op.getBody);`.

Differential Revision: https://reviews.llvm.org/D78864
2020-04-27 21:48:52 +02:00
David Truby 52492e6c43 [flang][NFC] Fix gcc 9 warning in omp combined construct checks. 2020-04-27 17:59:06 +01:00
David Truby 75c31057a7 [flang] Semantic checks for OpenMP combined constructs.
Summary:
This includes a refactor of the existing combined construct checks
that were present, as well as adding the remaining combined constructs
that had not been implemented yet.

Reviewers: jdoerfert

Subscribers: yaxunl, guansong, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D77812
2020-04-27 12:40:49 +01:00
David Truby b547e1a4d1 [flang] Fix handling of files without terminating newlines.
Reviewers: sscalpone

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D78578
2020-04-27 12:40:22 +01:00
sameeran joshi 807fe05d35 [flang][docs] Doxygen support in flang.
Summary:
    Added support for doxygen-style documentation generation from source code.
    Added -DLLVM_ENABLE_DOXYGEN=ON -DFLANG_INCLUDE_DOCS=ON flags to cmake.
    Added the target doxygen-flang for building doxygen
    Updated README.txt

    Reviewers: DavidTruby, richard.barton.arm, sscalpone,  mehdi_amini, jdoerfert

    Reviewed By: DavidTruby, richard.barton.arm, sscalpone

    Previous review: https://github.com/flang-compiler/f18/pull/1065

    Differential Revision: https://reviews.llvm.org/D78136
2020-04-27 15:02:29 +05:30
peter klausler 3a1afd8c3d Rework DATA statement semantics to use typed expressions
Summary:
Updates recent work on DATA statement semantic checking in
flang/lib/Semantics/check-data.{h,cpp} to use the compiler's
internal representation for typed expressions rather than working
on the raw parse tree.  Saves the analyzed expressions for DATA
statement values as parse tree decorations because they'll soon be
needed in lowering.  Corrects wording of some error messages.

Fixes a bug in constant expression checking: structure constructors
are not constant expressions if they set an allocatable component
to anything other than NULL.

Includes infrastructure changes to make this work, some renaming
to reflect the fact that the implied DO loop indices tracked by
expression analysis are not (just) from array constructors, remove
some dead code, and improve some comments.

Reviewers: tskeith, sscalpone, jdoerfert, DavidTruby, anchu-rajendran, schweitz

Reviewed By: tskeith, anchu-rajendran, schweitz

Subscribers: llvm-commits, flang-commits

Tags: #flang, #llvm

Differential Revision: https://reviews.llvm.org/D78834
2020-04-25 10:29:34 -07:00
Eric Schweitz 5339029ff7 [flang] Support for making unique internal names.
Differential Revision: https://reviews.llvm.org/D78838
2020-04-24 17:27:31 -07:00
peter klausler fc0262419a [flang] More CHARACTER runtime support + unit test
Summary:
This is a continuation of development of the runtime support library's functions for
CHARACTER data; specifically, it implements CHARACTER comparisons.
It includes a new unit test, and moves an #include directive to the
runtime's unit testing main header.

Reviewers: tskeith, sscalpone, DavidTruby, jdoerfert

Reviewed By: tskeith

Subscribers: flang-commits, mgorny, llvm-commits

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D78826
2020-04-24 14:34:51 -07:00
Tim Keith c353ebbfa4 [flang] Compute sizes and offsets for symbols
Summary:
Add size and offset properties to symbols, representing their byte size
and offset within their enclosing scope.

Add size and align properties to scopes so that they are available for
scopes representing derived types.

Add ComputeOffsets pass over the symbol table to fill in those fields.

Compute descriptor size based on rank and length parameters. Extract
DerivedTypeSpec::NumLengthParameters from DynamicType::RequiresDescriptor
to share the code.

Add Scope::GetSymbols to get symbols in canonical order.
compute-offsets.cpp and mod-file.cpp both need to process symbols in the
order in which they are declared. Move the collecting of those symbols
into Scope so that it can be shared.

Add symbol size and offset to output of `-fdebug-dump-symbols` and use
that in some tests.

Still to do:
- make size and alignment rules configurable based on target
- use offsets to check EQUIVALENCE statements

Differential Revision: https://reviews.llvm.org/D78680
2020-04-23 14:54:34 -07:00
Tim Keith 4ced7a48e6 [flang] Remove unused variable
Reviewers: sscalpone, jdoerfert, DavidTruby

Reviewed By: sscalpone

Subscribers: llvm-commits

Tags: #flang, #llvm

Differential Revision: https://reviews.llvm.org/D78725
2020-04-23 09:22:14 -07:00
Tim Keith 9623003e93 [flang][NFC] Refactor derived type instantiation
Summary:
Move InstantiateComponent and InstantiateIntrinsicType from symbol.cpp
to type.cpp as that is where they are called.

Put both in InstantiateHelper class to better isolate them.
Add CreateDerivedTypeSpec in InstantiateHelper.

Add non-const forms for AsIntrinsic and AsDerived to avoid const_cast.

No functional changes.

Reviewers: DavidTruby, klausler, PeteSteinfeld, jdoerfert

Reviewed By: klausler

Subscribers: llvm-commits

Tags: #flang, #llvm

Differential Revision: https://reviews.llvm.org/D78678
2020-04-23 08:29:47 -07:00
Tim Keith 026d8807f4 [flang] Add missing check for unresolved name
Summary:
The name in an InputItem isn't necessarily resolved if an error occurred,
so it needs to be checked.

Fixes https://bugs.llvm.org/show_bug.cgi?id=45477

Reviewers: klausler, PeteSteinfeld, DavidTruby, jdoerfert, sscalpone

Reviewed By: klausler, sscalpone

Subscribers: llvm-commits

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D78685
2020-04-23 07:00:38 -07:00
Valentin Clement a6c1692cb3 [Flang] fix dependency issues after D78215
Patch D78215 changes various dependencies in the CMakeLists.txt. This
results in error while compiling. This patch fixes the issue.

Reviewers: DavidTruby

Differential Revision: https://reviews.llvm.org/D78340
2020-04-21 20:32:11 +01:00
Rainer Orth 0535fab237 [Flang][test] Don't set PATH in flang/test/Semantics/common.sh
Currently, many `Flang :: Semantics` tests FAIL on Solaris.  The failure
mode is always the same:

  actual at 67: Name in ALLOCATE statement must be a variable name
  expect at 67: ERROR: Name in ALLOCATE statement must be a variable name

It turns out the issue is twofold here:

- The awk script embedded in `flang/test/Semantics/common.sh` uses a string
  value for `FS`, which isn't supported by traditional awk as documented in
  the GNU autoconf manual.

- Even though /usr/gnu/bin (with gawk installed as awk) is in my build
  environment's `PATH`, still /bin/awk is used

Although the proper fix would probably be to avoid the unportability, it's
easy to work around it for now.  `common.sh` above is the only script in
the whole tree that for unknown reasons overrides `PATH` to
`/usr/bin:/bin`, unnecessarily creating this mess in the first place.  Just
removing that setting easily avoids the issue.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D78550
2020-04-21 14:32:57 +02:00
Anchu Rajendran c1c01212c4 [flang]Implemented Semantic Checkes for 5 data constraints
Summary:
 C874, C875, C878, C880 and C881 checks are implemented.

Differential Revision: https://reviews.llvm.org/D78008
2020-04-18 12:21:30 +05:30
Mehdi Chinoune 2d6b9dbfef [flang] Use the Flang cmake-functions to add targets.
Summary: It also removes the cycle-dependency between FortranSemantics and FortranEvaluate.

Reviewers: #flang, jdoerfert, sscalpone

Reviewed By: #flang, sscalpone

Subscribers: DavidTruby, schweitz, tskeith, mgorny, aartbik, llvm-commits

Tags: #flang, #llvm

Differential Revision: https://reviews.llvm.org/D78215
2020-04-16 15:51:30 +01:00
David Truby 29e71ceaee [flang] Add return statement to Logical opeator=.
This removes the current undefined behavior where the function has a return type
but no return statement.

Fixes: https://bugs.llvm.org/show_bug.cgi?id=45530
2020-04-15 13:18:42 +01:00
River Riddle ebf190fcda [llvm][ADT] Move TypeSwitch class from MLIR to LLVM
This class implements a switch-like dispatch statement for a value of 'T' using dyn_cast functionality. Each `Case<T>` takes a callable to be invoked if the root value isa<T>, the callable is invoked with the result of dyn_cast<T>() as a parameter.

Differential Revision: https://reviews.llvm.org/D78070
2020-04-14 15:14:41 -07:00
River Riddle 2f21a57966 [llvm][STLExtras] Move the algorithm `interleave*` methods from MLIR to LLVM
These have proved incredibly useful for interleaving values between a range w.r.t to streams. After this revision, the mlir/Support/STLExtras.h is empty. A followup revision will remove it from the tree.

Differential Revision: https://reviews.llvm.org/D78067
2020-04-14 15:14:40 -07:00
Eric Schweitz d58a405de6 [flang] Upstream patch to enable the fir-ops test. bug 45487
Differential revision: https://reviews.llvm.org/D77834
2020-04-14 10:02:04 -07:00
Mehdi Amini ed6c452edc Add missing dependencies on the flang test target
Without this, the LLVM utilities (FileCheck) aren't built when running
`ninja check-flang` and it fails with:

llvm-project/llvm/utils/lit/lit/llvm/subst.py:134: fatal: Did not find FileCheck in...

Also the modules aren't built without depending on `module_files`, which
makes multiple tests failing.

Differential Revision: https://reviews.llvm.org/D78036
2020-04-13 18:23:01 +00:00
David Truby 413467f9ec [flang] [NFC] Adjust README.md for upstreaming.
This changes the references and build instructions for Flang so that
they are correct now that F18 has been rechristened Flang and merged
with LLVM.

Reviewed at: https://github.com/flang-compiler/f18/pull/909
2020-04-09 21:15:48 +01:00
David Truby 89c7d9633b [flang] Temporarily XFAIL failing test Fir/fir-ops.fir 2020-04-09 18:36:17 +01:00