aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend/CompilerInvocation.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-02-06[Flang] Move non-common headers to FortranSupport (#124416)Michael Kruse1-3/+3
Move non-common files from FortranCommon to FortranSupport (analogous to LLVMSupport) such that * declarations and definitions that are only used by the Flang compiler, but not by the runtime, are moved to FortranSupport * declarations and definitions that are used by both ("common"), the compiler and the runtime, remain in FortranCommon * generic STL-like/ADT/utility classes and algorithms remain in FortranCommon This allows a for cleaner separation between compiler and runtime components, which are compiled differently. For instance, runtime sources must not use STL's `<optional>` which causes problems with CUDA support. Instead, the surrogate header `flang/Common/optional.h` must be used. This PR fixes this for `fast-int-sel.h`. Declarations in include/Runtime are also used by both, but are header-only. `ISO_Fortran_binding_wrapper.h`, a header used by compiler and runtime, is also moved into FortranCommon.
2025-02-04[flang] Add support for -fimplicit-none-ext option (#125248)Eugene Epshteyn1-0/+6
When -fimplicit-none-ext is passed, flang behaves as if "implicit none(external)" was specified for all relevant constructs in Fortran source file. Note: implicit17.f90 was based on implicit07.f90 with `implicit none(external)` removed and `-fimplicit-none-ext` added.
2025-01-27[flang][driver] add negative from of -fsave-main-program (#124110)jeanPerier1-4/+5
Add the `-fno` form for consistency and to make it easy to switch the default for downstream users.
2025-01-21Reland "[Flang][Driver] Add a flag to control zero initialization" (#123606)Kiran Chandramohan1-0/+8
Reverts llvm/llvm-project#123330
2025-01-17Revert "Revert "Revert "[Flang][Driver] Add a flag to control zero ↵Kiran Chandramohan1-8/+0
initializa…" (#123330) Reverts llvm/llvm-project#123097 Reverting due to buildbot failure https://lab.llvm.org/buildbot/#/builders/89/builds/14577.
2025-01-17Revert "Revert "[Flang][Driver] Add a flag to control zero initializa… ↵Kiran Chandramohan1-0/+8
(#123097) …tion of global v…" (#123067)" This reverts commit 44ba43aa2b740878d83a9d6f1d52a333c0d48c22. Adds the flag to bbc as well.
2025-01-16[flang] Add -f[no-]unroll-loops flag (#122906)David Truby1-0/+4
2025-01-15Revert "[Flang][Driver] Add a flag to control zero initialization of global ↵Kiran Chandramohan1-8/+0
v…" (#123067) Reverts llvm/llvm-project#122144 Reverting due to CI failure https://lab.llvm.org/buildbot/#/builders/89/builds/14422
2025-01-15[Flang][Driver] Add a flag to control zero initialization of global v… ↵Kiran Chandramohan1-0/+8
(#122144) …ariables Patch adds a flag to control zero initialization of global variables without default initialization. The default is to zero initialize.
2025-01-14[flang][Driver] Preliminary support for -ftime-report (#122894)macurtis-amd1-0/+4
The behavior is not entirely consistent with that of clang for the moment since detailed timing information on the LLVM IR optimization and code generation passes is not provided. The -ftime-report= option is also not enabled since that is only relevant for information about the LLVM IR passes. However, some code to handle that option has been included, to make it easier to support the option when the issues blocking it are resolved. A FortranSupport library has been created that is intended to mirror the LLVM and MLIR support libraries. Based on @tarunprabhu's PR https://github.com/llvm/llvm-project/pull/107270 with minor changes addressing latest review feedback. He's busy and we'd like to get this support in ASAP. Co-authored-by: Tarun Prabhu <tarun.prabhu@gmail.com>
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.