aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend/CompilerInvocation.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-01-10[Flang][OpenMP][MLIR] Add support for -nogpulib option (#71045)Dominik Adamski1-0/+2
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-28[flang] Pass to add frame pointer attribute (#74598)Radu Salavat1-0/+17
Pass to add frame pointer attribute in Flang
2023-12-15[flang][driver][nfc] Rename one variable (res -> invoc) (#75535)Andrzej Warzyński1-26/+27
The new name better reflects what the variable represents.
2023-12-06[flang] Updating drivers to create data layout before semantics (#73301)jeanPerier1-16/+7
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-05[flang] remove -f[no-]alias-analysis (#74343)Tom Eccles1-5/+0
Now that tbaa tags pass is enabled by default, I would like to remove these flags. `-fno-alias-analysis` was originally intended to be useful for debugging, but as it also disables tbaa tag generation in codegen, it turned out to be too noisy. @banach-space expressed that these flags felt too non-standard. The tbaa tags pass can be toggled using `-mllvm -disable-fir-alias-tags=0`
2023-12-04[flang] Pass Argv0 to getIntriniscDir and getOpenMPHeadersDir (#73254)madanial01-6/+10
The `llvm::sys::fs::getMainExecutable(nullptr, nullptr)` is not able to obtain the correct executable path on AIX without Argv0 due to the lack of a current process on AIX's `proc` filesystem. This causes a build failure on AIX as intrinsic module directory is missing. --------- Co-authored-by: Mark Danial <mak.danial@ibm.com>
2023-12-04[flang] (Re-)Enable alias tags pass by default (#74250)Tom Eccles1-4/+6
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-29[flang][driver][nfc] Move the definition of SemanticsContext (#73669)Andrzej Warzyński1-2/+5
Moves the defintion of `SemanticsContext` within the Flang driver. Rather than in `CompilerInvocation`, semantic context fits better within `CompilerInstance` that encapsulates the objects that are required to run the frontend. `CompilerInvocation` is better suited for objects encapsulating compiler configuration (e.g. set-up resulting from user input or host set-up).
2023-11-29Revert "[flang] Enable alias tags pass by default (#73111)" (#73821)Tom Eccles1-6/+4
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-29[Flang] Add code-object-version option (#72638)Dominik Adamski1-0/+11
Information about code object version can be configured by the user for AMD GPU target and it needs to be placed in LLVM IR generated by Flang. Information about code object version in MLIR generated by the parser can be reused by other tools. There is no need to specify extra flags if we want to invoke MLIR tools (like fir-opt) separately. Changes in comparison to a8ac93: * added information about required targets for test flang/test/Driver/driver-help.f90
2023-11-28Revert "[Flang] Add code-object-version option (#72638)"Dominik Adamski1-11/+0
This commit causes test errors on buildbots. This reverts commit a8ac930b99d93b2a539ada7e566993d148899144.
2023-11-28[Flang] Add code-object-version option (#72638)Dominik Adamski1-0/+11
Information about code object version can be configured by the user for AMD GPU target and it needs to be placed in LLVM IR generated by Flang. Information about code object version in MLIR generated by the parser can be reused by other tools. There is no need to specify extra flags if we want to invoke MLIR tools (like fir-opt) separately.
2023-11-27[flang] Enable alias tags pass by default (#73111)Tom Eccles1-4/+6
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] Add dependent-lib option to flang -fc1 on Windows (#72121)David Truby1-0/+23
This patch adds a --dependent-lib option to flang -fc1 on Windows to embed library link options into the object file. This is needed to properly select the Windows CRT to link against.
2023-11-13[flang] add fveclib flag (#71734)Tom Eccles1-0/+29
-fveclib= allows users to choose a vectorized libm so that loops containing math functions are vectorized. This is implemented as much as possible in the same way as in clang. The driver test in veclib.f90 is copied from the clang test.
2023-11-10[flang][driver] add -flang-deprecated-no-hlfir hidden option (#71820)jeanPerier1-0/+13
Patch 1/3 of the transition to use the HLFIR step by default in lowering as described in https://discourse.llvm.org/t/rfc-enabling-the-hlfir-lowering-by-default/72778/7 This option will allow to lower code without the HLFIR step during a grace period as described in the RFC. It is not meant to be a long term switch for flang.
2023-10-12[flang][driver] add command line arguments for alias tags passTom Eccles1-0/+5
The ultimate intention is to have this pass enabled by default whenever we are optimizing for speed. But for now, just add the arguments so this can be more easily tested. PR: https://github.com/llvm/llvm-project/pull/68595
2023-10-02[flang]Add vscale argument parsing (#67676)Mats Petersson1-0/+37
Support for vector scale range arguments, for AArch64 scalable vector extension (SVE) support. Adds -msve-vector-bits to the flang frontend, and for flang fc1 the options are -mvscale-min and -mvscale-max (optional). These match the clang and clang cc1 options for the same purposes. A further patch will actually USE these arguments.
2023-09-14[NFC][CodeGen] Change CodeGenOpt::Level/CodeGenFileType into enum classes ↵Arthur Eubanks1-2/+2
(#66295) This will make it easy for callers to see issues with and fix up calls to createTargetMachine after a future change to the params of TargetMachine. This matches other nearby enums. For downstream users, this should be a fairly straightforward replacement, e.g. s/CodeGenOpt::Aggressive/CodeGenOptLevel::Aggressive or s/CGFT_/CodeGenFileType::
2023-09-08[flang] Use BIND name, if any, when consolidating common blocks (#65613)jeanPerier1-1/+3
This patch changes how common blocks are aggregated and named in lowering in order to: * fix one obvious issue where BIND(C) and non BIND(C) with the same Fortran name were "merged" * go further and deal with a derivative where the BIND(C) C name matches the assembly name of a Fortran common block. This is a bit unspecified IMHO, but gfortran, ifort, and nvfortran "merge" the common block without complaints as a linker would have done. This required getting rid of all the common block mangling early in FIR (\_QC) instead of leaving that to the phase that emits LLVM from FIR because BIND(C) common blocks did not have mangled names. Care has to be taken to deal with the underscoring option of flang-new. See added flang/test/Lower/HLFIR/common-block-bindc-conflicts.f90 for an illustration.
2023-08-31[Flang][Driver] Add location and remark option printing to R_Group DiagnosticsVictor Kingi1-0/+15
For each R_Group diagnostic produced, this patch gives more information about it by printing the absolute file path, the line and column number the pass was applied to and finally the remark option that was used. Clang does the same with the exception of printing the relative path rather than absolute path. Depends on D159260. That patch adds support for backend passes while this patch adds remark options to the backend test cases. Reviewed By: awarzynski Differential Revision: https://reviews.llvm.org/D159258
2023-08-31[Flang][Driver] Add regex support for R_Group optionsVictor Kingi1-8/+38
Add regex handling for all variations of OPT_R_Joined, i.e. `-Rpass`, `-Rpass-analysis`, `-Rpass-missed`. Depends on D158174. That patch implements backend support for R_Group options. Reviewed By: awarzynski Differential Revision: https://reviews.llvm.org/D158436
2023-08-23[Flang][Driver] Implement OPT_R_Joined optionsVictor Kingi1-0/+54
Add a BackendRemarkConsumer class, responsible for handling diagnostics received from LLVM. The diagnostics being information on middle and backend passes used or not used. Clang by default has all remarks ignored but manually sets the severity of `R_Group` to visible(`clang::diag::clang::Severity::Remark`). This patch does the same for Flang. Depends on D157410. That patch adds the R family of options to `FlangOption` and `FC1Option` in `clang/include/clang/Driver/Options.td` Reviewed By: awarzynski Differential Revision: https://reviews.llvm.org/D158174
2023-08-15[Driver] Refactor to use llvm Option's new Visibility flagsJustin Bogner1-3/+3
This is a big refactor of the clang driver's option handling to use the Visibility flags introduced in https://reviews.llvm.org/D157149. There are a few distinct parts, but they can't really be split into separate commits and still be made to compile. 1. We split out some of the flags in ClangFlags to ClangVisibility. Note that this does not include any subtractive flags. 2. We update the Flag definitions and OptIn/OptOut constructs in Options.td by hand. 3. We introduce and use a script, update_options_td_flags, to ease migration of flag definitions in Options.td, and we run that on Options.td. I intend to remove this later, but I'm committing it so that downstream forks can use the script to simplify merging. 4. We update calls to OptTable in the clang driver, cc1as, flang, and clangd to use the visibility APIs instead of Include/Exclude flags. 5. We deprecate the Include/Exclude APIs and add a release note. *if you are running into conflicts with this change:* Note that https://reviews.llvm.org/D157150 may also be the culprit and if so it should be handled first. The script in `clang/utils/update_options_td_flags.py` can help. Take the downstream side of all conflicts and then run the following: ``` % cd clang/include/clang/Driver % ../../../utils/update_options_td_flags.py Options.td > Options.td.new % mv Options.td.new Options.td ``` This will hopefully be sufficient, please take a look at the diff. Differential Revision: https://reviews.llvm.org/D157151
2023-08-04[flang] Add -fppc-native-vector-element-order option to control the element ↵Kelvin Li1-0/+5
order in PowerPC vector types This patch also adds a LIT test for the vec_cvf intrinsic that can be affected by the option. Co-authored-by: Mark Danial <Mark.Danial@ibm.com> Co-authored-by: Daniel Chen <cdchen@ca.ibm.com> Differential Revision: https://reviews.llvm.org/D155852
2023-07-28[Flang] Add support for fsave-optimization-recordVictor Kingi1-4/+16
Add support for generating and saving the optimization record. Optimization record lists the optimizations performed by LLVM. This patch enables the flag in Flang. Clang handles this functionality using the BackendConsumer which Flang doesn't have, hence, was implemented in CodeGenAction::executeAction FlangOption added to all variants of fsave-optimization-record in clang/include/clang/Driver/Options.td . Clang handles it the same way. opt_record_file, opt_record_passes and opt_record_format flags in Options.td were moved out of the group [CC1Option, NoDriverOption] to allow flang -fc1 support. The renderRemarksOptions and willEmitRemarks functions in clang/lib/Driver/ToolChains/Flang.cpp follow same syntax as clang. In flang/lib/Frontend/CompilerInvocation.cpp we update the field OptRecordFile with the provided optimization file value. Clang doesn't do this as it processes the Options.td, mapping the OptRecordFile earlier on. Reviewed By: awarzynski, tblah Differential Revision: https://reviews.llvm.org/D155452
2023-07-21[flang][nfc] Clarify the usage of llvmArgs and mlirArgsAndrzej Warzynski1-1/+6
Differential Revision: https://reviews.llvm.org/D155931
2023-07-20[MLIR][OpenMP][OMPIRBuilder] Use target triple to initialize `IsGPU` flagSergio Afonso1-0/+17
This patch modifies the construction of the `OpenMPIRBuilder` in MLIR to initialize the `IsGPU` flag using target triple information passed down from the Flang frontend. If not present, it will default to `false`. This replicates the behavior currently implemented in Clang, where the `CodeGenModule::createOpenMPRuntime()` method creates a different `CGOpenMPRuntime` instance depending on the target triple, which in turn has an effect on the `IsGPU` flag of the `OpenMPIRBuilderConfig` object. Differential Revision: https://reviews.llvm.org/D151903
2023-07-18[Flang] Include logical default with default-integer-8Kiran Chandramohan1-0/+1
Other compilers include the logical default also with the default-integer-8 setting. This patch does the same for flang. Reviewed By: awarzynski, sscalpone Differential Revision: https://reviews.llvm.org/D155279
2023-07-10[OpenMP][OMPIRBuilder] Rename IsEmbedded and IsTargetCodegen flagsSergio Afonso1-2/+2
This patch renames the `OpenMPIRBuilderConfig` flags to reduce confusion over their meaning. `IsTargetCodegen` becomes `IsGPU`, whereas `IsEmbedded` becomes `IsTargetDevice`. The `-fopenmp-is-device` compiler option is also renamed to `-fopenmp-is-target-device` and the `omp.is_device` MLIR attribute is renamed to `omp.is_target_device`. Getters and setters of all these renamed properties are also updated accordingly. Many unit tests have been updated to use the new names, but an alias for the `-fopenmp-is-device` option is created so that external programs do not stop working after the name change. `IsGPU` is set when the target triple is AMDGCN or NVIDIA PTX, and it is only valid if `IsTargetDevice` is specified as well. `IsTargetDevice` is set by the `-fopenmp-is-target-device` compiler frontend option, which is only added to the OpenMP device invocation for offloading-enabled programs. Differential Revision: https://reviews.llvm.org/D154591
2023-06-30[openacc][NFC] Bump parser support number to OpenACC 3.3Valentin Clement1-1/+1
Parser support reached OpenACC 3.3 specification. Bump the numbers to reflect the latest specs. Reviewed By: razvanlupusoru, awarzynski Differential Revision: https://reviews.llvm.org/D154249
2023-06-22[flang] add -flang-experimental-polymorphism flag to flang-newDavid Truby1-0/+4
This flag enables Fortran 2003 polymorphism. It is marked experimental and not included in --help. Reviewed By: tblah, awarzynski Differential Revision: https://reviews.llvm.org/D153281
2023-06-13[flang] Add PowerPC vec_add, vec_and, vec_mul, vec_sub and vec_xor intrinsicsKelvin Li1-0/+3
Differential Revision: https://reviews.llvm.org/D151857
2023-06-05[OpenMP][bbc][flang] Add _OPENMP macro definitionDominik Adamski1-2/+3
OpenMP standard (section 3.3 for OpenMP 5.2) requires that _OPENMP macro contains release date of given OpenMP standard version. Differential Revision: https://reviews.llvm.org/D151083 Reviewed By: kiranchandramohan
2023-06-01[flang][hlfir] Separate -emit-fir and -emit-hlfir for flang-newTom Eccles1-3/+7
In review for https://reviews.llvm.org/D146278, @vzakhari asked to separate -emit-fir and -emit-hlfir. This will allow FIR to be easily outputted after the HLFIR passes have been run. The new semantics are as follows: | Action | -flang-experimental-hlfir? | Result | | =========== | ========================== | =============================== | | -emit-hlfir | N | Outputs HLFIR | | -emit-hlfir | Y | Outputs HLFIR | | -emit-fir | N | Outputs FIR, using old lowering | | -emit-fir | Y | Outputs FIR, lowering via HLFIR | A patch for bbc will follow. Differential Revision: https://reviews.llvm.org/D151088
2023-06-01Flang implementation for COMPILER_VERSION and COMPILER_OPTIONS intrinsicsHussain Kadhem1-1/+25
This revision implements the Fortran intrinsic procedures COMPILER_VERSION and COMPILER_OPTIONS from the iso_fortran_env module. To be able to set the COMPILER_OPTIONS string according to the original compiler driver invocation, a string is passed to the frontend driver using the environment variable FLANG_COMPILER_OPTIONS_STRING, for lack of a better mechanism. Fixes #59233 Reviewed By: awarzynski Differential Revision: https://reviews.llvm.org/D140524
2023-05-19[OpenMP][MLIR][Flang][bbc][Driver] Add fopenmp-version and generate ↵Dominik Adamski1-1/+7
corresponding MLIR attribute This patch adds flag -fopenmp-version to the Flang frontend and bbc tool. This flag is lowered to MLIR OpenMP flag attribute. Differential Revision: https://reviews.llvm.org/D150354 Reviewed By: kiranchandramohan
2023-05-16[flang] Finer control over warningsPeter Klausler1-4/+6
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
2023-04-24[Flang][OpenMP][Driver][MLIR] Port fopenmp-host-ir-file-path flag and add ↵Andrew Gozillon1-0/+10
MLIR module attribute to proliferate to OpenMP IR lowering This patch ports the fopenmp-host-ir-file-path flag from Clang to Flang-new, this flag is added by the driver to the device pass when doing two phase compilation (device + host). This flag is then applied to the module when compiling during the OpenMP device phase. This file can then be utilised during lowering of the OpenMP dialect to LLVM-IR, which allows the device and host to maintain 1:1 mapping of OpenMP metadata for variables during lowering via the OpenMPIRBuilders loadOffloadInfoMetadata facilities (which is used for declare target and I believe target regions as well). Reviewer: awarzynski Differential Revision: https://reviews.llvm.org/D148038
2023-04-18Add -f[no-]loop-versioning optionMats Petersson1-0/+4
Add flags for loop-versioning pass enable/disable Reviewed By: awarzynski, tblah Differential Revision: https://reviews.llvm.org/D141307
2023-04-05[OpenMP][MLIR][Flang][bbc][Driver] Add OpenMP RTL Flags to Flang and ↵Andrew Gozillon1-0/+33
generate omp.FlagsAttr from them This patch ports OpenMP RTL flags from the shared Clang compiler options to Flang. As well as adding a limited subset to bbc. This patch enables the flags below (and any equals or inverse variants) for Flang that exist in Clang: -fopenmp-target-debug -fopenmp-assume-threads-oversubscription -fopenmp-assume-teams-oversubscription -fopenmp-assume-no-nested-parallelism -fopenmp-assume-no-thread-state For the bbc tool it only utilises the primary variants to minimize additional complexity in the tool. The patch also provides FlagAttr generation from these flags. Which will be lowered to LLVM-IR in a subsequent patch. Reviewers: kiranchandramohan, awarzynski Differential Revision: https://reviews.llvm.org/D147324
2023-03-29[Flang] Add debug flag to enable current debug information passSacha Ballantyne1-0/+34
While a pass exists to generate basic debug information, currently there is not a corresponding flag to enable it. This patch adds support for activating this pass at any debug level >= -g1, as well as emiting a warning for higher levels that the functionality is not yet fully implemented. This patch also adds -g and -gline-tables-only to appear when `flang-new` --help is run Depends on D142347. Reviewed By: awarzynski Differential Revision: https://reviews.llvm.org/D146814
2023-03-24[flang][driver][openmp] Write MLIR for -save-tempsSergio Afonso1-0/+3
This patch adds support for producing MLIR files when using -save-temps on flang. One MLIR file will be produced before lowering and optimization passes, containing the operations produced by the PFT-to-MLIR lowering bridge, and another at the end of the process, just before LLVM IR generation. This is accomplished by forwarding the -save-temps flag from the driver to the frontend, and modifying it to output MLIR files accordingly. Differential Revision: https://reviews.llvm.org/D146075
2023-03-22[flang] add -flang-experimental-hlfir flag to flang-newTom Eccles1-0/+5
This flag instructs flang-new to use the new HLFIR lowering. It is marked as experimental and not included in --help. This was added to make it more convenient to test the performance of code generated by the HLFIR lowering. Extra diffs are from running clang-format on CLOptions.inc (which was being forced by CI). Differential Revision: https://reviews.llvm.org/D146278
2023-03-09[Flang] Add support to use LTO specific pipelinesNadeem, Usman1-17/+29
Thin and full LTO modes use different pre-link pipelines compared to regular compilation. This patch adds support for calling those pipelines. This patch closely mimics Clang's implementation with the exception that I changed the codegen option name from `PrepareForLTO` to `PrepareForFullLTO` to be more precise. With this patch: - Compilation for full LTO should be as we expect (except possibly missing optimizations enabled by module summaries which we do not produce yet). - thinLTO uses the correct prelink pipeline but will use the postlink backend for fullLTO due to missing metadata and summary in the llvm module. I have added a warning regarding this: `flang-new: warning: the option '-flto=thin' is a work in progress`. Differential Revision: https://reviews.llvm.org/D142420 Change-Id: I6b94b775b5b8e93340e520c5cd4bf60834b2e209
2023-03-07[Flang][OpenMP][MLIR][Driver][bbc] Add -fopenmp-is-device flag to Flang -fc1 ↵Andrew Gozillon1-0/+4
& the bbc tool, and omp.is_device attribute Adds the -fopenmp-is-device flag to bbc and Flang's -fc1 (but not flang-new) and in addition adds an omp.is_device attribute onto the module when fopenmp is passed, this is a boolean attribute that is set to false or true dependent on if fopenmp-is-device is specified alongside the fopenmp flag on the commandline when invoking flang or bbc. Reviewers: awarzynski kiranchandramohan Differential Revision: https://reviews.llvm.org/D144864
2023-02-21[flang] Handle unsupported warning flagsEthan Luis McDonough1-8/+11
This PR makes flang emit a warning when the user passes an unsupported gfortran warning flag in as a CLI arg. This PR also checks each `-W` argument instead of just looking at the last one passed in. Reviewed By: awarzynski Differential Revision: https://reviews.llvm.org/D143301
2023-02-21[Flang] Add user option -funderscoring/-fnounderscoring to control trailing ↵Mark Danial1-0/+6
underscore added to external names This patch adds user option -funderscoring/-fnounderscoring to control the trailing underscore being appended to external names (e.g. procedure names, common block names). The option in gfortran is documented in https://gcc.gnu.org/onlinedocs/gfortran/Code-Gen-Options.html. Reviewed By: clementval Differential Revision: https://reviews.llvm.org/D140795
2023-02-10[NFC][TargetParser] Replace uses of llvm/Support/Host.hArchibald Elliott1-1/+1
The forwarding header is left in place because of its use in `polly/lib/External/isl/interface/extract_interface.cc`, but I have added a GCC warning about the fact it is deprecated, because it is used in `isl` from where it is included by Polly.
2023-02-07[NFC][TargetParser] Remove llvm/ADT/Triple.hArchibald Elliott1-1/+1
I also ran `git clang-format` to get the headers in the right order for the new location, which has changed the order of other headers in two files.