summaryrefslogtreecommitdiff
path: root/flang
Commit message (Collapse)AuthorAgeFilesLines
* [flang] Apply the check for the constraint `C1172` to more stmtsKatherine Rasmussen2023-05-173-0/+145
| | | | | | | | | | | Apply the check for the constraint `C1172` to `unlock-stmt`, `change-team-stmt`, `end-team-stmt`, and `critical-stmt`, which all have `sync-stat-lists` and so `C1172` applies to them. Add a test to check the `sync-stat-lists` for these 4 statements. Reviewed By: PeteSteinfeld Differential Revision: https://reviews.llvm.org/D150745
* [flang] Fix an unused variable warningKazu Hirata2023-05-171-1/+0
| | | | | | | This patch fixes: flang/lib/Semantics/runtime-type-info.cpp:1275:12: error: unused variable 'name' [-Werror,-Wunused-variable]
* [flang] Non-type-bound defined IO loweringV Donaldson2023-05-1716-203/+741
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Generate supporting data structures and calls to new runtime IO functions for defined IO that accesses non-type-bound procedures, such as `wft` in: module m1 type t integer n end type interface write(formatted) module procedure wft end interface contains subroutine wft(dtv, unit, iotype, v_list, iostat, iomsg) class(t), intent(in) :: dtv integer, intent(in) :: unit character(*), intent(in) :: iotype integer, intent(in) :: v_list(:) integer, intent(out) :: iostat character(*), intent(inout) :: iomsg iostat = 0 write(unit,*,iostat=iostat,iomsg=iomsg) 'wft was called: ', dtv%n end subroutine end module module m2 contains subroutine test1 use m1 print *, 'test1, should call wft: ', t(1) end subroutine subroutine test2 use m1, only: t print *, 'test2, should not call wft: ', t(2) end subroutine end module use m1 use m2 call test1 call test2 print *, 'main, should call wft: ', t(3) end
* [flang][hlfir] Fixed symbol lookup for character returns.Slava Zakharin2023-05-172-0/+40
| | | | | | | | | Symbols corresponding to entries returning character results must be mapped to EmboxCharOp, first, before we can map them to DeclareOp. The code may be reworked after HLFIR is enabled by default, but right now it seems like an acceptable solution to me. Differential Revision: https://reviews.llvm.org/D150749
* Revert "Reland "[CMake] Bumps minimum version to 3.20.0.""Nico Weber2023-05-173-3/+17
| | | | | | | | | | | | | | This reverts commit 65429b9af6a2c99d340ab2dcddd41dab201f399c. Broke several projects, see https://reviews.llvm.org/D144509#4347562 onwards. Also reverts follow-up commit "[OpenMP] Compile assembly files as ASM, not C" This reverts commit 4072c8aee4c89c4457f4f30d01dc9bb4dfa52559. Also reverts fix attempt "[cmake] Set CMP0091 to fix Windows builds after the cmake_minimum_required bump" This reverts commit 7d47dac5f828efd1d378ba44a97559114f00fb64.
* [flang] Catch (and fix) attempts to create an invalid source range for a ScopePeter Klausler2023-05-172-5/+47
| | | | | | | | | | | | | | | When Scope::AddSourceRange() is called to extend the scope's source range to include another snippet from a cooked character stream, add a check to ensure that the new range is part of the same cooked character stream as the rest of the scope. And fix the bug that was causing such invalid source ranges to be created: a submodule's Scope is a children of its parent's in the Scope tree, but it may or may not be part of the same source file, and it is certainly not enclosed in the parent's source range. So don't propagate Scope source range expansion from a submodule to its parent. Differential Revision: https://reviews.llvm.org/D150714
* [flang][hlfir] Implement the scheduling part of hlfir.forall codegenJean Perier2023-05-1710-17/+1112
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The lowering of hlfir.forall to loops (and later hlfir.where) requires doing a data dependency analysis to avoid creating temporary storage for every control/mask/rhs/lhs expressions. The added code implements a data dependency analysis for the hlfir ordered assignment trees (it is not specific to Forall since these nodes includes Where, user defined assignments, and assignment to vector subscripted entities, but the added code is only plugged and tested with hlfir.forall in this patch). This data dependency analysis returns a "schedule", which is a list of runs containing actions. Each runs will result in a single loop nest evaluating all its action "at the same time" inside the loop body. Actions may either evaluating an assignment, or saving some expression evaluation (the value yielded inside the ordered assignment hlfir operations) in a temporary storage before doing the assignment that requires this expression value but may "conflict" with it. A "conflict" is a read in an expression E to a variable that is, or may be (analysis is conservative), written by an assignment that depends on E. The analysis is based on MLIR SideEffectInterface and fir AliasAnalysis which makes it generic. For now, the codegen that will apply the schedule and rewrite the hlfir.forall into a set of loops is not implemented, but the scheduling is tested on its own (from Fortran, because it allows testing many cases in very readable fashions). The current scheduling has limitations, for instance "forall(i=1, 10) x(i)=2*x(i)" does not require saving the RHS values for all "i" before doing the assignments since the RHS does not depend on values computed during previous iterations. Any user call will also trigger a conservative assumption that there is a conflict. Finally, a lot of operations are missing memory effect interfaces (especially in HLFIR). This patch adds a few so that it can be tested, but more will be added in later patches. Differential Revision: https://reviews.llvm.org/D150455
* [cmake] Correct option to LLVM_FORCE_USE_OLD_TOOLCHAINJonas Hahnfeld2023-05-171-1/+1
| | | | This option was renamed a long time ago in commit 388cefa78d.
* [flang] Fix llvm-test-suite/Fortran/gfortran/torture/execute/st_function_1.f90Peter Klausler2023-05-161-10/+14
| | | | | | I just broke the test llvm-test-suite/Fortran/gfortran/torture/execute/st_function_1.f90 with a recent patch. The bug was obvious, as is the fix, which works, so I'm just pushing it directly to make the build bots happy.
* [flang] Correct overriding (or not) of inaccessible bindingsPeter Klausler2023-05-1610-32/+552
| | | | | | | | | | | Fortran doesn't allow inaccessible procedure bindings to be overridden, and this needs to apply to generic resolution. When resolving a type-bound generic procedure from another module, ensure only that the most extended override from its module is used if it is PRIVATE, not a later apparent override from another module. Differential Revision: https://reviews.llvm.org/D150721
* [flang] Fix bogus errors about CONTIGUOUS attributePeter Klausler2023-05-162-13/+17
| | | | | | | | | Incorrect error messages were issuing for symbol table entries with the CONTIGUOUS attribute that didn't deserve them, like host association symbols. Put the CONTIGUOUS check into CheckObjectEntity(). Differential Revision: https://reviews.llvm.org/D150712
* [flang] Finer control over warningsPeter Klausler2023-05-1631-190/+235
| | | | | | | | | | | Establish a set of optional usage warnings, and enable some only in "-pedantic" mode that, in our subjective experience with application codes, seem to issue frequently without indicating usage that really needs to be corrected. By default, with this patch the compiler should appear to be somewhat less persnickety but not less informative. Differential Revision: https://reviews.llvm.org/D150710
* [flang] Add check for constraints on event-stmtsKatherine Rasmussen2023-05-169-22/+181
| | | | | | | | | | | In the CoarrayChecker, add checks for the constraints C1177 and C1178 for event-wait-stmt. Add event-post-stmt to the check for the constraints for sync-stat-list. Add a check for the constraint C1176 on event-variable. Reviewed By: PeteSteinfeld Differential Revision: https://reviews.llvm.org/D137204
* Revert "[flang] Add check for constraints on event-stmts"Katherine Rasmussen2023-05-169-181/+22
| | | | This reverts commit 9725c740fbe7841a7aed57ca35f83d28aac1814c.
* [Flang][OpenMP][Semantics] Added missing HostAssoc check for use_device_ptr ↵Raghu Maddhipatla2023-05-161-1/+1
| | | | | | | | | | test. Missed adding this check in previous commit so adding it through separate commit. Reviewed By: raghavendhra Differential Revision: https://reviews.llvm.org/D150626
* [flang] Parenthesize RHS arguments to defined assignments (bug #62599)Peter Klausler2023-05-164-618/+657
| | | | | | | | | | | | | The right-hand sides of assignment statements are always expressions, never variables. When an assignment statement is converted into a call to a defined assignment subroutine, and the actual argument being associated with the second dummy argument is a variable, and the dummy argument does not have the VALUE attribute, wrap it with parentheses so that lowering will pass it by means of a temporary. Fixes https://github.com/llvm/llvm-project/issues/62599. Differential Revision: https://reviews.llvm.org/D150331
* [flang] Apply default module accessibility rules a second time (bug#62598)Peter Klausler2023-05-165-7/+45
| | | | | | | | | | | Apply the default PUBLIC/PRIVATE accessibility of a module to its symbols a second time after it is known that all symbols, including implicitly typed names from NAMELIST groups and specification expressions in module subprograms, have been created in its scope. Fixes https://github.com/llvm/llvm-project/issues/62598. Differential Revision: https://reviews.llvm.org/D150307
* [flang] Don't mistakenly tokenize a Hollerith literal from "DO 100 H=..." ↵Peter Klausler2023-05-162-3/+15
| | | | | | | | | | | (bug #58732) After tokenizing an identifier, don't allow the next token to be a Hollerith literal. Fixes https://github.com/llvm/llvm-project/issues/58732. Differential Revision: https://reviews.llvm.org/D150406
* [flang] Fixed comparison for derived types constants.Slava Zakharin2023-05-163-0/+15
| | | | | | | The two constants should be equal only if their derived types are the same. This fixes regression caused by D150380. Differential Revision: https://reviews.llvm.org/D150634
* [flang] Add check for constraints on event-stmtsKatherine Rasmussen2023-05-159-22/+181
| | | | | | | | | | | In the CoarrayChecker, add checks for the constraints C1177 and C1178 for event-wait-stmt. Add event-post-stmt to the check for the constraints for sync-stat-list. Add a check for the constraint C1176 on event-variable. Reviewed By: PeteSteinfeld Differential Revision: https://reviews.llvm.org/D137204
* [flang][openacc] Lower host_data constructValentin Clement2023-05-152-1/+110
| | | | | | | | | | Lower host_data construct to the acc.host_data operation. Depends on D150289 Reviewed By: razvanlupusoru, jeanPerier Differential Revision: https://reviews.llvm.org/D150290
* [flang][runtime] Fixed memory leak in Assign().Slava Zakharin2023-05-151-0/+4
| | | | | | | | | The temporary descriptor must be either Pointer or Allocatable, otherwise its memory will not be freed. Reviewed By: klausler Differential Revision: https://reviews.llvm.org/D150534
* [flang][runtime] Fixed dimension offset computation for MayAlias.Slava Zakharin2023-05-151-2/+2
| | | | | | Reviewed By: klausler Differential Revision: https://reviews.llvm.org/D150533
* [flang][hlfir] Fixed copy-in for polymorphic arguments.Slava Zakharin2023-05-152-6/+37
| | | | | | Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D150502
* [flang][hlfir] Fixed lowering for intrinsic calls with null() box argument.Slava Zakharin2023-05-155-12/+71
| | | | | | Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D150501
* [flang][hlfir] lower hlfir.any into fir runtime callJacob Crawley2023-05-152-5/+198
| | | | | | Depends on: D150272 Differential Revision: https://reviews.llvm.org/D150451
* [flang] lower any intrinsic to hlfir.any operationJacob Crawley2023-05-152-0/+93
| | | | | | | | Carries out the lowering of the any intrinsic into HLFIR Depends on: D149964 Differential Revision: https://reviews.llvm.org/D150272
* [flang] add hlfir.any intrinsicJacob Crawley2023-05-157-0/+209
| | | | | | | Adds a HLFIR operation for the ANY intrinsic according to the design set out in flang/docs/HighLevel.md Differential Revision: https://reviews.llvm.org/D149964
* Reland "[CMake] Bumps minimum version to 3.20.0."Mark de Wever2023-05-133-17/+3
| | | | | | The owner of the last two failing buildbots updated CMake. This reverts commit e8e8707b4aa6e4cc04c0cffb2de01d2de71165fc.
* [flang] Fixed global name creation for literal constants.Slava Zakharin2023-05-1214-617/+781
| | | | | | | | | | | | | | | | | | | The global names were created using a hash based on the address of std::vector::data address. Since the memory may be reused by different std::vector's, this may cause non-equivalent constant expressions to map to the same name. This is what is happening in the modified flang/test/Lower/constant-literal-mangling.f90 test. I changed the name creation to use a map between the constant expressions and corresponding unique names. The uniquing is done using a name counter in FirConverter. The effect of this change is that the equivalent constant expressions are now mapped to the same global, and the naming is "stable" (i.e. it does not change from compilation to compilation). Though, the issue is not HLFIR specific it was affecting several tests when using HLFIR lowering. Differential Revision: https://reviews.llvm.org/D150380
* [flang][hlfir] Fixed AssociateOp codegen for 0-dim variables.Slava Zakharin2023-05-122-2/+41
| | | | | | The codegen tried to fir.convert !fir.box to !fir.ref for this case. I used BoxAddr under a check for the type mismatch, but I am not sure if this is the right fix. Maybe it has to be handled in the lowering.
* [flang][openacc][NFC] Update _OPENACC definition to 202011Valentin Clement2023-05-111-1/+1
| | | | | | | | | | Update _OPENACC definition to be consistent with the flang-new driver. Currently set to 202011 which is OpenACC 3.1 specification and is the current parser/semantic status. Reviewed By: razvanlupusoru Differential Revision: https://reviews.llvm.org/D150400
* [flang][hlfir] Fixed invalid fir.convert generated by AssociateOp codegen.Slava Zakharin2023-05-112-22/+54
| | | | Differential Revision: https://reviews.llvm.org/D150393
* [flang] Inline array size call when dim is compile time constantRazvan Lupusoru2023-05-112-0/+19
| | | | | | | | | | Instead of calling _FortranASizeDim, we can instead load extent directly from descriptor. Add this support for cases where dim is a known constant at compile time. Reviewed By: clementval Differential Revision: https://reviews.llvm.org/D150385
* [mlir][flang][openacc] Remove obsolete operand legalization passesValentin Clement2023-05-116-157/+0
| | | | | | | | | | The information needed for translation is now encoded in the dialect operations and does not require a dedicated pass to be extracted. Remove the obsolete passes that were performing operand legalization. Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D150248
* [flang][hlfir] Establish <storage, mustFree> tuple for ApplyOp and NoReassocOp.Slava Zakharin2023-05-113-3/+170
| | | | | | | | | The bufferization pass must create the tuple for these operations, because the users may require it. For example, in case of ElementalOp inlining a DestroyOp may be generated for the operand of YieldElementOp, and the operand may be ApplyOp->NoReassocOp chain. Differential Revision: https://reviews.llvm.org/D150343
* [flang] Use internal linkage for string literalsDavid Truby2023-05-119-12/+14
| | | | | | | | | | | | | | On Windows, global string literals with "linkonce" linkage is not supported without using comdat. As a simpler fix than adding comdat support we can use internal linkage instead. This fixes a bug where two string literals with the same value in different fortran files would cause a linker error due to the use of linkonce linkage. Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D149859
* [Flang] Change complex divide loweringKiran Chandramohan2023-05-117-13/+211
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently complex division is lowered to a fir.divc operation and the fir.divc is later converted to a sequence of llvm operations to perform complex division, however this causes issues for extreme values when the calculations overflow. This patch changes the lowering of complex division to use the Intrinsic Call functionality to lower into library calls (for single, double, extended and quad precisions) or an MLIR complex dialect division operation (for half and bfloat precisions). A new wrapper function `genLibSplitComplexArgsCall` is written to handle the case of the arguments of the Complex Library calls being split to its real and imaginary real components. Note 1: If the Complex To Standard conversion of division operation matures then we can use it for all precisions. Currently it has the same issues as the conversion of fir.divc. Note 2: A previous patch (D145808) did the same but during conversion of the fir.divc operation. But using function calls at that stage leads to ABI issues since the conversion to LLVM is not aware of the complex target rewrite. Note 3: If the patch is accepted, fir.divc can be removed from FIR. We can use the complex.div operation where any transformation is required. Reviewed By: vzakhari, PeteSteinfeld, DavidTruby, jeanPerier Differential Revision: https://reviews.llvm.org/D149546
* [OpenMP][Flang][Semantics] Add semantics support for USE_DEVICE_ADDR clause ↵Raghu Maddhipatla2023-05-106-8/+49
| | | | | | | | on OMP TARGET DATA directive. Reviewed By: kiranchandramohan Differential Revision: https://reviews.llvm.org/D149815
* [Flang] Syntax support for OMP Allocators ConstructEthan Luis McDonough2023-05-108-14/+218
| | | | | | | | OpenMP 5.2 introduces a Fortran specific construct that aims to replace the executable allocate directive. This patch seeks to add parser support for the directive as well as the allocator clause with the [[ https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-5-2.pdf#section.6.6 | extended align/complex ]] modifier. Reviewed By: kiranchandramohan Differential Revision: https://reviews.llvm.org/D149727
* [mlir][openacc] Cleanup acc.kernels from old data clause operandsValentin Clement2023-05-101-4/+1
| | | | | | | | | | | | | Remove old clause operands from acc.kernels operation since the new dataOperands is now in place. private and firstprivate will receive some redesign but are not part of the new dataOperands. Depends on D150224 Reviewed By: vzakhari Differential Revision: https://reviews.llvm.org/D150225
* [mlir][openacc] Cleanup acc.serial from old data clause operandsValentin Clement2023-05-101-1/+1
| | | | | | | | | | | | | Remove old clause operands from acc.serial operation since the new dataOperands is now in place. private and firstprivate will receive some redesign but are not part of the new dataOperands. Depends on D150207 Reviewed By: vzakhari Differential Revision: https://reviews.llvm.org/D150224
* [flang][openacc] Preserve user order for entry data operand on compute constructValentin Clement2023-05-102-9/+23
| | | | | | | | | | | The order of operand in clauses that are decomposed was not preserved. This patch change how operands are handled and preserve the user ordering for the entry data operation on the acc.parallel operation. Reviewed By: vzakhari Differential Revision: https://reviews.llvm.org/D150214
* [flang][openacc] Preserve user order for entry data operand on data constructValentin Clement2023-05-102-10/+23
| | | | | | | | | | | The order of operand in clauses that are decomposed was not preserved. This patch change how operands are handled and preserve the user ordering for the entry data operation on the acc.data operation. Reviewed By: vzakhari Differential Revision: https://reviews.llvm.org/D150213
* [mlir][openacc] Cleanup acc.parallel from old data clause operandsValentin Clement2023-05-093-41/+2
| | | | | | | | | | | Remove old clause operands from acc.parallel operation since the new dataOperands is now in place. private, firstprivate and reductions will receive some redesign but are not part of the new dataOperands. Reviewed By: razvanlupusoru Differential Revision: https://reviews.llvm.org/D150207
* [flang][openacc] Fix lowerbound when there is no subscriptsValentin Clement2023-05-093-27/+23
| | | | | | | | | | | | | | The lowerbound was not correctly normalized to 0 when the bound are generated for an array without subscripts. ``` integer :: a(11:20) !$acc enter data create(a) ``` Reviewed By: razvanlupusoru Differential Revision: https://reviews.llvm.org/D150208
* [flang] Added missing type cast for the implied-do index.Slava Zakharin2023-05-097-274/+838
| | | | | | | | | The implied-do index value has 'index' type, and it has to be converted to the original ac-do-variable's data type. Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D150150
* [flang][hlfir] Allow passing null() to dummy class argument.Slava Zakharin2023-05-092-1/+33
|
* [mlir][openacc] Cleanup acc.data from old data clause operandsValentin Clement2023-05-093-41/+0
| | | | | | | | | | | | | | | | | Since the new data operand operations have been added in D148389 and adopted on acc.data in D149673, the old clause operands are no longer needed. The LegalizeDataOpForLLVMTranslation will become obsolete when all operations will be cleaned. For the time being only the appropriate part are being removed. processOperands will also receive some updates once all the operands will be coming from an acc data operand operation. Reviewed By: razvanlupusoru Differential Revision: https://reviews.llvm.org/D150155
* Revert "[flang][openacc] Fix lowerbound when there is no subscripts"Valentin Clement2023-05-092-21/+23
| | | | This reverts commit 626aa8518d873c5760cd033fe49b1809c9de3494.