Check that when a procedure pointer is initialised or assigned with an intrinsic
function, or when its interface is being defined by one, that intrinsic function
is unrestricted specific (listed in Table 16.2 of F'2018).
Mark intrinsics LGE, LGT, LLE, and LLT as restricted specific. Getting their
classifications right helps in designing the tests.
Differential Revision: https://reviews.llvm.org/D112381
Add support for reading environment variables directly, via std::getenv.
This needs to allocate a C-style string to pass into std::getenv. If the
memory allocation for that fails, we terminate.
This also changes the interface for EnvVariableLength to receive the
source file and line so we can crash gracefully.
Note that we are now completely ignoring the envp pointer passed into
ProgramStart, since that could go stale if the environment is modified
during execution.
Differential Revision: https://reviews.llvm.org/D111785
This patch supports the atomic construct (read and write) following
section 2.17.7 of OpenMP 5.0 standard. Also added tests and
verifier for the same.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D111992
Substring information on slice operation has been added in D112441.
The operations fir.array_load, fir.array_coor and fir.array_merge_store can take
a slice but not with a substring. This patch add this check in their verifier.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: schweitz
Differential Revision: https://reviews.llvm.org/D112568
RewritePatterns.td/RewritePatterns.inc is used only by the
FIROps.cpp file. This patch move this file logically in the Dialect
folder together with FIRDialet, FIROps, FIRTypes ...
It also rename it to CanonicalizationPatterns.td.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: schweitz
Differential Revision: https://reviews.llvm.org/D112522
This patch adds the substriing information to the fir.slice
operation. This will be used by character operations in later
upstreaming patches.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D112441
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Adds initial parsing and sema for the 'append_args' clause.
Note that an AST clause is not created as it instead adds its values
to the OMPDeclareVariantAttr.
Differential Revision: https://reviews.llvm.org/D111854
This patch has couple of small changes to clean-up FIROps.td.
- Wrap lines that are longer than 80.
- All parser, verifier and printer that are single line are wrapped with double
quotes.
- Couple of small typos.
Reviewed By: AlexisPerry
Differential Revision: https://reviews.llvm.org/D112436
The fir_Dialect definition was coming silently through FIRTypes.td.
Make the include of flang/Optimizer/Dialect/FIRDialect.td explicit in
FIROps.td and move MLIR includes to FIRDialect.td.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: AlexisPerry
Differential Revision: https://reviews.llvm.org/D112418
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
The clang-aarch64-full-2stage buildbot is complaining about a
warning with three instances in f18 code (none modified recently).
The warning is for using the | bitwise OR operator on bool operands.
In one instance, the bitwise operator was being used instead of the
logical || operator in order to avoid short-circuting. The fix
requires using some temporary variables. In the other two instances,
the bitwise operator seemed more idiomatic in context, but can be
replaced without harm with the logical operator.
Pushing without review as confidence is high and nobody wants
a buildbot to stay sad for long.
The 'A' edit descriptor once served as a form of raw I/O of bytes
to/from variables that weren't of type CHARACTER (which itself
didn't exist until F'77). This usage was especially common for
output of numeric variables that had been initialized with Hollerith.
Differential Revision: https://reviews.llvm.org/D112346
NAMELIST input can contain array subscripts with triplet notation.
The calculation of the default effective stride for the constructed
array descriptor was simply incorrect after the first dimension.
Differential Revision: https://reviews.llvm.org/D112347
A build-time check in a template class instantiation was applying
a test that's meaningful only for numeric types.
Differential Revision: https://reviews.llvm.org/D112345
A CHARACTER variable used as an output format may contain
unquoted tab characters, which are treated as if they had
been quoted. This is an extension supported by all other
Fortran compilers to which I have access.
Differential Revision: https://reviews.llvm.org/D112350
ExternalFileUnit::BeginReadingRecord() must be called at least once
during an external formatted READ statement before FinishReadingRecord().
In the case of a formatted external READ with no data items, the call
to finish processing of the format (which might have lingering control
items that need doing) was taking place before the call to BeginReadingRecord
from ExternalIoStatementState::EndIoStatement. Add a call to
BeginReadingRecord on this path.
Differential Revision: https://reviews.llvm.org/D112351
Don't try to convert INTEGER argument expressions to the kind of
the dummy argument when performing generic resolution; specific
procedures may be distinguished only by their kinds.
Differential Revision: https://reviews.llvm.org/D112240
NAMELIST array input does not need to fully define an array.
If another input item begins after at least one element,
it ends input into the array and the remaining items are
not modified.
The tricky part of supporting this feature is that it's not
always easy to determine whether the next non-blank thing in
the input is a value or the next item's name, esp. in the case
of logical data where T and F can be names. E.g.,
&group logicalArray = t f f t
= 1 /
should read three elements into "logicalArray" and then read
an integer or real variable named "t".
So the I/O runtime has to do some look-ahead to determine whether
the next thing in the input is a name followed by '=', '(', or '%'.
Since the '=' may be on a later record, possibly with intervening
NAMELIST comments, the runtime has to support a general form of
saving and restoring its current position. The infrastructure
in the I/O runtime already has to support repositioning for
list-directed repetition, even on non-positionable input sources
like terminals and sockets; this patch adds an internal RAII API
to make it easier to save a position and then do arbitrary
look-ahead.
Differential Revision: https://reviews.llvm.org/D112245
Allocatable dummy arguments can be used to distinguish
two specific procedures in a generic interface when
it is the case that exactly one of them is polymorphic
or exactly one of them is unlimited polymorphic. The
standard requires that an actual argument corresponding
to an (unlimited) polymorphic allocatable dummy argument
must also be an (unlimited) polymorphic allocatable, so an
actual argument that's acceptable to one procedure must
necessarily be a bad match for the other.
Differential Revision: https://reviews.llvm.org/D112237
A reference to an allocatable or pointer component must be applied
to a scalar base object. (This is the second part of constraint C919;
the first part is already checked.)
Differential Revision: https://reviews.llvm.org/D112241
The runtime library was emitting unformatted record headers and
footers when an external unit had no fixed RECL=. This is wrong
for sequential files, which should have headers & footers even
with RECL. Change to omit headers & footers from unformatted
I/O only for direct access files.
Differential Revision: https://reviews.llvm.org/D112243
Negative shift counts are of course valid for ISHFT when
shifting to the right. This patch decouples the folding of
ISHFT from that of SHIFTA/L/R and adds tests.
Differential Revision: https://reviews.llvm.org/D112244
This section of the documentation should've been deleted in:
https://reviews.llvm.org/D105811
I am submitting this without a review as it's an obvious omission.
This patch is extracted from D111337 to make is smaller.
It introduce utility functions to the FIRBuilder and add the MutableBox
files.
- genShape
- readCharLen
- getExtents
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D112207
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
This patch is extracted from D111337. It introduce the
CharacterExprHelper that helps dealing with character in FIR.
Reviewed By: schweitz, awarzynski
Differential Revision: https://reviews.llvm.org/D112140
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
This patch is extracted from D111337. It introduce the
CharacterExprHelper that helps dealing with character in FIR.
Reviewed By: schweitz, awarzynski
Differential Revision: https://reviews.llvm.org/D112140
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
This patch is extracted from D111337. It introduce the
CharacterExprHelper that helps dealing with character in FIR.
Reviewed By: schweitz, awarzynski
Differential Revision: https://reviews.llvm.org/D112140
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
This patch replaces the uses of std::map with llvm::DenseMap in the
flang-omp-report plugin. It also removed the 'constructClauseCount' map
due to no longer being needed after the plugin was stripped down.
This is a one of several patches focusing on switching containers from STL to LLVM's ADT library.
Reviewed By: kiranchandramohan, clementval
Differential Revision: https://reviews.llvm.org/D111977
This patch makes the following changes to flang-omp-report:
- Update 'normalize_clause_name' parameter to use llvm::StringRef instead of
std::sting.
- Change usages of std::tolower to llvm::toLower from
"ADT/StringExtras.h".
This is a one of several patches focusing on switching containers from STL to LLVM's ADT library.
Reviewed By: Leporacanthicus, clementval
Differential Revision: https://reviews.llvm.org/D111980
Extract part of D111337 in order to mke it smaller
and easier to review. This patch add some utility
functions to the FIRBuilder.
Add the following utility functions:
- getCharacterLengthType
- createStringLiteral
- locationToFilename
- characterWithDynamicLen
- sequenceWithNonConstantShape
- hasDynamicSize
These bring up the BoxValue implementation together with it.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: AlexisPerry
Differential Revision: https://reviews.llvm.org/D112074
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Extract some code from the big ptach D111337. This patch
contains some utility functions from the FIRBuidler.
List of utility functions added:
- getRegion
- getModule
- getKindMap
- getRefType
- getVarLenSeqTy
- getRealType
- createNullConstant
- createRealConstant
- createRealZeroConstant
- createGlobal
- createGlobalConstant
- createStringLitOp
- getNamedFunction
- getNamedGlobal
- createFunction
- addNamedFunction
- createBool
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D112057
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
In order to reduct the size of D111337. The IfBuilder and the two
utility functions genIsNotNull and genIsNull have been extracted in
a separate patch with dedicated unittests.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: Leporacanthicus
Differential Revision: https://reviews.llvm.org/D111796
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
```
[5.1] 2.21.2 THREADPRIVATE Directive
A variable that appears in a threadprivate directive must be declared in
the scope of a module or have the SAVE attribute, either explicitly or
implicitly.
A variable that appears in a threadprivate directive must not be an
element of a common block or appear in an EQUIVALENCE statement.
```
This patch supports the following checks for DECLARE TARGET Directive:
```
[5.1] 2.14.7 Declare Target Directive
A variable that is part of another variable (as an array, structure
element or type parameter inquiry) cannot appear in a declare
target directive.
A variable that appears in a declare target directive must be declared
in the scope of a module or have the SAVE attribute, either explicitly
or implicitly.
A variable that appears in a declare target directive must not be an
element of a common block or appear in an EQUIVALENCE statement.
```
As Fortran 2018 standard [8.5.16] states, a variable, common block, or
procedure pointer declared in the scoping unit of a main program,
module, or submodule implicitly has the SAVE attribute, which may be
confirmed by explicit specification.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D109864
Semantics is rejecting valid programs with NULL() actual arguments
to generic interfaces, including user-defined operators. Subclause
16.9.144(para 6) makes clear that NULL() can be a valid actual
argument to a generic interface so long as it does not produce
ambiguity. This patch handles those cases, revises existing
tests, and adjust an error message about NULL() operands to
appear less like a blanket prohibition.
Differential Revision: https://reviews.llvm.org/D111850
Fold the legacy intrinsic functions LGE, LGT, LLE, & LLT
by rewriting them into character relational expressions and
then folding those. Also fix folding of comparisons of
character values of distinct lengths: the shorter value must
be padded with blanks. (This fix exposed some bad test cases,
which are also fixed.)
Differential Revision: https://reviews.llvm.org/D111843
Semantics refuses valid ELEMENTAL subprograms without dummy arguments,
but there's no such constraint in the standard; indeed, subclause
15.8.2 discusses the meaning of calls to ELEMENTAL functions with
arguments. Remove the check and its test.
Differential Revision: https://reviews.llvm.org/D111832
This patch replaces all uses of std::vector with llvm::SmallVector in the flang-omp-report plugin.
This is a one of several patches focusing on switching containers from STL to LLVM's ADT library.
Reviewed By: Leporacanthicus
Differential Revision: https://reviews.llvm.org/D111709
Add the DoLoopHelper. Some helpers functions
to create fir.do_loop operations.
This code was part of D111337 and was extracted in order to
make the patch easier to review.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D111713
Co-authored-by: Valentin Clement <clementval@gmail.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Adds initial parsing and sema for the 'adjust_args' clause.
Note that an AST clause is not created as it instead adds its expressions
to the OMPDeclareVariantAttr.
Differential Revision: https://reviews.llvm.org/D99905
AffinePromotion and AffineDemotion passes where upstreamed
in their current status from fir-dev. In order to make sure everybody
is on the same page, this patch add some comments to state that.
Reviewed By: schweitz
Differential Revision: https://reviews.llvm.org/D111629
Search for the environment variable in the envp string passed to
ProgramStart. This doesn't work if the main program isn't Fortran.
Differential Revision: https://reviews.llvm.org/D111394
Precursor: https://reviews.llvm.org/D110200
Removed redundant ops from the standard dialect that were moved to the
`arith` or `math` dialects.
Renamed all instances of operations in the codebase and in tests.
Reviewed By: rriddle, jpienaar
Differential Revision: https://reviews.llvm.org/D110797
A recent patch to fix warnings from a Windows build regarding
inconsistent "struct" vs "class" usage missed a few code sites
and now the "latest-clang" build bot is also failing. This
patch should resolve those failing builds.
A recently added class constructor needs to be "explicit" to
prevent it from being available for use as a conversion, which
is breaking the MSVC build of flang.
B/O/Z integer output editing must not reflect any sign extension
of scalar output values. Add more size-dependent OutputInteger
I/O APIs and kind instantiations of EditIntegerOutput.
Differential Revision: https://reviews.llvm.org/D111678
The Fortran 2018 standard defines the concept of simple contiguity
in subclause 9.5.4 as a characteristic of arrays. So that scalars
may also be used in contexts where simply contiguous arrays are
allowed, f18 treats them as single-element arrays that are trivially
contiguous. This patch documents this semantic extension and
also adds comments to the predicate that implements the concept.
Differential Revision: https://reviews.llvm.org/D111679
An LLVM Flang build bot for Windows recently failed with a
bunch of warning messages. None were from recent changes to
the Fortran compiler; I suspect that a newer (or maybe older)
version of MSVC was being used, or perhaps a different set of
compiler options were temporarily applied to the build, since
the buildbot status went back to green shortly thereafter.
Most of the warnings looked bogus to me, but some are legitimate
concerns and we might as well clean them up. This patch does so.
Differential Revision: https://reviews.llvm.org/D111677
This patch upstream the cfg conversion pass. This pass
rewrite FIR loop-like operation to a CFG.
This patch is part of the upstreaming effort from fir-dev branch.
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Valentin Clement <clementval@gmail.com>
Reviewed By: schweitz
Differential Revision: https://reviews.llvm.org/D111095
As reported in https://bugs.llvm.org/show_bug.cgi?id=48145, name resolution for omp critical construct was failing. This patch adds functionality to help that name resolution as well as implementation to catch name mismatches.
The following semantic restrictions are therefore handled here:
- If a name is specified on a critical directive, the same name must also be specified on the end critical directive
- If no name appears on the critical directive, no name can appear on the end critical directive
- If a name appears on either the start critical directive or the end critical directive
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D110502
To get proper wrap-around behavior for the various kind parameter
values of the optional COUNT= and COUNT_MAX= dummy arguments to
the intrinsic subroutine SYSTEM_CLOCK, add an extra argument to
the APIs for lowering to pass the integer kind of the actual argument.
Avoid confusion by requiring that both actual arguments have the same
kind when both are present. The results of the runtime functions
remain std::int64_t and lowering should still convert them before
storing to the actual argument variables.
Rework the implementation a bit to accomodate the dynamic
specification of the kind parameter, and to clean up some coding
issues with preprocessing and templates.
Use the kind of the COUNT=/COUNT_MAX= actual arguments to determine
the clock's resolution, where possible, in conformance with other
Fortran implementations.
Differential Revision: https://reviews.llvm.org/D111281
Parallel sections directive borrows the semantic checks from both sections directive and parallel directive. Semantic checks for both are merged in main branch; this test case is added to make sure correct semantic checks upon merging the two.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D111438
Add two test for needExternalNameMangling.
- One varibale in a function
- One namelist in a module
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: schweitz
Differential Revision: https://reviews.llvm.org/D111544
Add explicit documentation for a couple of cases where the Fortran
standard has been observed to be ambiguous or nonspecific and we've
had to choose the behavior of the implementation from some possible
alternatives (and may be distinct from other implementations).
Differential Revision: https://reviews.llvm.org/D111446
Add rewrite patterns for fir.convert op canonicalization.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D111537
Co-authored-by: Valentin Clement <clementval@gmail.com>
Clean up InitFIR.h file.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D111539
Co-authored-by: Valentin Clement <clementval@gmail.com>
Update .clang-tidy file with the value used in fir-dev.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: rovka
Differential Revision: https://reviews.llvm.org/D111525
Co-authored-by: Valentin Clement <clementval@gmail.com>
This patch adds a new abstract class for frontend actions:
`PrescanAndSemaDebugAction`. It's almost identical to
`PrescanAndSemaAction`, but in the presence of semantic errors it does
not skip the corresponding `ExecuteAction` specialisation. Instead, it
runs it as if there were no semantic errors. This class is for developer
actions only (i.e. front-end driver options).
The new behaviour does not affect the return code from `flang-new -fc1`
when the input file is semantically incorrect. The return code is
inferred from the number of driver diagnostics generated in
`CompilerInstance::ExecuteAction` and this patch does not change that.
More specifically, the semantic errors are still reported and hence the
driver is able to correctly report that the compilation has failed (with
a non-zero return code).
This new base class is meant for debug actions only and
`DebugDumpAllAction` is updated to demonstrate the new behaviour. With
this change, `flang-new -fc1 -fdebug-dump-all` dumps the parse tree and
symbols for all input files, regardless of whether any semantic errors
were found.
This patch addresses https://bugs.llvm.org/show_bug.cgi?id=52097.
Differential Revision: https://reviews.llvm.org/D111308
Add pass that convert abstract result to function argument.
This pass is needed before the conversion to LLVM IR.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: schweitz
Differential Revision: https://reviews.llvm.org/D111146
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Upstream the character conversion pass.
Translates entities of one CHARACTER KIND to another.
By default the translation is to naively zero-extend or truncate a code
point to fit the destination size.
This patch is part of the upstreaming effort from fir-dev branch.
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Valentin Clement <clementval@gmail.com>
Reviewed By: schweitz
Differential Revision: https://reviews.llvm.org/D111405
Add affine demotion pass.
Affine dialect's default lowering for loads and stores is different from
fir as it uses the `memref` type. The `memref` type is not compatible with
the Fortran runtime. Therefore, conversion of memory operations back to
`fir.load` and `fir.store` with `!fir.ref<?>` types is required.
This patch is part of the upstreaming effort from fir-dev branch.
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Rajan Walia <walrajan@gmail.com>
Co-authored-by: Sourabh Singh Tomar <SourabhSingh.Tomar@amd.com>
Co-authored-by: Valentin Clement <clementval@gmail.com>
Reviewed By: schweitz
Differential Revision: https://reviews.llvm.org/D111257
Convert fir operations which satisfy affine constraints to the affine
dialect.
This patch is part of the upstreaming effort from fir-dev branch.
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Rajan Walia <walrajan@gmail.com>
Co-authored-by: Sourabh Singh Tomar <SourabhSingh.Tomar@amd.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Valentin Clement <clementval@gmail.com>
Reviewed By: schweitz, awarzynski
Differential Revision: https://reviews.llvm.org/D111155
Bit positions for the intrinsics IBCLR and IBSET and shift counts
for the intrinsics ISHFT/SHIFTA/SHIFTL/SHIFTR should be validated
when folding.
Differential Revision: https://reviews.llvm.org/D111327
Source lines with mismatched parentheses are hard cases for error
recovery in parsing, and the best error message (viz.,
"here's an unmatched parenthesis") can be emitted from the
prescanner.
Differential Revision: https://reviews.llvm.org/D111254#3046173
These functions were missing from the standard intrinsic module
IEEE_ARITHMETIC. IEEE_SCALB is an alias for the standard intrinsic
function SCALE(), and the others are defined as new builtin intrinsic
functions.
Differential Revision: https://reviews.llvm.org/D111253
Add the external name conversion pass needed for compiler
interoperability. This pass convert the Flang internal symbol name to
the common gfortran convention.
Clean up old passes without implementation in the Passes.ts file so
the project and fir-opt can build correctly.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: schweitz
Differential Revision: https://reviews.llvm.org/D111057
Partition libFIROptimizer into smaller libraries that reflect the
structure. Adapt potential problems.
This patch is part of the upstreaming effort from fir-dev branch. It's a
building stone to upstreaming transformations.
Reviewed By: schweitz
Differential Revision: https://reviews.llvm.org/D111055
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Partition libFIROptimizer into smaller libraries that reflect the
structure. Adapt potential problems.
This patch is part of the upstreaming effort from fir-dev branch. It's a
building stone to upstreaming transformations.
Reviewed By: schweitz
Differential Revision: https://reviews.llvm.org/D111055
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Partition libFIROptimizer into smaller libraries that reflect the
structure. Adapt potential problems.
This patch is part of the upstreaming effort from fir-dev branch. It's a
building stone to upstreaming transformations.
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Reviewed By: schweitz
Differential Revision: https://reviews.llvm.org/D111055
Blank input fields must be interpreted as zero, including the case of
virutal space characters generated from record padding at the end of
an input record. This stopped working sometime in the past few months
for real input (not sure when); here's a fix.
This bug was breaking FCVS test fm111.
Differential Revision: https://reviews.llvm.org/D110765
fir.array_update is only handling intrinsic assignments.
They are two big differences with user defined assignments:
1. The LHS and RHS types may not match, this does not play well
with fir.array_update that relies on both the merge and the
updated element to have the same type.
2. user defined assignment has a call semantics, with potential
side effects. So if a fir.array_update can hide a call, it traits
would need to be updated.
Instead of hiding more semantic in the fir.array_update, introduce
a new fir.array_modify op that allows de-correlating indicating that
an array value element is modified, and how it is modified.
This allow the ArrayValueCopy pass to still perform copy elision
while not having to implement the call itself, and could in general
be used for all kind of assignments (e.g. character assignment).
Update the alias analysis to not rely on the merge arguments (since
fir.array_modify has none).
Instead, analyze what is done with the element address.
This implies adding the ability to follow the users of fir.array_modify,
as well as being able to go through fir.store that may be generated to
store the RHS value in order to pass it to a user define routine.
This is done by adding a ReachCollector class to gather all array
accesses.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: schweitz
Differential Revision: https://reviews.llvm.org/D110928
Co-authored-by: Valentin Clement <clementval@gmail.com>
Fix some clang-tidy wrning in flang/Optimizer/Support and
remove explicit number of inlined elements for SmallVector. This
is mostly to sync with the changes from fir-dev.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: schweitz
Differential Revision: https://reviews.llvm.org/D111044
The THEN keyword in the "ELSE IF (test) THEN" statement is useless
syntactically, and to omit it is a common error (at least for me!)
that has poor error recovery. This patch changes the parser to
cough up a simple "expected 'THEN'" and still recognize the rest of
the IF construct.
Differential Revision: https://reviews.llvm.org/D110952
The first line of flang/include/flang/Runtime/magic-numbers.h
got split into two somehow; join it back up.
Differential Revision: https://reviews.llvm.org/D110965
According to OpenMP 5.0 spec document, the following semantic restrictions have been dealt with in this patch.
1. [sections construct] Orphaned section directives are prohibited. That is, the section directives must appear within the sections construct and must not be encountered elsewhere in the sections region.
Semantic checks for the following are not necessary, since use of orphaned section construct (i.e. without an enclosing sections directive) throws parser errors and control flow never reaches the semantic checking phase. Added a test case for the same.
2. [sections construct] Must be a structured block
Added test case and made changes to branching logic
3. [simd construct] Must be a structured block / A program that branches in or out of a function with declare simd is non conforming
4. Fixed !$omp do's handling of unlabeled CYCLEs
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D108904
All big enough parser, printer and verifier are moved to the cpp file.
This is one of the last one to be moved.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D110929
fir.negf op is replaced by mlir.negf and
fir.modf is just deleted.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D110932
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Valentin Clement <clementval@gmail.com>
Remove explicit number of inlined elements for SmallVector.
This patch is part of the upstreaming effort from fir-dev branch.
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Reviewed By: awarzynski
Differential Revision: https://reviews.llvm.org/D110912
Add the fir-char_convert op.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D110818
Co-authored-by: Valentin Clement <clementval@gmail.com>
Move the big builder out of the td file to the cpp file.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D110820
Revert "[flang][NFC] Add debug dump method to evaluate::Expr and semantics::Symbol"
This reverts commit b0e35fde21.
Revert "[flang] Add a wrapper for Fortran main program"
This reverts commit 2c1ce0755e.
Revert "[flang][NFC] Fix header comments in some runtime headers"
This reverts commit a63f57674d.
Follow up of https://reviews.llvm.org/D83397.
In folding, make pgmath usage conditional to C99 complex
support in C++. Disable warning in such case.
In lowering, use an empty class type to indicate C99 complex
type in runtime interface.
Add a unit test enforcing C99 complex can be processed
by FIR runtime interface builder.
Differential Revision: https://reviews.llvm.org/D110860
Add a C wrapper that calls the Fortran runtime initialization and
finalization routines as well as the compiled Fortran main program
_QQmain.
Place it in its own library to satisfy shared library builds since it
contains a C main function.
- cc7ac498f9 (diff-fa35a5efa62731fd2845e5e982eca9a2e36439783e11a4e4a463753c2160ec10R53)
- was created in flang/test/Examples/main.c in Eric's branch
Helps debugging when working with symbol/expression issue. The dump
method is easy to call in the debugger.
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Differential Revision: https://reviews.llvm.org/D110856
When the ProcRef is Symbol is a SubprogramDetails, the interface is
the SubprogramDetails. Do not return nullptr.
Differential Revision: https://reviews.llvm.org/D110853
Fold the transformational intrinsic function FINDLOC() for
all combinations of optional arguments and data types.
Differential Revision: https://reviews.llvm.org/D110757
The algorithm used to fold SQRT has some holes that
led to test failures; debug and add more tests.
Differential Revision: https://reviews.llvm.org/D110744
Support the extension intrinsic subroutines EXIT([status]) and ABORT()
in the intrinsic table and runtime support library. Lowering remains
to be done.
Differential Revision: https://reviews.llvm.org/D110741
Fine tuning after couple of upstreamed patches.
Rename the lenParams varaiables in buidlers to typeparams.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D110821
Co-authored-by: Valentin Clement <clementval@gmail.com>
Add pinned attributes and speicifc builders.
The pinned attribute helps mark those allocas in OpenMP regions that should not
be hoisted out by an alloca hoisting pass.
This patch is part of the upstreaming effort from fir-dev branch.
Coming from PR: https://github.com/flang-compiler/f18-llvm-project/pull/1065
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D110815
Co-authored-by: Valentin Clement <clementval@gmail.com>
Move fir.freemem and fir.store to the Memory SSA operations sections.
Move parser, printer and verifier of fir.store to the .cpp file.
This patch is part of the upstreaming effort from fir-dev branch.
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D110816
Move the parser, printer, verifier and builder out of the .td file.
Rename lenparams to typeparams to be in sync with fir-dev.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: rovka
Differential Revision: https://reviews.llvm.org/D110690
Move the parsers, printers and builders from the TableGen file
to the .cpp file. Remaining parsers, printers and builders will be
moved when we update the operations.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: schweitz
Differential Revision: https://reviews.llvm.org/D110626
Update the fir.alloca operation.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D110415
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Valentin Clement <clementval@gmail.com>
Updatet the fir.allocmem operation.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: schweitz
Differential Revision: https://reviews.llvm.org/D110412
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Move coor operand from variadic values to ArrayAttr.
Update assembly format.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D110652
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Valentin Clement <clementval@gmail.com>
The former is redundant because the later carries it as part of
its builder. Add a getContext() helper method to DialectAsmParser
to make this more convenient, and stop passing the context around
explicitly. This simplifies ODS generated parser hooks for attrs
and types.
This resolves PR51985
Recommit 4b32f8bac4 after fixing a dependency.
Differential Revision: https://reviews.llvm.org/D110796
The former is redundant because the later carries it as part of
its builder. Add a getContext() helper method to DialectAsmParser
to make this more convenient, and stop passing the context around
explicitly. This simplifies ODS generated parser hooks for attrs
and types.
This resolves PR51985
Differential Revision: https://reviews.llvm.org/D110796
Rearrange the contents of __builtin_* module files a little and
make sure that semantics implicitly USEs the module __Fortran_builtins
before processing each source file. This ensures that the special derived
types for TEAM_TYPE, EVENT_TYPE, LOCK_TYPE, &c. exist in the symbol table
where they will be available for use in coarray intrinsic function
processing.
Update IsTeamType() to exploit access to the __Fortran_builtins
module rather than applying ad hoc name tests. Move it and some
other utilities from Semantics/tools.* to Evaluate/tools.* to make
them available to intrinsics processing.
Add/correct the intrinsic table definitions for GET_TEAM, TEAM_NUMBER,
and THIS_IMAGE to exercise the built-in TEAM_TYPE as an argument and
as a result.
Add/correct/extend tests accordingly.
Differential Revision: https://reviews.llvm.org/D110356
Move the parser, printer and verifier to the .cpp file. Add builders
needed for lowering.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: schweitz, mehdi_amini
Differential Revision: https://reviews.llvm.org/D110686
Co-authored-by: Valentin Clement <clementval@gmail.com>
Move builders to .cpp file and update accordingly.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D110698
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Valentin Clement <clementval@gmail.com>
Add getFinalValueAttrName() and remove specified number of
inlined elements for SmallVector. This patch is mainly motivated
to help the upstreaming effort.
This patch is part of the upstreaming effort from fir-dev branch.
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Valentin Clement <clementval@gmail.com>
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D110710
The updated tests were originally added in
https://reviews.llvm.org/D109890 and are currently causing some
buildbots to fail.
This patch:
* adds missing items in the `REQUIRERS` list in tests
* adds `flangOmpReport` (the plugin library added in D109890) as a CMake
dependency for tests (only when examples are enabled)
Differential Revision: https://reviews.llvm.org/D110682
Rename `lenParams` to `typeparams` to be in sync with fir-dev.
This patch is part of the upstreaming effort from fir-dev branch.
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Valentin Clement <clementval@gmail.com>
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D110645
This plugin parses Fortran files and creates a
YAML report with all the OpenMP constructs and
clauses seen in the file.
The following tests have been modified to be
compatible for testing the plugin, hence why
they are not reused from another directory:
- omp-atomic.f90
- omp-declarative-directive.f90
- omp-device-constructs.f90
The plugin outputs a single file in the same
directory as the source file in the following format:
`<source-file-name>.yaml`
Building the plugin:
`ninja flangOmpReport`
Running the plugin:
`./bin/flang-new -fc1 -load lib/flangOmpReport.so -plugin flang-omp-report -fopenmp <source_file.f90>`
Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com>
Co-authored-by: Stuart Ellis <stuart.ellis@arm.com>
Reviewed By: awarzynski, kiranchandramohan
Differential Revision: https://reviews.llvm.org/D109890
Rename `lenParams` to `typeparams` to be in sync with fir-dev.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D110628
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Recommit https://reviews.llvm.org/D109813 and
https://reviews.llvm.org/D109814.
This implements the second and final entry point for GET_COMMAND_ARGUMENT,
handling the VALUE, STATUS and ERRMSG parameters.
It has a small fix in that we're now using memcpy instead of strncpy
(which was a bad idea to begin with, since we're not actually interested
in a string copy).
This reverts commit 0446f1299f and
df6302311f.
There's a warning on flang-aarch64-latest-gcc related to strncpy using
the result of strlen as a bound. I'll recommit with a fix.
Add the fir.save_result operation. It is use to save an
array, box, or record function result SSA-value to a memory location
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D110407
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Valentin Clement <clementval@gmail.com>
Update the fir.insert_on_range operation. Add a better description,
builder and verifier.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D110389
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Valentin Clement <clementval@gmail.com>
Implement the final part of GET_COMMAND_ARGUMENT, i.e. the handling of
ERRMSG. This uses some of the infrastructure in stat.h and gets rid of
the magic numbers that we were using for return codes.
Differential Revision: https://reviews.llvm.org/D109814
Partial implementation for the second entry point for
GET_COMMAND_ARGUMENT. It handles the VALUE and STATUS arguments, and
doesn't touch ERRMSG.
Differential Revision: https://reviews.llvm.org/D109813
Implement the ArgumentLength entry point of GET_COMMAND_ARGUMENT. Also
introduce a fixture for the tests.
Note that this also changes the interface for ArgumentLength from
returning a 4-byte integer to returning an 8-byte integer.
Differential Revision: https://reviews.llvm.org/D109227
Enforce constraints C1034 & C1038, which disallow the use
of otherwise valid statements as branch targets when they
appear in FORALL &/or WHERE constructs. (And make the
diagnostic message somewhat more user-friendly.)
Differential Revision: https://reviews.llvm.org/D109936
A defined assignment subroutine invoked in the context of a WHERE
statement or construct must necessarily be elemental (C1032).
Differential Revision: https://reviews.llvm.org/D109932
This patch is part of the upstreaming effort from fir-dev branch.
Add a description for the fir.array_load opeartion and rename lenParams to typeparams.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D110393
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Add support to create unique name for namelist group and be able to
deconstruct them.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D110331
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>