aboutsummaryrefslogtreecommitdiff
path: root/flang/lib
AgeCommit message (Collapse)AuthorFilesLines
4 hours[flang][near NFC] Fix English in an error message (#151029)Peter Klausler1-8/+8
Correct "is a not a pointer" to "is not a pointer" in an error message. While here, also unsplit nearby error messages so that their contents are more searchable. Fixes https://github.com/llvm/llvm-project/issues/150864.
4 hours[flang][CUDA] Apply intrinsic operator overrides (#151018)Peter Klausler3-14/+76
Fortran's intrinsic numeric and relational operators can be overridden with explicit interfaces so long as one or more of the dummy arguments have the DEVICE attribute. Semantics already allows this without complaint, but fails to replace the operations with the defined specific procedure calls when analyzing expressions.
7 hours[flang][openacc] Add semantic checks for atomic constructs (#149579)Andre Kuhlenschmidt7-46/+275
An error report of the following code generating non-atomic code led us to realize there are missing checks in the OpenACC atomics code. Add some of those checks for atomic and sketch how the rest of the code should proceed in checking the rest of the properties. The following cases are all reported as errors. ```fortran ! Originally reported error! !$acc atomic capture a = b c = b !$acc end atomic capture ! Other ambiguous, but related errors! !$acc atomic capture x = i i = x !$acc end atomic capture !$acc atomic capture a = b b = b !$acc end atomic capture !$acc atomic capture a = b a = c !$acc end atomic capture ```
15 hours[Flang][OpenMP] Skip DSA for canonical loops (#150593)Michael Kruse1-24/+27
OpenMP loop transformations to not have data-sharing attributes and do not explicitly privatize the loop variable. The DataSharingProcessor was still used in #144785 because `createAndSetPrivatizedLoopVar` expected it. We skip that function and directly write to the loop variable. If the loop variable is implicitly or explicitly privatized, it will be due to surrounding OpenMP constructs such as `parallel`.
30 hours[flang][acc] Lower do and do concurrent loops specially in acc regions (#149614)Razvan Lupusoru2-120/+308
When OpenACC is enabled and Fortran loops are annotated with `acc loop`, they are lowered to `acc.loop` operation. And rest of the contained loops use the normal FIR lowering path. Hovever, the OpenACC specification has special provisions related to contained loops and their induction variable. In order to adhere to this, we convert all valid contained loops to `acc.loop` in order to store this information appropriately. The provisions in the spec that motivated this change (line numbers are from OpenACC 3.4): - 1353 Loop variables in Fortran do statements within a compute construct are predetermined to be private to the thread that executes the loop. - 3783 When do concurrent appears without a loop construct in a kernels construct it is treated as if it is annotated with loop auto. If it appears in a parallel construct or an accelerator routine then it is treated as if it is annotated with loop independent. By valid loops - we convert do loops and do concurrent loops which have induction variable. Loops which are unstructured are not handled.
31 hours[mlir] Reland `Move InitAll*** implementation into static library` (#151150)Ivan Butygin1-6/+3
Reland https://github.com/llvm/llvm-project/pull/150805 Shared libs build was broken. Add `${dialect_libs}` and `${conversion_libs}` to `MLIRRegisterAllExtensions` because it depends on `registerConvert***ToLLVMInterface` functions.
36 hoursRevert "[mlir][core] Move `InitAll***` implementation into static library." ↵Mehdi Amini1-3/+6
(#151118) Reverts llvm/llvm-project#150805 Some bots are failing.
36 hours[mlir][core] Move `InitAll***` implementation into static library. (#150805)Ivan Butygin1-6/+3
`InitAll***` functions are used by `opt`-style tools to init all MLIR dialects/passes/extensions. Currently they are implemeted as inline functions and include essentially the entire MLIR header tree. Each file which includes this header (~10 currently) takes 10+ sec and multiple GB of ram to compile (tested with clang-19), which limits amount of parallel compiler jobs which can be run. Also, flang just includes this file into one of its headers. Move the actual registration code to the static library, so it's compiled only once. Discourse thread https://discourse.llvm.org/t/rfc-moving-initall-implementation-into-static-library/87559
2 days[flang][MLIR][OpenMP][llvm]Atomic Control Support (#150860)Anchu Rajendran S4-1/+73
4 days[Flang/Flang-RT] Fix OldUnit tests on Windows (#150734)Michael Kruse1-4/+4
Flang and Flang-RT have two flavours of unittests: 1. GTest unittests, using lit's `lit.formats.GoogleTest` format ending with `Tests${CMAKE_EXECUTABLE_SUFFIX}` 2. "non-GTest" or "OldUnit" unittests, a plain executable ending with `.test${CMAKE_EXECUTABLE_SUFFIX}` Both executables are emitted into the same unittests/ subdirectory. When running ... 1. `tests/Unit/lit.cfg.py`, only considers executable ending with `Tests` (or `Tests.exe` on Windows), hence skips the non-GTest tests. 2. `tests/NonGtestUnit/lit.cfg.py` considers all tests ending with `.test` or `.exe`. On Windows, The GTest unitests also end with `.exe`. In Flang-RT, `.exe` is considered an extension for non-GTest unitests which causes tests such as Flang's `RuntimeTests.exe` to be executed for both on Windows. This particular test includes a file write test, using a hard-coded filename `ucsfile`. If the two instances are executed concurrently, they might interfere with each other reading/writing `ucsfile` which results in a flaky test. This patch avoids the redundant execution by requiring the suffix `.test.exe` on Windows. lit has to be modified because it uses `os.path.splitext` the extract the extension, which would only recognize the last component. It was changed from the orginal `endswith` in c865abe747aa72192f02ebfdcabe730f2553e42f for unknown reasons. In Flang, `.exe` is not considered a suffix for non-GTest unittests and hence they are not run at all. Fixing by also added `.test.exe` as valid suffix, like with Flang-RT. Unfortunately, the ` Evaluate/real.test.exe` test was failing on Windows: ``` FAIL: flang-OldUnit :: Evaluate/real.test.exe (3592 of 3592) ******************** TEST 'flang-OldUnit :: Evaluate/real.test.exe' FAILED ******************** ..\_src\flang\unittests\Evaluate\real.cpp:511: FAIL: FlagsToBits(prod.flags) == 0x18, not 0x10 0 0x800001 * 0xbf7ffffe ..\_src\flang\unittests\Evaluate\real.cpp:511: FAIL: FlagsToBits(prod.flags) == 0x18, not 0x10 0 0x800001 * 0x3f7ffffe ..\_src\flang\unittests\Evaluate\real.cpp:511: FAIL: FlagsToBits(prod.flags) == 0x18, not 0x10 0 0x80800001 * 0xbf7ffffe ..\_src\flang\unittests\Evaluate\real.cpp:511: FAIL: FlagsToBits(prod.flags) == 0x18, not 0x10 0 0x80800001 * 0x3f7ffffe ... ``` This is due to the `__x86_64__` macro not being set by Microsoft's cl.exe and hence floating point status flags not being read out. The equivalent macro for Microsofts compiler is `_M_X64` (or `_M_X64`).
5 days[flang] Catch both EXTERNAL and INTRINSIC on type declaration stmt (#150254)Peter Klausler1-1/+2
The EXTERNAL and INTRINSIC attributes can't both appear on the same type declarations statement. Fixes https://github.com/llvm/llvm-project/issues/149771.
5 days[mlir][LLVM] Remove `llvm` deps from the LLVM dialect (#150692)Fabian Mora2-0/+2
This patch removes spurious includes of `llvm/IR` files, and unnecessary link components in the LLVM dialect. The only major dependencies still coming from LLVM are `llvm::DataLayout`, which is used by `verifyDataLayoutString` and some `dwarf` symbols in some attributes. Both of them should likely be removed in the future. Finally, I also removed one constructor from `LLVM::AssumeOp` that used [OperandBundleDefT](https://llvm.org/doxygen/classllvm_1_1OperandBundleDefT.html) without good reason and introduced a header unnecessarily.
5 days[Flang] Implement LOWER= argument for C_F_POINTER (Fortran 2023) (#149870)Michael Klemm2-8/+62
This PR resolves issue #147819 and adds support for the F2023 extension of the `LOWER=` argument for `C_F_POINTER`.
5 days[Flang][OpenMP] Appropriately emit present/load/store in all cases in ↵agozillon1-22/+31
MapInfoFinalization (#150311) Currently, we return early whenever we've already generated an allocation for intermediate descriptor variables (required in certain cases when we can't directly access the base address of a passes in descriptor function argument due to HLFIR/FIR restrictions). This unfortunately, skips over the presence check and load/store required to set the intermediate descriptor allocations values/data. This is fine in most cases, but if a function happens to have a series of branches with seperate target regions capturing the same input argument, we'd emit the present/load/store into the first branch with the first target inside of it, the secondary (or any preceding) branches would not have the present/load/store, this would lead to the subsequent mapped values in that branch being empty and then leading to a memory access violation on device. The fix for the moment is to emit a present/load/store at the relevant location of every target utilising the input argument, this likely will also lead to fixing possible issues with the input argument being manipulated inbetween target regions (primarily resizing, the data should remain the same as we're just copying an address around, in theory at least). There's possible optimizations/simplifications to emit less load/stores such as by raising the load/store out of the branches when we can, but I'm inclined to leave this sort of optimization to lower level passes such as an LLVM pass (which very possibly already covers it).
5 days[flang][OpenMP] Detect BLOCK construct through lookahead (#150617)Krzysztof Parzyszek1-5/+12
Avoid parsing the entire ExecutionPartConstruct in either the strictly- or the loosely-structured block parser only to discard it when it's not BLOCK (or is BLOCK) respectively. Doing so was not incorrct, but in pathological cases (like Fujitsu 0981_0034) the recursive parsing can take a very long time. Instead, detect the presence of BLOCK first (via a simple lookahead), and fail immediately if necessary.
6 days[flang][fir] Add conversion of `fir.if` to `scf.if`. (#149959)Terapines MLIR1-2/+41
This commmit is a supplement for https://github.com/llvm/llvm-project/pull/140374. RFC:https://discourse.llvm.org/t/rfc-add-fir-affine-optimization-fir-pass-pipeline/86190/6
6 days[mlir][NFC] update `flang/lib` create APIs (12/n) (#149914)Maksim Levental25-677/+716
See https://github.com/llvm/llvm-project/pull/147168 for more info.
6 daysRevert "[flang][flang-driver][mlir][OpenMP] atomic control support" (#150504)Kiran Chandramohan4-73/+1
Reverts llvm/llvm-project#143441 Reverting due to CI failure https://lab.llvm.org/buildbot/#/builders/53/builds/18055.
6 days[flang][flang-driver][mlir][OpenMP] atomic control support (#143441)Anchu Rajendran S4-1/+73
Atomic Control Options are used to specify architectural characteristics to help lowering of atomic operations. The options used are: `-f[no-]atomic-remote-memory`, `-f[no-]atomic-fine-grained-memory`, `-f[no-]atomic-ignore-denormal-mode`. Legacy option `-m[no-]unsafe-fp-atomics` is aliased to `-f[no-]ignore-denormal-mode`. More details can be found in https://github.com/llvm/llvm-project/pull/102569. This PR implements the frontend support for these options with OpenMP atomic in flang. Backend changes are available in the draft PR: https://github.com/llvm/llvm-project/pull/143769 which will be raised after this merged.
6 days[flang][OpenMP] Silence warning in openmp-parsers.cppKrzysztof Parzyszek1-1/+1
flang/lib/Parser/openmp-parsers.cpp:1655:43: warning : logical not is only applied to the left hand side of comparison [-Wlogical-not -parentheses] 1655 | TYPE_PARSER(!StandaloneDirectiveLookahead >= | ^~
6 days[flang][OpenMP] Parse strictly- and loosely-structured blocks (#150298)Krzysztof Parzyszek4-28/+98
Block-associated constructs have, as their body, either a strictly- or a loosely-structured block. In the former case the end-directive is optional. The existing parser required the end-directive to be present in all cases. Note: The definitions of these blocks in the OpenMP spec exclude cases where the block contains more than one construct, and the first one is BLOCK/ENDBLOCK. For example, the following is invalid: ``` !$omp target block ! This cannot be a strictly-structured block, but continue ! a loosely-structured block cannot start with endblock ! BLOCK/ENDBLOCK continue ! !$omp end target ```
6 days[flang][OpenMP] Avoid analyzing assumed-size array bases (#150324)Krzysztof Parzyszek1-16/+20
A check for character substrings masquerading as array sections was using expression analyzer on the array base. When this array happened to be an assumed-size array, the analyzer emitted a semantic error that did not correspond to any issue with the source code. To avoid that, check whether the object is an assumed-size array before using the expression analyzer on it. While at it, replace the call to GetShape with a simple check for rank, since that's the only information needed. Fixes https://github.com/llvm/llvm-project/issues/150297
7 days[flang] Extend symbol update to ArrayAttrext in `external-name-interop` ↵Delaram Talaashrafi1-11/+47
(#150061) In the `external-name-interop` pass, when a symbol is changed, all the uses of the renamed symbols should also be updated. The update was only applied to the `SymbolRefAttr` type. With this change, the update will be applied to `ArrayAttr` containing elements of type `SymbolRefAttr`. --------- Co-authored-by: Delaram Talaashrafi <dtalaashrafi@nvidia.com>
7 days[flang] Implement `asinpi` (#150238)Connector Switch2-0/+17
7 days[flang] Implement `acospi` (#150234)Connector Switch2-0/+17
7 days[flang] Fix a warningKazu Hirata1-0/+1
This patch fixes: flang/lib/Lower/Bridge.cpp:2128:10: error: unused variable 'result' [-Werror,-Wunused-variable]
7 days[Flang] Fix a crash when equivalence and namelist statements are used (#150081)Carlos Seo1-1/+3
Check for equivalence when generating namelist descriptors in IO.cpp. Fixes #124489
7 days[Flang] Fix ASSIGN statement (#149941)Carlos Seo1-2/+26
Handle the case where the assigned variable also has a pointer attribute. Fixes #121721
7 days[flang] Implement `tanpi` (#149527)Connector Switch2-0/+17
7 days[flang][OpenMP] General utility to get directive id from AST node (#150121)Krzysztof Parzyszek4-113/+12
Fortran::parser::omp::GetOmpDirectiveName(t) will get the OmpDirectiveName object that corresponds to construct t. That object (an AST node) contains the enum id and the source information of the directive. Replace uses of extractOmpDirective and getOpenMPDirectiveEnum with the new function.
8 days[flang][OpenMP] Restore reduction processor behavior broken by #145837 (#150178)Kareem Ergawy3-20/+27
Fixes #149089 and #149700. Before #145837, when processing a reduction symbol not yet supported by OpenMP lowering, the reduction processor would simply skip filling in the reduction symbols and variables. With #145837, this behvaior was slightly changed because the reduction symbols are populated before invoking the reduction processor (this is more convenient to shared the code with `do concurrent`). This PR restores the previous behavior.
8 days[Flang] Build fix without precompiled headersMichael Kruse1-0/+1
The header semantics.h is added implitly in the precompiled headers, but the build was failing when precompiled headers are disabled (e.g. using CMAKE_DISABLE_PRECOMPILE_HEADERS=ON): ``` ../_src/flang/lib/Semantics/canonicalize-omp.cpp: In constructor ‘Fortran::semantics::CanonicalizationOfOmp::CanonicalizationOfOmp(Fortran::semantics::SemanticsContext&)’: ../_src/flang/lib/Semantics/canonicalize-omp.cpp:31:38: error: invalid use of incomplete type ‘class Fortran::semantics::SemanticsContext’ 31 | : context_{context}, messages_{context.messages()} {} | ^~~~~~~ In file included from ../_src/flang/lib/Semantics/canonicalize-omp.cpp:9: ../_src/flang/lib/Semantics/canonicalize-omp.h:17:7: note: forward declaration of ‘class Fortran::semantics::SemanticsContext’ 17 | class SemanticsContext; | ^~~~~~~~~~~~~~~~ compilation terminated due to -fmax-errors=1. ```
8 days[flang] Implement `sinpi` (#149525)Connector Switch2-0/+17
8 days[flang][OpenMP] Fix build break with -WerrorKrzysztof Parzyszek1-2/+0
llvm-project/flang/lib/Semantics/resolve-directives.cpp:753:7: error: default label in switch which covers all enumeration values [-Werror,-Wcovered-switch-default] 753 | default: | ^ 1 error generated. https://lab.llvm.org/buildbot/#/builders/53/builds/17917
8 days[flang][OpenMP] Sema checks, lowering with new format of MAP modifiers (#149137)Krzysztof Parzyszek11-104/+224
OpenMP 6.0 has changed the modifiers on the MAP clause. Previous patch has introduced parsing support for them. This patch introduces processing of the new forms in semantic checks and in lowering. This only applies to existing modifiers, which were updated in the 6.0 spec. Any of the newly introduced modifiers (SELF and REF) are ignored.
9 days[Flang] Implement !$omp unroll using omp.unroll_heuristic (#144785)Michael Kruse1-5/+199
Add support for `!$omp unroll` in Flang and basic MLIR `omp.canonical_loop` modeling. First step to add `omp.canonical_loop` modeling to the MLIR OpenMP dialect with the goal of being more general than the current `omp.loop_nest` approach: * Support for non-perfectly nested loops * Support for non-rectangular loops * Support for arbitrary compositions of loop transformations This patch is functional end-to-end and adds support for `!$omp unroll` to Flang. `!$omp unroll` is lowered to `omp.new_cli`, `omp.canonical_loop`, and `omp.unroll_heuristic` in MLIR, which are lowered to LLVM-IR using the OpenMPIRBuilder (https://reviews.llvm.org/D107764).
9 days[mlir][NFC] update `flang/Optimizer/Builder` create APIs (9/n) (#149917)Maksim Levental10-1274/+1308
See https://github.com/llvm/llvm-project/pull/147168 for more info.
9 days[mlir][NFC] update `flang/Optimizer/Builder/Runtime` create APIs (10/n) ↵Maksim Levental21-205/+210
(#149916) See https://github.com/llvm/llvm-project/pull/147168 for more info.
9 days[mlir][NFC] update `flang/Lower` create APIs (8/n) (#149912)Maksim Levental24-1336/+1378
See https://github.com/llvm/llvm-project/pull/147168 for more info.
9 days[mlir][NFC] update `flang/Optimizer/Transforms` create APIs (11/n) (#149915)Maksim Levental22-491/+517
See https://github.com/llvm/llvm-project/pull/147168 for more info.
9 days[NFC][flang] Added engineering option for triaging local-alloc-tbaa. (#149587)Slava Zakharin1-5/+36
I triaged a benchmark that showed inaccurate results, when local-alloc-tbaa was enabled. It turned out to be not a real TBAA issue, but rather TBAA affecting optimizations that affect FMA generation, which introduced an expected accuracy variation. I would like to keep this threshold control for future uses.
9 days[flang][OpenMP] Parse OpenMP 6.0 map modifiers (#149134)Krzysztof Parzyszek6-16/+203
OpenMP 6.0 has changed the modifiers on the MAP clause: - map-type-modifier has been split into individual modifiers, - map-type "delete" has become a modifier, - new modifiers have been added. This patch adds parsing support for all of the OpenMP 6.0 modifiers. The old "map-type-modifier" is retained, but is no longer created in parsing. It will remain to take advantage of the preexisting modifier validation for older versions: when the OpenMP version is < 6.0, the modifiers will be rewritten back as map-type-modifiers (or map- type in case of "delete"). In this patch the modifiers will always be rewritten in the older format to isolate these changes to parsing as much as possible.
12 days[mlir][Flang][NFC] Replace use of `vector.insertelement/extractelement` ↵Diego Caballero3-3/+11
(#143272) This PR is part of the last step to remove `vector.extractelement` and `vector.insertelement` ops (RFC: https://discourse.llvm.org/t/rfc-psa-remove-vector-extractelement-and-vector-insertelement-ops-in-favor-of-vector-extract-and-vector-insert-ops). It replaces `vector.insertelement` and `vector.extractelement` with `vector.insert` and `vector.extract` in Flang. It looks like no lit tests are impacted?
12 days[flang][openacc] fix bugs with default(none) checking (#149220)Andre Kuhlenschmidt1-0/+15
A report of the following code not generating an error led to fixing two bugs in directive checking. - We should treat CombinedConstructs as OpenACC Constructs - We should treat DoConstruct index variables as private. ```fortran subroutine sub(nn) integer :: nn, ii !$acc serial loop default(none) do ii = 1, nn end do !$acc end serial loop end subroutine ``` Here `nn` should be flagged as needing a data clause while `ii` should still get one implicitly.
12 days[flang][NFC] Fix build-time warning (#149549)Peter Klausler1-4/+3
Don't increment the LHS variable of an assignment that also uses that variable on the RHS.
12 days[flang][runtime] Preserve type when remapping monomorphic pointers (#149427)Peter Klausler2-9/+12
Pointer remappings unconditionally update the element byte size and derived type of the pointer's descriptor. This is okay when the pointer is polymorphic, but not when a pointer is associated with an extended type. To communicate this monomorphic case to the runtime, add a new entry point so as to not break forward binary compatibility.
12 days[flang] Fixed a crash with undeclared variable in implicit-do loop (#149513)Eugene Epshteyn1-1/+3
Fixed a crash in the following example: ``` subroutine sub() implicit none print *, (i, i = 1, 2) ! Problem: using undefined var in implied-do loop end subroutine sub ``` The error message was already generated, but the compiler crashed before it could display it.
12 days[flang] Migrate away from ArrayRef(std::nullopt_t) (#149454)Kazu Hirata12-32/+37
ArrayRef(std::nullopt_t) has been deprecated. This patch replaces std::nullopt with mlir::TypeRange{} or mlir::ValueRange{} as appropriate.
12 days[flang][cuda] Support device component in a pointer or allocatable ↵Valentin Clement (バレンタイン クレメン)1-3/+23
derived-type (#149418)
13 days[flang] handle allocation of zero-sized objects (#149165)Kelvin Li1-0/+10
This PR handles the allocation of zero-sized objects for different implementations. One byte is allocated for the zero-sized objects.