aboutsummaryrefslogtreecommitdiff
path: root/flang/tools
AgeCommit message (Collapse)AuthorFilesLines
7 days[flang] Fix cycle of build dependencies (#108132)Peter Klausler1-1/+1
While trying to fix one build problem, I made things worse. This should clear things up.
7 days[flang] Make flang module hidden dependency explicit to correct build… ↵Peter Klausler1-3/+3
(#108129) … failure Any flang module with a derived type definition implicitly depends on flang/module/__fortran_type_info.f90. Make this dependency explicit so that an unlucky build order doesn't cause a crash.
13 days[flang] Warn when F128 is unsupported (#102147) (#106957)Tom Eccles1-1/+24
This generates `warning: REAL(KIND=16) is not an enabled type for this target` if that type is used in a build not correctly configured to support this type. Uses of `selected_real_kind(30)` return -1. Relanding #102147 because the test errors turned out to be specific to a downstream configuration.
14 daysAllow disabling of types from the command line (#107126)Renaud Kauffmann1-2/+3
Adding hidden options to disable types through the `TargetCharacteristics`. I am seeing issues when I do this programmatically and would like, for anyone, to have the ability to reproduce them for development and testing purposes. I am planning to file a couple of issues following this patch.
2024-08-29Revert "[flang] Warn when F128 is unsupported" (#106561)Tom Eccles1-24/+1
Reverts llvm/llvm-project#102147 It seems some systems which should support F128 are wrongly detected as not supporting. This might be due to checking `LDBL_MANT_DIG` instead of `__LDBL_MANT_DIG__`. I will investigate.
2024-08-28[flang] Warn when F128 is unsupported (#102147)Tom Eccles1-1/+24
This generates `warning: REAL(KIND=16) is not an enabled type for this target` if that type is used in a build not correctly configured to support this type. Uses of `selected_real_kind(30)` return -1.
2024-08-22[flang][NFC] Move OpenMP related passes into a separate directory (#104732)Ivan R. Ivanov4-0/+5
Reapplied with fixed library dependencies for shared lib build
2024-08-21Revert "[flang][NFC] Move OpenMP related passes into a separate directory ↵Ivan Radanov Ivanov4-5/+0
(#104732)" This reverts commit 87eeed1f0ebe57abffde560c25dd9829dc6038f3.
2024-08-21[flang][NFC] Move OpenMP related passes into a separate directory (#104732)Ivan R. Ivanov4-0/+5
2024-08-08[CMake] Remove EXPORT_SYMBOLS_FOR_PLUGINS from #102138 (#102396)Steven Wu1-9/+7
Partially remove some of the changes from #102138 as EXPORT_SYMBOLS_FOR_PLUGINS doesn't work on all the configurations.
2024-08-07Reapply "[CMake] Fold export_executable_symbols_* into function args. ↵Steven Wu1-7/+9
(#101741)" (#102138) Fix the builds with LLVM_TOOL_LLVM_DRIVER_BUILD enabled. LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES is not completely compatible with export_executable_symbols as the later will be ignored if the previous is set to NO. Fix the issue by passing if symbols need to be exported to llvm_add_exectuable so the link flag can be determined directly without calling export_executable_symbols_* later.
2024-08-06Revert "[CMake] Fold export_executable_symbols_* into function args. (#101741)"Steven Wu1-9/+7
This reverts commit 5c56b46a32a8856a022a54291bc9294068f7ddbd. This break lld build when using GENERATE_DRIVER.
2024-08-05[CMake] Fold export_executable_symbols_* into function args. (#101741)Steven Wu1-7/+9
`LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES` is not completely compatible with `export_executable_symbols` as the later will be ignored if the previous is set to NO. Fix the issue by passing if symbols need to be exported to `llvm_add_exectuable` so the link flag can be determined directly without calling `export_executable_symbols_*` later.
2024-08-02[Flang][OpenMP] Add frontend support for -fopenmp-targets (#100155)Sergio Afonso1-1/+12
This patch adds support for the `-fopenmp-targets` option to the `bbc` and `flang -fc1` tools. It adds an `OMPTargetTriples` property to the `LangOptions` structure, which is filled with the triples represented by the compiler option. This is used to initialize the `omp.target_triples` module attribute for later use by lowering stages.
2024-07-19[flang][runtime] Build ISO_FORTRAN_ENV to export kind arrays as linkable ↵Michael Klemm2-10/+44
symbols (#95388) Moves definitions of the kind arrays into a Fortran MODULE to not only emit the MOD file, but also compile that MODULE file into an object file. This file is then linked into libFortranRuntime.so. Eventually this workaround PR shoud be redone and a proper runtime build should be setup that will then also compile Fortran MODULE files. Fixes #89403 --------- Co-authored-by: Valentin Clement (バレンタイン クレメン) <clementval@gmail.com> Co-authored-by: Michael Kruse <github@meinersbur.de>
2024-07-16Add basic -mtune support (#98517)Alexis Perry-Holby2-1/+6
Initial implementation for the -mtune flag in Flang. This PR is a clean version of PR #96688, which is a re-land of PR #95043
2024-07-02mlir/LogicalResult: move into llvm (#97309)Ramkumar Ramachandra2-3/+3
This patch is part of a project to move the Presburger library into LLVM.
2024-06-25Revert "[flang] Add basic -mtune support" (#96678)Tarun Prabhu2-6/+1
Reverts llvm/llvm-project#95043
2024-06-25[flang] Add basic -mtune support (#95043)Alexis Perry-Holby2-1/+6
This PR adds -mtune as a valid flang flag and passes the information through to LLVM IR as an attribute on all functions. No specific architecture optimizations are added at this time.
2024-06-05[Flang][OpenMP] Add -fopenmp-force-usm option to flang (#94359)Sergio Afonso1-5/+10
This patch enables the `-fopenmp-force-usm` option to be passed to the flang driver, which forwards it to the compiler frontend. This flag, when set, results in the introduction of the `unified_shared_memory` bit to the `omp.requires` attribute of the top-level module operation. This is later combined with any other target device-related REQUIRES clauses that may have been explicitly set in the compilation unit.
2024-05-25[flang] Revise IDE folder structure (#89745)Michael Kruse1-0/+1
Update the folder titles for targets in the monorepository that have not seen taken care of for some time. These are the folders that targets are organized in Visual Studio and XCode (`set_property(TARGET <target> PROPERTY FOLDER "<title>")`) when using the respective CMake's IDE generator. * Ensure that every target is in a folder * Use a folder hierarchy with each LLVM subproject as a top-level folder * Use consistent folder names between subprojects * When using target-creating functions from AddLLVM.cmake, automatically deduce the folder. This reduces the number of `set_property`/`set_target_property`, but are still necessary when `add_custom_target`, `add_executable`, `add_library`, etc. are used. A LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's root CMakeLists.txt.
2024-05-17[flang][cuda] Implicitly load cudadevice module in device/global subprogram ↵Valentin Clement (バレンタイン クレメン)1-4/+8
(#92038) This is a re-worked version of #91668. It adds the `cudadevice` module and set the `device` attributes on its functions/subroutines so there is no need for special case in semantic check. `cudadevice` module is implicitly USE'd in `global`/`device` subprogram.
2024-05-17[flang][cuda] Move CUDA Fortran operations to a CUF dialect (#92317)Valentin Clement (バレンタイン クレメン)3-0/+6
The number of operations dedicated to CUF grew and where all still in FIR. In order to have a better organization, the CUF operations, attributes and code is moved into their specific dialect and files. CUF dialect is tightly coupled with HLFIR/FIR and their types. The CUF attributes are bundled into their own library since some HLFIR/FIR operations depend on them and the CUF dialect depends on the FIR types. Without having the attributes into a separate library there would be a dependency cycle.
2024-05-16[flang] Add nsw flag to do-variable increment with a new option (#91579)Yusuke MINATO1-0/+7
This patch adds nsw flag to the increment of do-variables when a new option is enabled. NOTE 11.10 in the Fortran 2018 standard says they never overflow. See also the discussion in #74709 and the following discourse post. https://discourse.llvm.org/t/rfc-add-nsw-flags-to-arithmetic-integer-operations-using-the-option-fno-wrapv/77584/5
2024-05-13[flang][cuda] Extends matching distance computation (#91810)Valentin Clement (バレンタイン クレメン)1-0/+10
Extends the computation of the matching distance in the generic resolution to support options described in the table: https://docs.nvidia.com/hpc-sdk/archive/24.3/compilers/cuda-fortran-prog-guide/index.html#cfref-var-attr-unified-data Options are added as language features in the `SemanticsContext` and a flag is added in bbc for testing purpose.
2024-05-10Revert "[flang][cuda] Implicitly load cudadevice module in device/global ↵Valentin Clement (バレンタイン クレメン)1-4/+0
subprogram" (#91827) Reverts llvm/llvm-project#91668
2024-05-10[flang][cuda] Implicitly load cudadevice module in device/global subprogram ↵Valentin Clement (バレンタイン クレメン)1-0/+4
(#91668) Some functions and subroutines are available in device context (device/global). These functions have interfaces declared in the `cudadevice` module. This patch adds interfaces as `__cuda_device_builtins_<fctname>` in a builtin module and they are USE'd rename in the `cudadevice` module. The module is implicitly used in device/global subprograms. The builtin module only contains procedures from section 3.6.4 for now.
2024-05-02[flang] Added extension point callbacks to default FIR optimizer pipeline. ↵Vijay Kandiah2-2/+4
(#90674) This change inserts a few extension point callbacks in the DefaultFIROptimizerPassPipeline. As an example usage of callbacks in the FIR optimizer pipeline, the FIRInlinerCallback is now used to register the default MLIR inliner pass in flang-new, tco, and bbc compilation flows. Other compilation flows can use these callbacks to add extra passes at different points of the pass pipeline. --------- Co-authored-by: Vijay Kandiah <vkandiah@sky6.pgi.net>
2024-05-01[flang] Intermix messages from parser and semantic analysis (#90654)Peter Klausler1-4/+7
When there are one or more fatal error messages produced by the parser, semantic analysis is not performed. But when there are messages produced by the parser and none of them are fatal, those messages are emitted to the user before compilation continues with semantic analysis, and any messages produced by semantics are emitted after the messages from parsing. This can be confusing for the user, as the messages may no longer all be in source file location order. It also makes it difficult to write tests that check for both non-fatal messages from parsing as well as messages from semantics using inline CHECK: or other expected messages in test source code. This patch ensures that if semantic analysis is performed, and non-fatal messages were produced by the parser, that all the messages will be combined and emitted in source file order.
2024-04-29[flang] Generate main only when a Fortran program statement is present (#89938)David Truby1-1/+0
This patch changes the behaviour for flang to only create and link to a `main` entry point when the Fortran code has a program statement in it. This means that flang-new can be used to link even when the program is a mixed C/Fortran code with `main` present in C and no entry point present in Fortran. This also removes the `-fno-fortran-main` flag as this no longer has any functionality.
2024-04-19[flang] Remove obsolete flang-to-external-fc tool (#88904)Michael Klemm2-508/+0
It seems like the `flang-to-external-fc` tool is no longer needed, because Flang is now a full compiler in its own right. After PR #85249 has landed, this tool will not be able to pick up the `.f18.mod` files.
2024-04-11[flang] Do not create .f18.mod files for each compiled module (#85249)Michael Klemm1-5/+2
The default CMake scripts had a copy operation to copy a compiled `.mod` file to also be available with suffix `.f18.mod`. This seems no longer needed. Also updated ModFiles.md to point to `-module-suffix`. --------- Co-authored-by: Kiran Chandramohan <kiranchandramohan@gmail.com>
2024-04-08[flang] Clean up ISO_FORTRAN_ENV, fix NUMERIC_STORAGE_SIZE (#87566)Peter Klausler1-9/+6
Address TODOs in the intrinsic module ISO_FORTRAN_ENV, and extend the implementation of NUMERIC_STORAGE_SIZE so that the calculation of its value is deferred until it is needed so that the effects of -fdefault-integer-8 or -fdefault-real-8 are reflected. Emit a warning when NUMERIC_STORAGE_SIZE is used from the module file and the default integer and real sizes do not match. Fixes https://github.com/llvm/llvm-project/issues/87476.
2024-03-20[flang][OpenMP] Compile proper `omp_lib.mod` from the `openmp/src/include` ↵Michael Klemm1-3/+33
sources (#80874) This PR changes the build system to use use the sources for the module `omp_lib` and the `omp_lib.h` include file from the `openmp` runtime project and not from a separate copy of these files. This will greatly reduce potential for inconsistencies when adding features to the OpenMP runtime implementation. When the OpenMP subproject is not configured, this PR also disables the corresponding LIT tests with a "REQUIRES" directive at the beginning of the OpenMP test files. --------- Co-authored-by: Valentin Clement (バレンタイン クレメン) <clementval@gmail.com>
2024-03-19[flang] Enable polymorphic lowering by default (#83285)jeanPerier1-6/+0
Polymorphic entity lowering status is good. The main remaining TODO is to allow lowering of vector subscripted polymorphic entity, but this does not deserve blocking all application using polymorphism. Remove experimental option and enable lowering of polymorphic entity by default.
2024-03-14[flang] Avoid module dependency failure when __fortran_buitlin is updatedValentin Clement1-1/+1
2024-02-23[flang][OpenMP] Set OpenMP attributes in MLIR module in bbc before lo… ↵Krzysztof Parzyszek1-1/+1
(#82774) …wering Right now attributes like OpenMP version or target attributes for offload are set after lowering in bbc. The flang frontend sets them before lowering, making them available in the lowering process. This change sets them before lowering in bbc as well.
2024-02-23[flang][bbc] Fix dangling reference to `envDefaults` (#82800)Krzysztof Parzyszek1-1/+2
The lowering bridge stores the evvironment defaults (passed to the constructor) as a reference. In the call to the constructor in bbc, the defaults were passed as `{}`, which creates a temporary whose lifetime ends immediately after the call. The flang driver passes a member of the compilation instance to the constructor, which presumably remains alive long enough, so storing the reference in the bridge is justified. To avoid the dangling reference, create an actual object `envDefaults` in bbc.
2024-02-20[flang][runtime] Add FortranFloat128Math wrapper library. (#81971)Slava Zakharin1-0/+3
Implemented few entry points for REAL(16) math in FortranF128Math static library. It is a thin wrapper around GNU libquadmath. Flang driver can always link it, and the dependencies will be brought in as needed. The final Fortran program/library that uses any of the entry points will depend on the underlying third-party library - this dependency has to be resolved somehow. I added FLANG_RUNTIME_F128_MATH_LIB CMake control so that the compiler driver and the runtime library can be built using the same third-party library: this way the linker knows which dependency to link in (under --as-needed). The compiler distribution should specify which third-party library is required for linking/running the apps that use REAL(16). The compiler package may provide a version of the third-party library or at least a stub library that can be used for linking, but the final program execution will still require the actual library.
2024-02-08[Flang][bbc] Prevent bbc -emit-fir command invoking OpenMP passes twice (#80927)agozillon1-5/+23
Currently when the bbc tool is invoked with the emit-fir command the pass pipeline will be invoked twice for verification causing the previously added OpenMP pass pipeline to be invoked multiple times. This change seeks to prevent that from occurring by using a seperate pass manager and run command immediately when it is necessary for the OpenMP passes to be executed.
2024-02-07[flang] Introducing a method to dynamically and conditionally register ↵Vijay Kandiah3-0/+3
dialect interfaces. (#80881) This change introduces the `addFIRExtensions` method to dynamically and conditionally register dialect interfaces. As a use case of `addFIRExtensions`, this change moves the static registration of `FIRInlinerInterface` out of the constructor of `FIROpsDialect` to be dynamically registered while loading the necessary MLIR dialects required by Flang. This registration of `FIRInlinerInterface` is also guarded by a boolean `addFIRInlinerInterface` which defaults to true. --------- Co-authored-by: Vijay Kandiah <vkandiah@nvidia.com>
2024-01-30[Flang][Lower] Attach target_cpu and target_features attributes to MLIR ↵Sergio Afonso2-2/+10
functions (#78289) This patch forwards the target CPU and features information from the Flang frontend to MLIR func.func operation attributes, which are later used to populate the target_cpu and target_features llvm.func attributes. This is achieved in two stages: 1. Introduce the `fir.target_cpu` and `fir.target_features` module attributes with information from the target machine immediately after the initial creation of the MLIR module in the lowering bridge. 2. Update the target rewrite flang pass to get this information from the module and pass it along to all func.func MLIR operations, respectively as attributes named `target_cpu` and `target_features`. These attributes will be automatically picked up during Func to LLVM dialect lowering and used to initialize the corresponding llvm.func named attributes. The target rewrite and FIR to LLVM lowering passes are updated with the ability to override these module attributes, and the `CodeGenSpecifics` optimizer class is augmented to make this information available to target-specific MLIR transformations. This completes a full flow by which target CPU and features make it all the way from compiler options to LLVM IR function attributes.
2024-01-22[flang] Handle -S assemble only flag in flang-to-external-fc (#78979)David Spickett1-0/+4
Flang was recently updated on Compiler Explorer and by default it's in assemble only mode, you have to enable linking and executing. This means that the default output for flang-to-external-fc is nothing, as it doesn't know what `-S` means. You'd have to know to enable the link to binary option to see any output. Handle `-S` so that users of Compiler Explorer don't have to wonder why the "compiler" is broken.
2024-01-10[Flang][OpenMP][MLIR] Add support for -nogpulib option (#71045)Dominik Adamski1-1/+7
If -nogpulib option is passed by the user, then the OpenMP device runtime is not used and we should not emit globals to configure debugging at compile-time for the device runtime. Link to -nogpulib flag implementation for Clang: https://reviews.llvm.org/D125314
2023-12-13[flang] Use StringRef::{starts,ends}_with (NFC)Kazu Hirata1-2/+2
This patch replaces uses of StringRef::{starts,ends}with with StringRef::{starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. I'm planning to deprecate and eventually remove StringRef::{starts,ends}with.
2023-12-06[flang] Updating drivers to create data layout before semantics (#73301)jeanPerier4-23/+74
Preliminary patch to change lowering/code generation to use llvm::DataLayout information instead of generating "sizeof" GEP (see https://github.com/llvm/llvm-project/issues/71507). Fortran Semantic analysis needs to know about the target type size and alignment to deal with common blocks, and intrinsics like C_SIZEOF/TRANSFER. This information should be obtained from the llvm::DataLayout so that it is consistent during the whole compilation flow. This change is changing flang-new and bbc drivers to: 1. Create the llvm::TargetMachine so that the data layout of the target can be obtained before semantics. 2. Sharing bbc/flang-new set-up of the SemanticConstext.targetCharateristics from the llvm::TargetMachine. For now, the actual part that set-up the Fortran type size and alignment from the llvm::DataLayout is left TODO so that this change is mostly an NFC impacting the drivers. 3. Let the lowering bridge set-up the mlir::Module datalayout attributes since it is doing it for the target attribute, and that allows the llvm data layout information to be available during lowering. For flang-new, the changes are code shuffling: the `llvm::TargetMachine` instance is moved to `CompilerInvocation` class so that it can be used to set-up the semantic contexts. `setMLIRDataLayout` is moved to `flang/Optimizer/Support/DataLayout.h` (it will need to be used from codegen pass for fir-opt target independent testing.)), and the code setting-up semantics targetCharacteristics is moved to `Tools/TargetSetup.h` so that it can be shared with bbc. As a consequence, LLVM targets must be registered when running semantics, and it is not possible to run semantics for a target that is not registered with the -triple option (hence the power pc specific modules can only be built if the PowerPC target is available.
2023-12-04[flang] (Re-)Enable alias tags pass by default (#74250)Tom Eccles1-0/+1
Enable by default for optimization levels higher than 0 (same behavior as clang). For simplicity, only forward the flag to the frontend driver when it contradicts what is implied by the optimization level. This was first landed in https://github.com/llvm/llvm-project/pull/73111 but was later reverted due to a performance regression. That regression was fixed by https://github.com/llvm/llvm-project/pull/74065.
2023-11-29Revert "[flang] Enable alias tags pass by default (#73111)" (#73821)Tom Eccles1-1/+0
This reverts commit caba0314cf631a3ba3e982cbcdc455224046c7a8. Serious performance regressions were reported by @vzakhari https://github.com/llvm/llvm-project/issues/58303#issuecomment-1830754173 Fixing this doesn't look quick so I will revert for now.
2023-11-27[flang] Enable alias tags pass by default (#73111)Tom Eccles1-0/+1
Enable by default for optimization levels higher than 0 (same behavior as clang). For simplicity, only forward the flag to the frontend driver when it contradicts what is implied by the optimization level. Since https://github.com/llvm/llvm-project/pull/72903 there are now no known performance regressions.
2023-11-15[flang] Switch lowering to use the HLFIR step by default (#72090)jeanPerier1-1/+1
Patch 3/3 of the transition step 1 described in https://discourse.llvm.org/t/rfc-enabling-the-hlfir-lowering-by-default/72778/7 This patch changes bbc and flang-new driver to use HLFIR lowering by default. `-hlfir=false` can be used with bbc and `-flang-deprecated-no-hlfir` with flang-new to get the previous default lowering behavior, but these options will only be available for a limited period of time. If any user needs these options to workaround bugs, they should open an issue against flang in llvm github repo so that the regression can be fixed in HLFIR.