aboutsummaryrefslogtreecommitdiff
path: root/flang
AgeCommit message (Collapse)AuthorFilesLines
2022-10-11[flang] Use the ShapedType::kDynamicSize constant instead of hardcoding it.Alexander Belyaev1-2/+4
Differential Revision: https://reviews.llvm.org/D135675
2022-10-11[flang] Fix buildbot failure after D135610.Slava Zakharin1-0/+4
Differential Revision: https://reviews.llvm.org/D135684
2022-10-11[flang] Add cpowi function to runtime and use instead of pgmathDavid Truby8-8/+324
This patch adds a cpowi function to the flang runtime, and switches to using that function instead of pgmath for complex number to integer power operations. Differential Revision: https://reviews.llvm.org/D134889
2022-10-11[flang] Support GNU extensions IARGC and GETARG in runtimePeixin-Qiao2-5/+29
The GNU extension intrinsic IARGC is equivalent to COMMAND_ARGUMENT_COUNT, and the GETARG is similar to GET_COMMAND_ARGUMENT, but with less arguments. Reuse the runtime of COMMAND_ARGUMENT_COUNT and GET_COMMAND_ARGUMENT for IARGC and GETARG. Reviewed By: klausler Differential Revision: https://reviews.llvm.org/D133558
2022-10-11[flang][NFC] Fix typos in FIROps.tdPeixin-Qiao2-24/+19
Reviewed By: kiranchandramohan Differential Revision: https://reviews.llvm.org/D135570
2022-10-11[flang][NFC] Fix fir::ConvertOp descriptionPeixin-Qiao1-2/+3
According to the support of fir::ConvertOp conversion in CodeGen.cpp, it also supports integer to pointer conversion and pointer to integer conversion. The entity can be array, and the conversion type can be pointer to array. Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D135571
2022-10-10[flang] Add type-specific runtime entries for Minloc/Maxloc.Slava Zakharin8-42/+312
We used to have a big switch statement over the type categories and kinds inside Minloc/Maxloc. After D133051 the switch grew bigger, and this changed inlining decisions made by GCC (the build compiler). Some of the simple methods stopped being inlined, and this caused slight performance regression in Polyhedron/gas_dyn2. This change adds separate entries for real/integer data types to let them be optimized separately. Differential Revision: https://reviews.llvm.org/D135610
2022-10-10[flang] Allow conversion from boxed derived type to fir.classValentin Clement5-12/+86
This patch updates the fir.convert operation's verifier to allow conversion from !fir.box<!fir.type<T>> to !fir.class<!fir.type<T>>. Other conversion involving fir.class are likely needed but will be added when lowering needs them. Reviewed By: PeteSteinfeld Differential Revision: https://reviews.llvm.org/D135445
2022-10-07[flang][nfc] Relocate a few driver testsAndrzej Warzynski6-19/+11
When the work on the Flang driver started, we created 2 test directories: * flang/test/Frontend/ * flang/test/Driver/ That was mostly done to model what Clang was doing. In practice, we stopped using "flang/test/Frontend/" early on and most Flang driver tests are currently located in "flang/test/Driver/". This patch moves the remaining tests from the latter into the former directory. This change also means that we can re-use test input files, i.e. flang/test/Frontend/Inputs/hello-world.f90 can be replaced with flang/test/Driver/Inputs/hello.f90. To this end, the affected test is updated (multiple-input-files.f90). Differential Revision: https://reviews.llvm.org/D130633
2022-10-07[Flang] Use the ultimate symbol in a DeallocateStmt checkKiran Chandramohan2-1/+15
Use the ultimate symbol while calling the `IsAllocatableOrPointer` function to ensure that the check works as expected for host-associated symbols. Fixes #58178 Reviewed By: PeteSteinfeld Differential Revision: https://reviews.llvm.org/D135443
2022-10-07[flang] Allow fir.class in AnyRefOrBoxValentin Clement2-2/+32
Some operations are using `AnyRefOrBox` to specify the type of the operands or attribute. This is the case for the `fir.coordinate_of` operation. This patch updates the `AnyRefOrBox` to accept `BaseBoxType` instead of only `BoxType`. Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D135442
2022-10-07[flang][NFC] Update fir.dispatch format in docValentin Clement1-2/+2
2022-10-06[flang] Represent TARGET for globals with 'target' attribute.Slava Zakharin10-38/+81
TARGET dummy arguments have fir.target attribute attached to them, but globals do not have any sign of TARGET. This patch adds target attribute for globals, which can be queried via ::fir::GlobalOp::getTarget(). Differential Revision: https://reviews.llvm.org/D135313
2022-10-06[flang] Correct epistemological edge cases for IS_CONTIGUOUS foldingPeter Klausler4-19/+77
Don't return a hard .FALSE. when folding IS_CONTIGUOUS() unless the subscript triplets are discontiguous and array section is nonempty, or if the array section is nonempty and there is a vector subscript. Differential Revision: https://reviews.llvm.org/D135334
2022-10-06fixPeter Klausler1-1/+0
2022-10-06[flang][runtime] Handle array components in NAMELIST inputPeter Klausler1-0/+1
A namelist input item that is a derived type component reference needs additional processing when the base item or the component is an array. When both have rank > 0, the component reference must of course be subscripted. (Fixes https://gitlab-master.nvidia.com/fortran/f18-stage/-/issues/999, NAG test t/tz2.)
2022-10-06[flang][runtime] Handle array components in NAMELIST inputPeter Klausler1-1/+36
A namelist input item that is a derived type component reference needs additional processing when the base item or the component is an array. When both have rank > 0, the component reference must of course be subscripted. Differential Revision: https://reviews.llvm.org/D135218
2022-10-06[flang] Supply missing source location for a messagePeter Klausler2-1/+4
An error message in semantic analysis of SELECT TYPE type guards doesn't allow for the possibility of failure from FindSourceLocation(), and that can happen when the type guard is just an intrinsic type name like "type is (character)". Deal with it. Differential Revision: https://reviews.llvm.org/D135217
2022-10-06[flang] Improve syntax error messages by fixing withMessage() parser combinatorPeter Klausler6-35/+44
The parser combinator withMessage("error message"_err_en_US, PARSER) is meant to run the parser PARSER and, if it fails, override its error messages if it failed silently or it was unable to recognize any tokens at all. This gives the parser a way to avoid emitting some confusing or missing error messages. Unfortunately, the implementation could sometimes lose track of whether any tokens had been recognized, leading to problems with outer usage of withMessage() and also -- more seriously -- with ParseState::CombineFailedParses(). That's a utility that determines which error messages to retain when two or more parsers have been attempted at the same starting point and none of them succceed. Its policy is to retain the state from the parser that consumed the most input text before failing, so long as it had recognized at least one token. So anyway, fix up withMessage(), adjust the tests, and add a test of the original motivating confusing error situation, in which a syntax error in a COMMON statement was being diagnosed as a problem with a statement function definition because withMessage() had lost the fact that the parse of the COMMON statement had recognized some tokens, and the last attempted parse later was a failed attempt to parse a statement function. Differential Revision: https://reviews.llvm.org/D135216
2022-10-06[flang] Add missing source location to a semantic error messagePeter Klausler2-0/+16
Ensure that the semantic error "An allocatable or pointer component reference must be applied to a scalar base" is emitted with a source code location. Differential Revision: https://reviews.llvm.org/D135215
2022-10-06[flang][NFC] Document Fortran aliasing rulesPeter Klausler1-0/+355
Summarize current understanding of Fortran's guarantees to a compiler (or in other words, restrictions on programs and programmers) about aliasing. Differential Revision: https://reviews.llvm.org/D135214
2022-10-06[flang] Clarify edge case of host association and generic interfacesPeter Klausler2-20/+48
Name resolution was mishandling cases of generic interfaces and specific procedures (sometimes complicatd by use of the same name for each) when the specific procedure was accessed by means of host association; only the scope of the generic interface definition was searched for the specific procedure. Also search enclosing scopes in the usual way. Differential Revision: https://reviews.llvm.org/D135213
2022-10-06[flang] Use assembly format for fir.dispatchValentin Clement5-57/+19
Remove custom parser/printer and make use of the assembly format for the fir.dispatch operation. Depends on D135358 Reviewed By: PeteSteinfeld, jeanPerier Differential Revision: https://reviews.llvm.org/D135363
2022-10-06[flang][runtime] When NAMELIST input hits EOF, signal END, not an errorPeter Klausler1-1/+5
NAMELIST input processing in the runtime support library treats an end-of-file found while searching for the initial '&' character as an error condition, but it really should be distinguishable. Call SignalEnd() rather than SignalError(). Differential Revision: https://reviews.llvm.org/D135212
2022-10-06[flang] Selectors whose expressions are pointers returned from functions are ↵Peter Klausler5-17/+99
valid targets An ASSOCIATE or SELECT TYPE statement's selector whose "right-hand side" is the result of a reference to a function that returns a pointer must be usable as a valid target (but not as a pointer). Differential Revision: https://reviews.llvm.org/D135211
2022-10-06[flang] Delay parse tree rewriting for I/O UNIT=func()Peter Klausler4-30/+92
When an I/O statement's UNIT= specifier is a variable that is a function reference, parse tree rewriting may determine the wrong type of the result because generic resolution has not yet been performed. So move this bit of parse tree rewriting into I/O semantic checking so that the right handling (integer -> external file unit number, character pointer -> internal I/O) applies. Differential Revision: https://reviews.llvm.org/D135210
2022-10-06[flang] Ignore errors on declarations in interfaces that "have no effect"Peter Klausler2-21/+54
Fortran strangely allows declarations to appear in procedure interface definitions when those declarations do not contribute anything to the characteristics of the procedure; in particular, one may declare local variables that are neither dummy variables nor function results. Such declarations "have no effect" on the semantics of the program, and that should include semantic error checking for things like special restrictions on PURE procedures. Differential Revision: https://reviews.llvm.org/D135209
2022-10-06[flang] Ensure USE associations of shadowed procedures are emitted to module ↵Peter Klausler2-4/+63
files When a generic interface in a module shadows a procedure of the same name that has been brought into scope via USE association, ensure that that USE association is not lost when the module file is written. Differential Revision: https://reviews.llvm.org/D135207
2022-10-06[flang] Error message situation should be a warningPeter Klausler4-4/+35
f18 emits an error message when the same name is used in a scope for both a procedure and a generic interface, and the procedure is not a specific procedure of the generic interface. It may be questionable usage, and not portable, but it does not appear to be non-conforming by a strict reading of the standard, and many popular Fortran compilers accept it. Differential Revision: https://reviews.llvm.org/D135205
2022-10-06[flang] Don't force SET_EXPONENT(I=...) argument to integer(4)Peter Klausler3-13/+24
The implementation of the folding code for SET_EXPONENT() was written in such a fashion as to convert the I= actual argument value to a 32-bit integer. Which is usually not a problem, but it's not always correct and a test case ran into trouble with it. Fix to allow any kind of INTEGER without conversion. Differential Revision: https://reviews.llvm.org/D135203
2022-10-06[flang] Update fir.dispatch operationValentin Clement5-23/+74
Update the `fir.dispatch` operation to prepare the lowering part. `nopass` and `pass_arg_pos` attributes are added in the arguments list so accessors are generated by MLIR tablegen. A verifier is added as well as some tests. This patch is part of the implementation of the poltymorphic entities. https://github.com/llvm/llvm-project/blob/main/flang/docs/PolymorphicEntities.md Reviewed By: jeanPerier, PeteSteinfeld Differential Revision: https://reviews.llvm.org/D135358
2022-10-06[flang] Add a "not yet implemented" message for large, constant arraysPeter Steinfeld1-0/+3
Rather than crashing in llvm code, nip things in the bud. Differential Revision: https://reviews.llvm.org/D135321
2022-10-05[flang] Keep current polymorphic implementation under a flagValentin Clement5-2/+28
It is useful for couple of test suite like NAG to keep failing with a TODO until the polymorphic entities is implemented all the way done to codegen. This pass adds a flag to LoweringOptions for experimental development. This flag is off by default and can be enable in `bbc` with `-polymorphic-type`. Options can be added in the driver and tco when needed. Reviewed By: PeteSteinfeld Differential Revision: https://reviews.llvm.org/D135283
2022-10-05[flang] Fixed build issue after 88f07a736bbc3f0062d7d8f4032f0b54aff5c018Slava Zakharin1-1/+1
nullptr matches both against ::mlir::UnitAttr and ::mlir::TypeRange, so the following two candidates fit: static void mlir::omp::OrderedRegionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::UnitAttr simd) static void mlir::omp::OrderedRegionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/bool simd = false)
2022-10-05Revert "[flang] Add -fpass-plugin option to Flang frontend"Mats Petersson10-75/+2
This reverts commit 43fe6f7cc35ded691bbc2fa844086d321e705d46. Reverting this as CI breaks. To reproduce, run check-flang, and it will fail with an error saying .../lib/Bye.so not found in pass-plugin.f90
2022-10-05[flang] Deallocate polymorphic and unlimited polymorphic intent(out) ↵Valentin Clement3-3/+17
allocatable with runtime Polymorphic and unlimited polymorphic entities should be handled by runtime. This patch update the condition in `genDeallocate` to force polymorphic and unlimited polymorphic entities to be deallocated through a runtime call and not inlined. Depends on D135143 Reviewed By: jeanPerier, PeteSteinfeld Differential Revision: https://reviews.llvm.org/D135144
2022-10-05[flang][OpenMP] Support privatization for single constructPeixin Qiao4-52/+120
This supports the lowering of private and firstprivate clauses in single construct. The alloca ops are emitted in the entry block according to https://llvm.org/docs/Frontend/PerformanceTips.html#use-of-allocas, and the load/store ops are emitted in the single region. The data race problem is handled in OMPIRBuilder. That is, the barrier is emitted in OMPIRBuilder. Co-authored-by: Nimish Mishra <neelam.nimish@gmail.com> Reviewed By: kiranchandramohan Differential Revision: https://reviews.llvm.org/D128596
2022-10-05[flang] Update to fir::isUnlimitedPolymorphicType and fir::isPolymorphicType ↵Valentin Clement4-3/+162
functions This patch update the fir::isUnlimitedPolymorphicType function to reflect the chosen design. It adds also a fir::isPolymorphicType function. Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D135143
2022-10-04[flang] Add -fpass-plugin option to Flang frontendTarun Prabhu10-2/+75
Add the -fpass-plugin option to flang which dynamically loads LLVM passes from the shared object passed as the argument to the flag. The behavior of the option is designed to replicate that of the same option in clang and thus has the same capabilities and limitations. - Multiple instances of -fpass-plugin=path-to-file can be specified and each of the files will be loaded in that order. - The flag can be passed to both flang-new and flang-new -fc1. Differential Revision: https://reviews.llvm.org/D129156
2022-10-04[flang][tco] Engineering option for running only CodeGen passes.Slava Zakharin2-3/+26
This option allows running only CodeGen passes and then translating FIR to LLVM IR. I am using it to fetch optimized FIR after bbc, hand-modify it and then produce LLVM IR that can be fed to clang.
2022-10-04[flang] Lower TYPE(*) as fir.box<none>Valentin Clement6-12/+34
This patch lowers `TYPE(*)` correctly to fir.box<none>. Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D135141
2022-10-04[flang] Lower polymorphic entities types in dummy argument and function resultValentin Clement16-30/+238
This patch updates lowering to produce the correct fir.class types for various polymorphic and unlimited polymoprhic entities cases. This is only the lowering. Some TODOs have been added to the CodeGen part to avoid errors since this part still need to be updated as well. The fir.class<*> representation for unlimited polymorphic entities mentioned in the document has been updated to fir.class<none> to avoid useless work in pretty parse/printer. This patch is part of the implementation of the poltymorphic entities. https://github.com/llvm/llvm-project/blob/main/flang/docs/PolymorphicEntities.md Depends on D134957 Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D134959
2022-10-03[flang] Skip creating AggregateStores for common block associated aggregatesJonathon Penix2-0/+38
Previously, AggregateStores were created for aggregates associated with common blocks. As a) AggregateStoreMap uses scope and offset information to search for aggregate stores and b) variables related to common blocks have their offsets set relative to the common block itself, if there were multiple equivalences and at least one involved variables defined in a common block there was an opportunity for the scope/offset pairs to match between distinct aggregate stores. As a result, entries in AggregateStoreMap could collide, resulting in incorrect stores being returned for a particular variable. To prevent these collisions, skip creating AggregateStores for aggregates which are associated with common blocks. This information was already unused as aggregates associated with common blocks are handled by instantiateCommon. Fixes https://github.com/llvm/llvm-project/issues/57749 Differential Revision: https://reviews.llvm.org/D134828
2022-10-03[flang] Write semantics tests for the FORM TEAM statement.Hussain Kadhem3-0/+105
Reviewed By: ktras Differential Revision: https://reviews.llvm.org/D134205
2022-10-03[flang] Add Sparc support to Optimizer/CodeGen/Target.cppRainer Orth2-1/+193
As described in Issue #57642, `flang` currently lacks SPARC support in `Optimizer/CodeGen/Target.cpp`, which causes a considerable number of tests to `FAIL` with error: flang/lib/Optimizer/CodeGen/Target.cpp:310: not yet implemented: target not implemented This patch fixes this by following GCC`s documentation of the ABI described in the Issue. Tested on `sparcv9-sun-solaris2.11`. Differential Revision: https://reviews.llvm.org/D133561
2022-10-03[flang] Do not resolve TRIM/REPEAT length to its argument lengthJean Perier2-3/+24
For TRIM and REPEAT calls, semantics was creating ProcedureDesignators using the length parameter of the arguments. This caused bugs when folding LEN(TRIM(char_explicit_constant_length)). The same did not appeared in folding for REPEAT because it is rewritten at a higher level to LEN(c)*N. This is not only a folding issue since any place (like lowering) may try to use the bad length parameter from the created ProcedureDesignator. Update intrinsic resolution to not copy the length parameter for TRIM and REPEAT. Differential Revision: https://reviews.llvm.org/D134970
2022-10-03[flang][NFC] Use prefixed accessors for fircg dialectValentin Clement3-56/+55
The raw accessor is going away soon so switch to prefixed accessors in the fircg dialect. The main dialect was switched some months ago. https://github.com/llvm/llvm-project/issues/58090 Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D135061
2022-10-03[flang] Make real type of kind 10 target dependentPeixin Qiao11-36/+210
The real(10) is supported on x86_64. On aarch64, the value of selected_real_kind(16) should be 16 rather than 10 since real(10) is not supported on x86_64. Previously, the real type support check is not target dependent. Support it now through the target triple information. Reviewed By: clementval Differential Revision: https://reviews.llvm.org/D134021
2022-10-02[flang] Introduce fir.class typeValentin Clement6-10/+82
Introduce a new ClassType for polymorphic entities. A fir.class type is similar to a fir.box type in many ways and is also base on the BaseBoxType. This patch is part of the implementation of the poltymorphic entities. https://github.com/llvm/llvm-project/blob/main/flang/docs/PolymorphicEntities.md Depends on D134956 Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D134957
2022-10-02[flang] Introduce BaseBoxTypeValentin Clement3-2/+37
Introduce a BaseBoxType to be used by BoxType and the a new ClassType that is introduced in a follow up patch. This patch is part of the implementation of the poltymorphic entities. https://github.com/llvm/llvm-project/blob/main/flang/docs/PolymorphicEntities.md Reviewed By: PeteSteinfeld Differential Revision: https://reviews.llvm.org/D134956