Commit Graph

4345 Commits

Author SHA1 Message Date
Daniil Dudkin 488b9fd103 [flang] Do not ICE on recursive function definition in function result
The following code causes the compiler to ICE in several places due to
lack of support of recursive procedure definitions through the function
result.

  function foo() result(r)
    procedure(foo), pointer :: r
  end function foo
2022-04-21 19:04:17 +09:00
Nimish Mishra 00c511b351 Added lowering support for atomic read and write constructs
This patch adds lowering support for atomic read and write constructs.
Also added is pointer modelling code to allow FIR pointer like types to
be inferred and converted while lowering.

Reviewed By: kiranchandramohan

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

Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com>
2022-04-21 12:19:13 +05:30
Shraiysh Vaishay 88bb2521b0 [mlir][OpenMP] Add checks and tests for hint clause and fix empty hint
This patch handles empty hint value for critical and atomic constructs.

This also adds checks and tests for hint clause on atomic constructs.

Reviewed By: peixin, kiranchandramohan, NimishMishra

Differential Revision: https://reviews.llvm.org/D123186
2022-04-21 07:31:03 +05:30
V Donaldson 7d61a8419b [flang] Semantics limits on kP scale factors
When known at compile time, Ew.d and Dw.d output edit descriptors
should respect limitations from the standard on the value of a
kP scale factor with respect to the digit count (d), at least for
values of k other than zero.
2022-04-20 14:43:21 -07:00
Mike Kashkarov 39ee23ed5a [flang] Set LBOUND() folding for (x) expression as ones
Set LBOUND() constant folding for parentheses expr. as ones

Array bounds should not propagate throught omitted bounds specifications or
temporary variables - fix constant folding in case of Parentheses<T> expression
by explicitly returning array of ones (or scalar in case of DIM=).

Add set of tests for (x) bounds checks (w/ and w/o 'parameter' arrays)

Reviewed By: jeanPerier

Differential Revision: https://reviews.llvm.org/D123838
2022-04-20 20:06:11 +03:00
Mike Kashkarov bd5371e4fc [flang] Fix LBOUND() folding for constant arrays
Previously constant folding uses 'dim' without checks which leads to ICE if we
do not have DIM= parameter. And for inputs without DIM= we need to form an
array of rank size with computed bounds instead of single value.

Add additional PackageConstant function to simplify 'if (dim)' handling since we
need to distinguish between scalar initialization in case of DIM= argument and
rank=1 array.

Also add a few more tests with 'parameter' type to verify folding for constant
arrays.

Reviewed By: jeanPerier

Differential Revision: https://reviews.llvm.org/D123237
2022-04-20 20:04:31 +03:00
Jean Perier 3d63d2111c [flang] Do not pass derived type by descriptor when not needed
A missing "!" in the call interface lowering caused all derived type
arguments without length parameters that require and explicit interface
to be passed via fir.box (runtime descriptor).

This was not the intent: there is no point passing a simple derived type
scalars or explicit shapes by descriptor just because they have an attribute
like TARGET. This would actually be problematic with existing code that is
not always 100% compliant: some code implicitly calls procedures with
TARGET dummy attributes (this is not something a compiler can enforce
if the call and procedure definition are not in the same file).

Add a Scope::IsDerivedTypeWithLengthParameter to avoid passing derived
types with only kind parameters by descriptor. There is no point, the
callee knows about the kind parameter values.

Differential Revision: https://reviews.llvm.org/D123990
2022-04-20 10:00:34 +02:00
River Riddle 58ceae9561 [mlir:NFC] Remove the forward declaration of FuncOp in the mlir namespace
FuncOp has been moved to the `func` namespace for a little over a month, the
using directive can be dropped now.
2022-04-18 12:01:55 -07:00
Peter Klausler b8a929cb2f [flang] Fix regression with recent work on intrinsic/generic interactions
When resolving a procedure reference, do not allow a successful
intrinsic procedure probe result to override an existing
symbol.

Differential Revision: https://reviews.llvm.org/D123905
2022-04-18 11:10:41 -07:00
Peter Klausler cd03e96f00 [flang] Add & use a better visit() (take 2)
Adds flang/include/flang/Common/log2-visit.h, which defines
a Fortran::common::visit() template function that is a drop-in
replacement for std::visit().  Modifies most use sites in
the front-end and runtime to use common::visit().

The C++ standard mandates that std::visit() have O(1) execution
time, which forces implementations to build dispatch tables.
This new common::visit() is O(log2 N) in the number of alternatives
in a variant<>, but that N tends to be small and so this change
produces a fairly significant improvement in compiler build
memory requirements, a 5-10% improvement in compiler build time,
and a small improvement in compiler execution time.

Building with -DFLANG_USE_STD_VISIT causes common::visit()
to be an alias for std::visit().

Calls to common::visit() with multiple variant arguments
are referred to std::visit(), pending further work.

This change is enabled only for GCC builds with GCC >= 9;
an earlier attempt (D122441) ran into bugs in some versions of
clang and was reverted rather than simply disabled; and it is
not well tested with MSVC. In non-GCC and older GCC builds,
common::visit() is simply an alias for std::visit().
2022-04-16 16:00:48 -07:00
Peter Klausler 1fe7a187ae [flang][runtime] Don't emit empty lines for bad writes
When an error occurs in a formatted sequential output statement
and no output was ever emitted, don't emit a blank record.
This matches the error case behavior of other Fortran compilers.

Differential Revision: https://reviews.llvm.org/D123734
2022-04-15 20:32:32 -07:00
Peter Klausler 9f5f2eb2a1 [flang] Accept %KIND type parameter inquiries on %RE,%IM, &c.
The x%KIND inquiry needs to be supported when 'x' is itself
a complex part reference or a type parameter inquiry.

Differential Revision: https://reviews.llvm.org/D123733
2022-04-15 20:22:03 -07:00
Peter Klausler de6e88ef5a [flang] Allow POINTER attribute statement on procedure interfaces
A POINTER attribute statement is allowed to add the POINTER attribute
to a procedure entity that has already been declared, e.g. with an
INTERFACE block.

Differential Revision: https://reviews.llvm.org/D123732
2022-04-15 20:20:56 -07:00
Peter Klausler 847c39838e [flang] Upgrade short actual character arguments to errors
f18 was emitting a warning about short character actual arguments to
subprograms and statement functions; every other compiler considers this
case to be an error.

Differential Revision: https://reviews.llvm.org/D123731
2022-04-15 20:05:04 -07:00
Peter Klausler 64aff3632f [flang][runtime] Fix ENDFILE for formatted stream output
A predicate expression made ENDFILE statements significant
only for sequential files, but it's applicable to formatted
stream output as well.

Differential Revision: https://reviews.llvm.org/D123730
2022-04-15 18:57:29 -07:00
Peter Klausler 9e7eef9989 [flang] Handle parameter-dependent types in PDT initializers
For parameterized derived type component initializers whose
expressions' types depend on parameter values, f18's current
scheme of analyzing the initialization expression once during
name resolution fails.  For example,

  type :: pdt(k)
    integer, kind :: k
    real :: component = real(0.0, kind=k)
  end type

To handle such cases, it is necessary to re-analyze the parse
trees of these initialization expressions once for each distinct
initialization of the type.

This patch adds code to wipe an expression parse tree of its
typed expressions, and update those of its symbol table pointers
that reference type parameters, and then re-analyze that parse
tree to generate the properly typed component initializers.

Differential Revision: https://reviews.llvm.org/D123728
2022-04-15 16:20:41 -07:00
Peter Klausler 7e225423d3 [flang] Finer control over error recovery with GetExpr()
Prior to this patch, the semantics utility GetExpr() will crash
unconditionally if it encounters a typed expression in the parse
tree that has not been set by expression semantics.  This is the
right behavior when called from lowering, by which time it is known
that the program had no fatal user errors, since it signifies a
fatal internal error.  However, prior to lowering, in the statement
semantics checking code, a more nuanced test should be used before
crashing -- specifically, we should not crash in the face of a
missing typed expression when in error recovery mode.

Getting this right requires GetExpr() and its helper class to have
access to the semantics context, so that it can check AnyFatalErrors()
before crashing.  So this patch touches nearly all of its call sites.

Differential Revision: https://reviews.llvm.org/D123873
2022-04-15 14:25:41 -07:00
Peter Klausler ca2be81e34 [flang] Fix Symbol::Rank for ProcEntityDetails
When a procedure pointer or procedure dummy argument has a
defined interface, the rank of the pointer (or dummy) is the
rank of the interface.

Also tweak code discovered in shape analysis when investigating
this problam so that it returns a vector of emptied extents rather
than std::nullopt when the extents are not scope-invariant, so that
the rank can at least be known.

Differential Revision: https://reviews.llvm.org/D123727
2022-04-15 09:54:48 -07:00
Peter Klausler e6873bfbcd [flang][runtime] Don't skip input spaces when they are significant
When formatted input (not list-directed or NAMELIST) is in "BZ" mode,
either because a BZ control edit descriptor appeared in a FORMAT or
BLANK="ZERO" appeared in OPEN or READ, input editing must not skip
over blanks before or within the input field.

Differential Revision: https://reviews.llvm.org/D123725
2022-04-14 21:30:43 -07:00
Peter Klausler 2503f28648 [flang] Accept TYPE(intrinsic type) in declarations only for non-extension type
To avoid clashing with names of user derived types, the redundant
syntax TYPE(intrinsic type spec) must be interpreted as a monomorphic
derived type when "intrinsic type spec" is a single word.  This
affects TYPE(BYTE) and TYPE(DOUBLECOMPLEX), but not TYPE(DOUBLE COMPLEX)
in free form source.

Differential Revision: https://reviews.llvm.org/D123724
2022-04-14 18:19:37 -07:00
Peter Klausler 7c71ce97e7 [flang] Defer NAMELIST group item name resolution
Items in NAMELIST groups might be host-associated implicitly-typed
variables, but name resolution can't know that when the NAMELIST
appears in a specification part and the host's execution part has
not yet been analyzed.  So defer NAMELIST group item name resolution
to the end of the execution part.  This is safe because nothing
else in name resolution depends on whether a variable is in a
NAMELIST group or not.

Differential Revision: https://reviews.llvm.org/D123723
2022-04-14 17:50:03 -07:00
Peter Klausler 625dedc3fe [flang] Allow modification of construct entities
Construct entities from ASSOCIATE, SELECT TYPE, and SELECT RANK
are modifiable if the are associated with modifiable variables
without vector subscripts.  Update WhyNotModifiable() to accept
construct entities that are appropriate.

A need for more general error reporting from one overload of
WhyNotModifiable() caused its result type to change to
std::optional<parser::Message> instead of ::MessageFixedText,
and this change had some consequences that rippled through
call sites.

Some test results that didn't allow for modifiable construct
entities needed to be updated.

Differential Revision: https://reviews.llvm.org/D123722
2022-04-14 16:58:08 -07:00
Peter Klausler 142cbd500b [flang] Fix TYPE/CLASS IS (T(...)) in SELECT TYPE
TYPE IS and CLASS IS guards in SELECT TYPE constructs are
allowed to specify the same type as the type of the selector
but f18's implementation of that predicate required strict
equality of the derived type representations.  We need to
allow for assumed values of LEN type parameters to match
explicit and deferred type parameter values in the selector
and require equality for KIND type parameters.  Implement
DerivedTypeSpec::Match() to perform this more relaxed type
comparison, and use it in check-select-type.cpp.

Differential Revision: https://reviews.llvm.org/D123721
2022-04-14 16:20:37 -07:00
Peter Klausler 95199af4ae [flang] Local generics must not shadow host-associated generics
It is possible for generic interfaces of equivalent (but not necessarily
identical -- operator(.eq.) is equivalent to operator(==)) names to
be declared in a host scope and a nested scope, and the nested declaration
should function as an extension of the host's.

Differential Revision: https://reviews.llvm.org/D123719
2022-04-14 15:43:59 -07:00
Peter Klausler 8065e48218 [flang] Inner INTRINSIC must not shadow host generic
A generic interface (however spelled) can have the same name as
an intrinsic procedure in the same scope.  When an explicit INTRINSIC
attribute statement appears in a nested scope, semantics was
unconditionally declaring a new symbol that hid the generic entirely.
Catch this case and create instead a host association symbol for
the generic that can then be decorated with the INTRINSIC attribute.

Differential Revision: https://reviews.llvm.org/D123718
2022-04-14 15:42:44 -07:00
Peter Klausler a68612a964 [flang][runtime] Preserve effect of positioning in record in non-advancing output
When formatted non-advancing output ends in a control edit descriptor
like nX or Tn or TRn that effectively extends the record, fill any
gap with explicit blanks at the completion of the WRITE.

Differential Revision: https://reviews.llvm.org/D123716
2022-04-14 15:33:15 -07:00
Peter Klausler 724709e09d [flang] Make F0.1 output editing of zero edge case consistent
The statement
  PRINT '(2F0.1)', 0.0, 0.5
should emit consistent ".0 .5" output, not "0.0 .5".

Differential Revision: https://reviews.llvm.org/D123715
2022-04-14 15:31:47 -07:00
Peter Klausler de026aeb8e [flang] Raise FP exceptions from runtime conversion to binary
Formatted READs of REAL should convert the exception flags from
the decimal-to-binary conversion library into real runtime FP
exceptions so that they at least show up in the termination message
of a STOP statement.

Differential Revision: https://reviews.llvm.org/D123714
2022-04-14 14:49:36 -07:00
Peter Klausler eb14135e35 [flang] Correct interaction between generics and intrinsics
Fortran allows a generic interface to have he same name as an
intrinsic procedure.  If the intrinsic is explicitly marked with
the INTRINSIC attribute, restrictions apply (C848) - the generic
must contain only functions or subroutines, depending on the
intrinsic.  Explicit or not, the generic overrides the intrinsic,
but the intrinsic behavior must still be available for calls
whose actual arguments do not match any of the specific procedures.

Semantics was not checking constraint C848, and it didn't allow
an explicit INTRINSIC attribute on a name of a generic interface.

Differential Revision: https://reviews.llvm.org/D123713
2022-04-14 13:56:04 -07:00
V Donaldson 96e45a8958 [flang] Use full result range for clock_gettime implementation of SYSTEM_CLOCK
Update the primary clock_gettime implementation of SYSTEM_CLOCK to use
the full range of values, dependent on the type kind of the requested
result.  Counts/sec and count max for supported kinds become:

 kind          counts/sec             count max

    1                  10                   127
    2                1000                 32767
    4                1000            2147483647
    8          1000000000   9223372036854775807
   16          1000000000   9223372036854775807

The secondary "fallback" implementation is not changed.

Real valued COUNT_RATE arguments are not changed.

The test program below has calls for kinds 1, 2, 4, 8, 16.  Support for
these types varies by compiler.  The code as given can be restricted to
accommodate these variations, with results shown below.

subroutine c
  integer(1) c1, r1, m1
  integer(2) c2, r2, m2
  integer(4) c4, r4, m4
  integer(8) c8, r8, m8
  integer(16) c16, r16, m16

  print*
  print '(a5,3a22)', 'kind', 'counts/sec', 'count max', 'count'
  print*

  call system_clock(c1, r1, m1)
  print '(i5,3i22)', 1, r1, m1, c1

  call system_clock(c2, r2, m2)
  print '(i5,3i22)', 2, r2, m2, c2

  call system_clock(c4, r4, m4)
  print '(i5,3i22)', 4, r4, m4, c4

  call system_clock(c8, r8, m8)
  print '(i5,3i22)', 8, r8, m8, c8

  call system_clock(c16, r16, m16)
  print '(i5,3i22)', 16, r16, m16, c16
end

subroutine k(j)
  j = 0
  do i=1,1000000000
    j = j + i
  enddo
end

program p
  do i=1,1 ! increase loop count to check for (kind=1) wraparound
    call k(j)
    call c
  enddo
end

=== flang output without change (last column counts vary per run) ===

 kind          counts/sec             count max                 count

    1                 -24                   127                    83
    2                1000                   290                   211
    4                1000                   290                   211
    8          1000000000             290448383             211631452
   16          1000000000             290448383             211633853

=== flang output with change (last column counts vary per run) ===

    1                  10                   127                    21
    2                1000                 32767                  2100
    4                1000            2147483647                  2100
    8          1000000000   9223372036854775807            2100183374
   16          1000000000   9223372036854775807            2100185353

Other compilers; kind support varies (last column counts vary per run).
Test and ouput modified to avoid crashes and normalize results.
Some negative values indicate unsupported kinds; others are bugs.

 kind          counts/sec             count max                 count

    1                   0                     0                  -127
    2                   0                     0                -32767
    4                1000            2147483647              69271692
    8          1000000000   9223372036854775807        69271692353290
   16          1000000000   9223372036854775807        69271692354794

=======

    1                  10                   127                     0
    2                1000                 32767                     0
    4             1000000            2147483647                     0
    8            10000000   9223372036854775807                     9

=======

    1                   0                     0                  -127
    2                1000                 32767                  3263
    4               10000            2147483647            1788192630
    8             1000000   9223372036854775807      1649443459263095

=======

    1                 -24                    -1                    36
    2                1000                    -1                -10716
    4                1000            2147483647             176018980
    8                1000   9223372036854775807         1649443460644

=======

    2                 100                 28799                 23080
    4                 100               8639999               4285480
    8                 100               8639999               4285480
   16                 100               8639999               4285480

=======

    1                 -24                    -1                     4
    2                1000                 23551                -26108
    4                1000              86399999              67541508
    8             1000000   9223372036854775807      1649443541508087
2022-04-14 13:01:32 -07:00
Peter Klausler d054959786 [flang] Fix shape analysis of RESHAPE result
Shape analysis of RESHAPE(..., SHAPE=s) should of course return
the SHAPE= actual argument when it is constant; but when it is
not, its length is still known, and thus so is the rank of the
result of RESHAPE(), and shape analysis should at least return
a shape vector of the right length rather than a result that
makes the result appear to be a scalar, which can lead to some
bogus error messages.

Also, while here: rename a private GetShapeHelper::AsShape()
routine so that it can't be confused with the ones in the API
of shape.h.

Differential Revision: https://reviews.llvm.org/D123712
2022-04-14 12:07:48 -07:00
Peter Klausler 664c111c95 [flang] Always encode multi-byte output in UTF-8
A recent change to implement UTF-8 encoding should have
made the encoding conditional only for CHARACTER(KIND=1)
to enable UTF-8 output vs. Latin-1 or whatever.  UTF-8 output
of wider CHARACTER kinds should not be conditional (until we choose
to support UCS-16, maybe).  So wider CHARACTER kinds are being
emitted with extra zero bytes; this patch fixes them.

Differential Revision: https://reviews.llvm.org/D123711
2022-04-14 11:13:51 -07:00
Peter Klausler 6111ddedc8 [flang] Defer all function result type processing
When a type specification appears in the prefix of a FUNCTION statement,
defer its processing as late as possible so that any symbols in the
tpe specification can be resolved in the function's scope to local
declarations, including use-associated symbols.  f18 was already doing
this deferral in a limited form for derived types, and this patch
makes it work for intrinsic type parameter values as well.

In short, "real(kind(x)) function foo(x)" now works as it should.

"As late as possible" means the end of the specification part, or
the first appearance of the function result name in the specification
part.

Differential Revision: https://reviews.llvm.org/D123705
2022-04-14 10:25:57 -07:00
Peter Klausler 9b200074b1 [flang] Fix combining cases of USE association & generic interfaces
Fortran admits a few ways to have multiple symbols with the
same name in the same scope.  Two of them involve generic
interfaces (from INTERFACE or GENERIC, the syntax doesn't matter);
these are allowed to inhabit a scope with either a derived type or
a subprogram that is also a specific procedure of the generic.
(But not both a derived type and a subprogram; they could not
cohabit a scope anyway, generic or not.)

In cases of USE association, f18 needs to be capable of combining
use-associated generic interfaces with other use-associated entities.
Two generics get merged (this case was nearly correct); a generic
and a derived type can merge into a GenericDetails with a shadowed
derivedType(); and a generic can replace or ignore a use-associated
procedure of the same name so long as that procedure is already
one of its specifics.

Further, these modifications to the use-associated generic
interface must be made to a local copy of the symbol.  The previous
code was messing directly with the symbol in the module's scope.

The fix is basically a reimplementation of the member function
DoAddUse() in name resolution.

Differential Revision: https://reviews.llvm.org/D123704
2022-04-14 08:59:52 -07:00
Peter Klausler ef141aec3c [flang] Improve appearance of message attachments
Error messages can have a list of attachments; these are used to point
to related source locations, supply additional information, and to
encapsulate error messages that were *not* emitted in a given context
to explain why a warning was justified.

This patch adds a message severity ("Because") for that last case,
and extends to AttachTo() API to provide a means for overriding
the severity of an attached message.

Some existing message attachments had their severities adjusted,
now that we're printing them.  And operator==() for Message was
cleaned up while debugging after I noticed that it was recursively
O(N**2) and subject to returning a false positive.

Differential Revision: https://reviews.llvm.org/D123710
2022-04-14 07:34:50 -07:00
PeixinQiao 0b55a8dc6f [flang] Fix intrinsic interface for DIMAG/DCONJG
The intrinsics DREAL, DIMAG, and DCONJG are from Fortran 77 extensions.
For DREAL, the type of argument is extended to any complex. For DIMAG
and DCONJG, the type of argument for them should be complex(8). For DIMAG,
the result type should be real(8). For DCONJG, the result type should be
complex(8). Fix the intrinsic interface for them and add test cases for
the semantic checks and the lowering.

Reviewed By: Jean Perier

Differential Revision: https://reviews.llvm.org/D123459
2022-04-14 21:34:00 +08:00
PeixinQiao 0ff322246b [flang] Fix float-number representation bug
The float number is represented as (-1)^s * 1.f * 2^(-127) for 32-bit,
where s is the signed flag, f is the mantissa. When the exponent bits
are all zeros, the float number is represented as (-1)^s * 0.f *2^(-126)
for 32-bit, in which case, the intPart is '0'.

Reviewed By: Jean Perier

https://reviews.llvm.org/D123673
2022-04-14 21:28:30 +08:00
Mike Kashkarov 68efe63565 [flang] Fix ICE for sqrt(0.0) evaluation
During real range reduction to [0.5, 4) with

           SQRT(2**(2a) * x) = SQRT(2**(2a)) * SQRT(x) = 2**a * SQRT(x)

    we fall into inf. recursion if IsZero() == true.

    Explicitly handle SQRT(0.0) instead of additional checks during folding. Also
    add helpers for +0.0/-0.0 generation to clean up a bit.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D123131
2022-04-14 12:53:46 +03:00
Mike Kashkarov ba038a3080 [flang] Do not ICE on out-of-range data statement designator
Print error message instead of assert trigger.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D123132
2022-04-14 12:51:55 +03:00
Mike Kashkarov d2bcb0a129 [flang] Allow IMPLICIT NONE(EXTERNAL) with GenericDetails
Restrictions of IMPLICIT NONE(EXTERNAL) prohibits usage of c_associated from
iso_c_binding (with explicit interface) without external definiton - relax
associated check.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D120971
2022-04-14 12:45:21 +03:00
Andrzej Warzynski 6c93e1d329 [flang][driver] Add support for `-mmlir`
The semantics of `-mmlir` are identical to `-mllvm`. The only notable
difference is that `-mmlir` options should be forwarded to MLIR rather
than LLVM.

Note that MLIR llvm::cl options are lazily constructed on demand (see
the definition of options in PassManagerOptions.cpp). This means that:
  * MLIR global options are only visible when explicitly initialised and
    displayed only when using `-mmlir --help`,
  * Flang and LLVM global options are always visible and displayed when
    using either `-mllvm -help` or `-mmlir --help`.

In other words, `-mmlir --help` is a superset of `-mllvm --help`. This is not
ideal, but we'd need to refactor all option definitions in Flang and
LLVM to improve this. I suggesting leaving this for later.

Differential Revision: https://reviews.llvm.org/D123297
2022-04-14 09:40:31 +00:00
Andrzej Warzynski 8de6cb1297 [flang] Fix DYLIB builds
https://reviews.llvm.org/D123211 broke builds that set both
`LLVM_BUILD_LLVM_DYLIB` and `LLVM_LINK_LLVM_DYLIB` (see [1]). This patch
fixes that.

The build failure was caused by the fact that the LLVMPasses library,
which is an LLVM "component", was listed directly as link-time
dependency. Instead, one should use `LINK_COMPONENTS` in CMake files. I
made an identical mistake recently and then subsequently fixed it in
https://reviews.llvm.org/D121461 - please visit that revision for more
detail.

I'm merging this without a review. The change is straightforward, we
recently discussed it and I was able to confirm locally that it fixes
the build issue.

[1] https://lab.llvm.org/buildbot/#/builders/177/builds/4619
2022-04-14 08:58:34 +00:00
Peter Klausler d2b339f176 [flang] Respect left tab limit with Tn editing after ADVANCE='NO'
Correct the implementation of non-advancing I/O after some testing
to ensure that T tab edit descriptors are not allowed to back up
into positions of a record prior to where it stood at the beginning
of the I/O statement.

Differential Revision: https://reviews.llvm.org/D123709
2022-04-13 21:45:53 -07:00
Peter Klausler a73f7ababb [flang] Error handling for out-of-range CASE values
Catch and nicely describe errors in CASE range values
that are out of range for the type of the SELECT CASE.

Differential Revision: https://reviews.llvm.org/D123708
2022-04-13 18:35:00 -07:00
Peter Klausler 34cc706b96 [flang] Fold IBITS() intrinsic function
Implement constant folding of IBITS(); add test.

Differential Revision: https://reviews.llvm.org/D123707
2022-04-13 17:06:14 -07:00
Damian Rouson f253a577b2 [flang] expand the num_images test coverage
Add a test with a range of num_images() intrinsic function
invocations, including the standard-conforming but previously
untested 'team' argument.  Also test that several non-conforming
num_images() invocations generate the correct error messages.

Differential Revision: https://reviews.llvm.org/D121938
2022-04-13 16:09:19 -07:00
Peter Klausler c709f503d7 [flang] Emit a portability warning for padding in COMMON
When padding is required in a COMMON block to ensure alignment
of a component, emit a portability warning.

Differential Revision: https://reviews.llvm.org/D123706
2022-04-13 15:58:17 -07:00
PeixinQiao 8964a17dad [OpenMP] Lowering to MLIR of ordered threads directive
This patch supports lowering parse-tree to MLIR of ordered threads
directive following Section 2.19.9 of the OpenMP 5.1 standard.

This is part of the upstreaming effort from the fir-dev branch in [1].
[1] https://github.com/flang-compiler/f18-llvm-project

Reviewed By: shraiysh

Differential Revision: https://reviews.llvm.org/D123590
2022-04-13 22:30:52 +08:00
PeixinQiao 154135c11c [flang][OpenMP] Add semantic checks of nesting of region about ordered construct
This patch supports the following checks for ORDERED construct:

```
[5.1] 2.19.9 ORDERED Construct
The worksharing-loop or worksharing-loop SIMD region to which an ordered
region corresponding to an ordered construct without a depend clause
binds must have an ordered clause without the parameter specified on the
corresponding worksharing-loop or worksharing-loop SIMD directive.
The worksharing-loop region to which an ordered region that corresponds
to an ordered construct with any depend clauses binds must have an
ordered clause with the parameter specified on the corresponding
worksharing-loop directive.
An ordered construct with the depend clause specified must be closely
nested inside a worksharing-loop (or parallel worksharing-loop)
construct.
An ordered region that corresponds to an ordered construct with the simd
clause specified must be closely nested inside a simd or
worksharing-loop SIMD region.
```

Reviewed By: kiranchandramohan, shraiysh, NimishMishra

Differential Revision: https://reviews.llvm.org/D113399
2022-04-13 22:27:58 +08:00
Andrzej Warzynski 6d3224d93f [flang][nfc] Simplify TargetMachine initialisation 2022-04-13 10:49:24 +00:00