aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend/CompilerInvocation.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-01-08[flang][driver] add option to make all main program variable static (#121968)jeanPerier1-0/+5
Co-authored-by: Kiran Chandramohan <kiranchandramohan@gmail.com>
2024-12-18[flang] Add UNSIGNED (#113504)Peter Klausler1-0/+6
Implement the UNSIGNED extension type and operations under control of a language feature flag (-funsigned). This is nearly identical to the UNSIGNED feature that has been available in Sun Fortran for years, and now implemented in GNU Fortran for gfortran 15, and proposed for ISO standardization in J3/24-116.txt. See the new documentation for details; but in short, this is C's unsigned type, with guaranteed modular arithmetic for +, -, and *, and the related transformational intrinsic functions SUM & al.
2024-12-17[flang] Support -f[no-]realloc-lhs. (#120165)Slava Zakharin1-0/+5
-frealloc-lhs is the default. If -fno-realloc-lhs is specified, then an allocatable on the left side of an intrinsic assignment is not implicitly (re)allocated to conform with the right hand side. Fortran runtime will issue an error if there is a mismatch in shape/type/allocation-status.
2024-12-10Reland "[flang] Integrate the option -flang-experimental-integer-overflow ↵Yusuke MINATO1-6/+0
into -fno-wrapv" (#118933) This relands #110063. The performance issue on 503.bwaves_r is found not to be related to the patch, and is resolved by fbd89bcc when LTO is enabled.
2024-11-22[flang][Driver] Support -print-supported-cpus and associated aliases (#117199)Tarun Prabhu1-0/+2
The aliases are -mcpu=help and -mtune=help. There is still an issue with the output which prints an example line that references clang. That is not fixed here because it is printed in llvm/MC/SubtargetInfo.cpp. Some more thought is needed to determine how best to handle this. Fixes #117010
2024-10-29[flang] Support -mabi=vec-extabi and -mabi=vec-default on AIX (#113215)Kelvin Li1-0/+10
This option is to enable the AIX extended and default vector ABIs.
2024-10-28Revert "[flang] Integrate the option -flang-experimental-integer-overflow ↵Yusuke MINATO1-0/+6
into -fno-wrapv" (#113901) Reverts llvm/llvm-project#110063 due to the performance regression on 503.bwaves_r in SPEC2017.
2024-10-25[flang] Integrate the option -flang-experimental-integer-overflow into ↵Yusuke MINATO1-6/+0
-fno-wrapv (#110063) nsw is now added to do-variable increment when -fno-wrapv is enabled as GFortran seems to do. That means the option introduced by #91579 isn't necessary any more. Note that the feature of -flang-experimental-integer-overflow is enabled by default.
2024-10-18[flang][Driver] Add support for -f[no-]wrapv and -f[no]-strict-overflow in ↵Yusuke MINATO1-3/+33
the frontend (#110061) This patch introduces the options for integer overflow flags into Flang. The behavior is similar to that of Clang.
2024-10-14[clang][flang][mlir] Reapply "Support -frecord-command-line option (#102975)"Tarun Prabhu1-0/+6
The underlying issue was caused by a file included in two different places which resulted in duplicate definition errors when linking individual shared libraries. This was fixed in c3201ddaeac02a2c86a38b [#109874].
2024-10-10[flang][driver] rename flang-new to flang (#110023)Brad Richardson1-3/+3
This does a global rename from `flang-new` to `flang`. I also removed/changed any TODOs that I found related to making this change. --------- Co-authored-by: H. Vetinari <h.vetinari@gmx.com> Co-authored-by: Andrzej Warzynski <andrzej.warzynski@arm.com>
2024-09-30[flang][preprocessor] Don't expand INCLUDE under -E by default (#110333)Peter Klausler1-0/+6
Fortran INCLUDE lines have (until now) been treated like #include directives. This isn't how things work with other Fortran compilers when running under the -E option for preprocessing only, so stop doing it by default, and add -fpreprocess-include-lines to turn it back on when desired.
2024-09-27[flang][driver] Make the -J option less restrictive so we would not have to ↵Paul Osmialowski1-3/+10
struggle with autoconf (#110010) There are autoconf-configured projects for which the generated Makefile is invoking flang with more than one -J option, each one specifying the same directory. Although only one module directory should be specified (by either -J or -module-dir), it should not really matter how many times this same directory has been specified. Apparently, other compilers understand it that way, hence autoconf's configure script may generate a Makefile with the repetitive -J's. For example, when trying to build the ABINIT [1] project (which can be configured by either CMake or the configure script) when configured by autoconf, it fails to build as such: ``` make[3]: Entering directory 'src/98_main' mpifort -DHAVE_CONFIG_H -I. -I../../../src/98_main -I../.. -I../../src/incs -I../../../src/incs -Ifallbacks/exports/include -Jbuild/mods -Jbuild/mods -c -o abinit-abinit.o `test -f 'abinit.F90' || echo '../../../src/98_main/'`abinit.F90 error: Only one '-module-dir/-J' option allowed make[3]: *** [Makefile:3961: abinit-abinit.o] Error 1 ``` This patch solves the problem. [1] https://github.com/abinit/abinit.git
2024-09-26[flang][Semantics] Add LangOptions to SemanticsContext (#110013)Krzysztof Parzyszek1-1/+2
The motivation for this is to make OpenMP settings visible in the semantic checks (OpenMP version in particular).
2024-09-26[flang][Frontend] Move LangOptions from Frontend to Common (#110012)Krzysztof Parzyszek1-8/+8
The information in LangOptions is not tied to any frontend code, and could be used by any other component.
2024-09-20Revert "[clang][flang][mlir] Support -frecord-command-line option (#102975)"David Spickett1-6/+0
This reverts commit b3533a156da92262eb19429d8c12f53e87f5ccec. It caused test failures in shared library builds: https://lab.llvm.org/buildbot/#/builders/80/builds/3854
2024-09-19[clang][flang][mlir] Support -frecord-command-line option (#102975)Tarun Prabhu1-0/+6
Add support for the -frecord-command-line option that will produce the llvm.commandline metadata which will eventually be saved in the object file. This behavior is also supported in clang. Some refactoring of the code in flang to handle these command line options was carried out. The corresponding -grecord-command-line option which saves the command line in the debug information has not yet been enabled for flang.
2024-09-04Allow disabling of types from the command line (#107126)Renaud Kauffmann1-3/+14
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-09-04[flang][Driver] support -fno-openmp (#107087)Tom Eccles1-1/+3
Closes #83148
2024-08-02[Flang][OpenMP] Add frontend support for -fopenmp-targets (#100155)Sergio Afonso1-80/+126
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-26Fix build flang issue. (#100736)Zahira Ammarguellat1-1/+1
2024-07-16Add basic -mtune support (#98517)Alexis Perry-Holby1-0/+4
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-11[flang] Add -fhermetic-module-files (#98083)Peter Klausler1-0/+5
Module files emitted by this Fortran compiler are valid Fortran source files. Symbols that are USE-associated into modules are represented in their module files with USE statements and special comments with hash codes in them to ensure that those USE statements resolve to the same modules that were used to build the module when its module file was generated. This scheme prevents unchecked module file growth in large applications by not emitting USE-associated symbols redundantly. This problem can be especially bad when derived type definitions must be repeated in the module files of their clients, and the clients of those modules, and so on. However, this scheme has the disadvantage that clients of modules must be compiled with dependent modules in the module search path. This new -fhermetic-module-files option causes module file output to be free of dependences on any non-intrinsic module files; dependent modules are instead emitted as part of the module file, rather than being USE-associated. It is intended for top level library module files that are shipped with binary libraries when it is not convenient to collect and ship their dependent module files as well. Fixes https://github.com/llvm/llvm-project/issues/97398.
2024-07-03[flang] Implement -mcmodel flag (#95411)David Truby1-0/+24
This patch implements the -mcmodel flag from clang, allowing the Code Model to be changed for the LLVM module. The same set of mcmodel flags are accepted as in clang and the same Code Model attributes are added to the LLVM module for those flags. Also add `-mlarge-data-threshold` for x86-64, which is automatically set by the shared command-line code (see below). This is also added as an attribute into the LLVM module and on the target machine. A function is created for `addMCModel` that is copied out of clang's argument handling so that it can be shared with flang. --------- Co-authored-by: Mats Petersson <mats.petersson@arm.com>
2024-06-25Revert "[flang] Add basic -mtune support" (#96678)Tarun Prabhu1-4/+0
Reverts llvm/llvm-project#95043
2024-06-25[flang] Add basic -mtune support (#95043)Alexis Perry-Holby1-0/+4
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-17[flang] Add -mlink-builtin-bitcode option to fc1 (#94763)Jan Leyonberg1-0/+5
This patch enables the -mlink-builtin-bitcode flag in fc1 so that bitcode libraries can be linked in. This is needed for OpenMP offloading libraries.
2024-06-05[Flang][OpenMP] Add -fopenmp-force-usm option to flang (#94359)Sergio Afonso1-0/+3
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-16[flang] Add nsw flag to do-variable increment with a new option (#91579)Yusuke MINATO1-0/+6
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-15[flang] New -fdebug-unparse-with-modules option (#91660)Peter Klausler1-0/+3
This option is a compilation action that parses a source file and performs semantic analysis on it, like the existing -fdebug-unparse option does. Its output, however, is preceded by the effective contents of all of the non-intrinsic modules on which it depends but does not define, transitively preceded by the closure of all of those modules' dependencies. The output from this option is therefore the analyzed parse tree for a source file encapsulated with all of its non-intrinsic module dependencies. This output may be useful for extracting code from large applications for use as an attachment to a bug report, or as input to a test case reduction tool for problem isolation.
2024-05-12Use StringRef::operator== instead of StringRef::equals (NFC) (#91864)Kazu Hirata1-2/+2
I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator==/!= outnumber StringRef::equals by a factor of 276 under llvm-project/ in terms of their usage. - The elimination of StringRef::equals brings StringRef closer to std::string_view, which has operator== but not equals. - S == "foo" is more readable than S.equals("foo"), especially for !Long.Expression.equals("str") vs Long.Expression != "str".
2024-05-08[Flang] RFC: Add support for -w option 1/n (#90420)Kiran Chandramohan1-0/+10
Add support for the -w option to switch OFF all Flang warnings. This patch only supports switching OFF the frontend warnings. TODO : Support for MLIR, LLVM and Driver warnings. TODO : Support interactions between -w, -pedantic, -Wall
2024-04-22[flang] Default -g to full debug info. (#89418)abidh1-0/+1
Currently, -g defaults to line tables only. This PR changes that to full debug information. This will allow us to test/use the upcoming debug info changes.
2024-04-10[Flang] Define c_int_fast16_t and c_int_fast32_t for PowerPC. (#88292)Daniel Chen1-8/+9
On Linux, PowerPC defines `int_fast16_t` and `int_fast32_t` as `long`. Need to update the corresponding type, `c_int_fast16_t` and `c_int_fast32_t` in `iso_c_binding` module so they are interoparable.
2024-04-10[flang][Frontend] Implement printing defined macros via -dM (#87627)Krzysztof Parzyszek1-0/+1
This should work the same way as in clang.
2024-03-19[flang] Enable polymorphic lowering by default (#83285)jeanPerier1-5/+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-13[flang][cuda] Enable cuda with -x cuda option (#84944)Valentin Clement (バレンタイン クレメン)1-0/+9
Flang driver was already able to enable the CUDA language feature base on the file extension but there was no command line option. This PR adds one.
2024-02-13[Flang] Add __powerpc__ macro to set c_intmax_t to c_int64_t rather than ↵Daniel Chen1-1/+14
c_int128_t as PowerPC only supports up to c_int64_t. (#81222) PowerPC only supports up to `c_int64_t`. Add macro `__powerpc__` and preprocess it for setting `c_intmax_t` in `iso_c_binding` intrinsic module.
2024-02-05[AMDGPU] Introduce Code Object V6 (#76954)Pierre van Houtryve1-0/+2
Introduce Code Object V6 in Clang, LLD, Flang and LLVM. This is the same as V5 except a new "generic version" flag can be present in EFLAGS. This is related to new generic targets that'll be added in a follow-up patch. It's also likely V6 will have new changes (possibly new metadata entries) added later. Docs change are part of the follow-up patch #76955
2024-01-15[flang][driver] Limit the usage of -mvscale-max and -mvscale-min (#77905)Andrzej Warzyński1-14/+31
Make sure that `-mvscale-max` and `-mvscale-min` are only available for targets that are known to support vscale and scalable vectors. Also fix capitalization of function variables.
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