aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend/CompilerInvocation.cpp
AgeCommit message (Collapse)AuthorFilesLines
39 hours[flang][MLIR][OpenMP][llvm]Atomic Control Support (#150860)Anchu Rajendran S1-0/+10
5 daysRevert "[flang][flang-driver][mlir][OpenMP] atomic control support" (#150504)Kiran Chandramohan1-10/+0
Reverts llvm/llvm-project#143441 Reverting due to CI failure https://lab.llvm.org/buildbot/#/builders/53/builds/18055.
5 days[flang][flang-driver][mlir][OpenMP] atomic control support (#143441)Anchu Rajendran S1-0/+10
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.
2025-07-09[flang][driver] add -Wfatal-errors (#147614)Andre Kuhlenschmidt1-1/+5
Adds the flag `-Wfatal-errors` which truncates the error messages at 1 error.
2025-07-09[flang] Add -fcomplex-arithmetic= option and select complex division ↵Shunsuke Watanabe1-0/+21
algorithm (#146641) This patch adds an option to select the method for computing complex number division. It uses `LoweringOptions` to determine whether to lower complex division to a runtime function call or to MLIR's `complex.div`, and `CodeGenOptions` to select the computation algorithm for `complex.div`. The available option values and their corresponding algorithms are as follows: - `full`: Lower to a runtime function call. (Default behavior) - `improved`: Lower to `complex.div` and expand to Smith's algorithm. - `basic`: Lower to `complex.div` and expand to the algebraic algorithm. See also the discussion in the following discourse post: https://discourse.llvm.org/t/optimization-of-complex-number-division/83468 --------- Co-authored-by: Tarun Prabhu <tarunprabhu@gmail.com>
2025-07-07[flang] Correctly handle -mframe-pointer=reserved (#146937)Daniel Paoliello1-1/+2
Fixes `#146802` #146582 started using the `Reserved` Frame Pointer kind for Arm64 Windows, but this revealed a bug in Flang where it copied the `-mframe-pointer=reserved` flag from Clang, but didn't correctly handle it in its own command line parser and subsequent compilation pipeline. This change adds support for `-mframe-pointer=reserved` and adds a test to make sure that functions are correctly marked when the flag is set.
2025-07-04[Clang] Introduce `--offload-targets` for `-fopenmp-targets` (#146594)Joseph Huber1-1/+1
Summary: This patch is mostly an NFC that renames the existing `-fopenmp-targets` into `--offload-targets`. Doing this early to simplify a follow-up patch that will hopefully allow this syntax to be used more generically over the existing `--offload` syntax (which I think is mostly unmaintained now.). Following in the well-trodden path of trying to pull language specific offload options into generic ones, but right now this is still just OpenMP specific.
2025-06-30[flang] add option to generate runtime type info as external (#146071)jeanPerier1-0/+2
Reland #145901 with a fix for shared library builds. So far flang generates runtime derived type info global definitions (as opposed to declarations) for all the types used in the current compilation unit even when the derived types are defined in other compilation units. It is using linkonce_odr to achieve derived type descriptor address "uniqueness" aspect needed to match two derived type inside the runtime. This comes at a big compile time cost because of all the extra globals and their definitions in apps with many and complex derived types. This patch adds and experimental option to only generate the rtti definition for the types defined in the current compilation unit and to only generate external declaration for the derived type descriptor object of types defined elsewhere. Note that objects compiled with this option are not compatible with object files compiled without because files compiled without it may drop the rtti for type they defined if it is not used in the compilation unit because of the linkonce_odr aspect. I am adding the option so that we can better measure the extra cost of the current approach on apps and allow speeding up some compilation where devirtualization does not matter (and the build config links to all module file object anyway).
2025-06-26[flang][OpenMP] Remove experimental warning (#144915)Tom Eccles1-2/+6
RFC: https://discourse.llvm.org/t/rfc-removing-the-openmp-experimental-warning-for-llvm-21/86455 Fixes: #110008
2025-06-25[flang][OpenMP] Verify that N in -fopenmp-version=N is valid (#145725)Krzysztof Parzyszek1-4/+38
For historical versions that are unsupported, emit a warning and assume the currently default version. For values of N that are not integers or that don't correspond to any OpenMP version (old or newer), emit an error.
2025-06-18[flang][driver] add ability to look up feature flags without setting them ↵Andre Kuhlenschmidt1-1/+1
(#144559) This just adds some convenience methods to feature control and rewrites old code in terms of those methods. Also cleans up some names that I just realize were overloads of another method.
2025-06-13Fix and reapply IR PGO support for Flang (#142892)FYK1-0/+10
This PR resubmits the changes from #136098, which was previously reverted due to a build failure during the linking stage: ``` undefined reference to `llvm::DebugInfoCorrelate' undefined reference to `llvm::ProfileCorrelate' ``` The root cause was that `llvm/lib/Frontend/Driver/CodeGenOptions.cpp` references symbols from the `Instrumentation` component, but the `LINK_COMPONENTS` in the `llvm/lib/Frontend/CMakeLists.txt` for `LLVMFrontendDriver` did not include it. As a result, linking failed in configurations where these components were not transitively linked. ### Fix: This updated patch explicitly adds `Instrumentation` to `LINK_COMPONENTS` in the relevant `llvm/lib/Frontend/CMakeLists.txt` file to ensure the required symbols are properly resolved. --------- Co-authored-by: ict-ql <168183727+ict-ql@users.noreply.github.com> Co-authored-by: Chyaka <52224511+liliumshade@users.noreply.github.com> Co-authored-by: Tarun Prabhu <tarunprabhu@gmail.com>
2025-06-10[flang] Add support for -mrecip[=<list>] (#143418)Cameron McInally1-1/+3
This patch adds support for the -mrecip command line option. The parsing of this options is equivalent to Clang's and it is implemented by setting the "reciprocal-estimates" function attribute. Also move the ParseMRecip(...) function to CommonArgs, so that Flang is able to make use of it as well. --------- Co-authored-by: Cameron McInally <cmcinally@nvidia.com>
2025-06-10[flang][cli] Add diagnostic flags to the CLI (#142022)Andre Kuhlenschmidt1-34/+30
This change allows the flang CLI to accept `-W[no-]<feature>` flags matching the clang syntax and enable and disable usage and language feature warnings.
2025-06-06[Driver] Move CommonArgs to a location visible by the Frontend Drivers (#142800)Cameron McInally1-13/+3
This patch moves the CommonArgs utilities into a location visible by the Frontend Drivers, so that the Frontend Drivers may share option parsing code with the Compiler Driver. This is useful when the Frontend Drivers would like to verify that their incoming options are well-formed and also not reinvent the option parsing wheel. We already see code in the Clang/Flang Drivers that is parsing and verifying its incoming options. E.g. OPT_ffp_contract. This option is parsed in the Compiler Driver, Clang Driver, and Flang Driver, all with slightly different parsing code. It would be nice if the Frontend Drivers were not required to duplicate this Compiler Driver code. That way there is no/low maintenance burden on keeping all these parsing functions in sync. Along those lines, the Frontend Drivers will now have a useful mechanism to verify their incoming options are well-formed. Currently, the Frontend Drivers trust that the Compiler Driver is not passing back junk in some cases. The Language Drivers may even accept junk with no error at all. E.g.: `clang -cc1 -mprefer-vector-width=junk test.c' With this patch, we'll now be able to tighten up incomming options to the Frontend drivers in a lightweight way. --------- Co-authored-by: Cameron McInally <cmcinally@nvidia.com> Co-authored-by: Shafik Yaghmour <shafik.yaghmour@intel.com>
2025-06-04[flang] Add aarch64 processor defines (#142606)David Truby1-0/+4
This patch adds aarch64 specific processor defines when targeting aarch64, similar to the ones for ppc64 and x86_64
2025-05-30Revert "Add IR Profile-Guided Optimization (IR PGO) support to the Flang ↵Tarun Prabhu1-10/+0
compiler" (#142159) Reverts llvm/llvm-project#136098
2025-05-30Add IR Profile-Guided Optimization (IR PGO) support to the Flang compiler ↵FYK1-0/+10
(#136098) This patch implements IR-based Profile-Guided Optimization support in Flang through the following flags: - `-fprofile-generate` for instrumentation-based profile generation - `-fprofile-use=<dir>/file` for profile-guided optimization Resolves #74216 (implements IR PGO support phase) **Key changes:** - Frontend flag handling aligned with Clang/GCC semantics - Instrumentation hooks into LLVM PGO infrastructure - LIT tests verifying: - Instrumentation metadata generation - Profile loading from specified path - Branch weight attribution (IR checks) **Tests:** - Added gcc-flag-compatibility.f90 test module verifying: - Flag parsing boundary conditions - IR-level profile annotation consistency - Profile input path normalization rules - SPEC2006 benchmark results will be shared in comments For details on LLVM's PGO framework, refer to [Clang PGO Documentation](https://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization). This implementation was developed by [XSCC Compiler Team](https://github.com/orgs/OpenXiangShan/teams/xscc). --------- Co-authored-by: ict-ql <168183727+ict-ql@users.noreply.github.com> Co-authored-by: Tom Eccles <t@freedommail.info>
2025-05-30[flang] Add support for -mprefer-vector-width=<value> (#142073)Cameron McInally1-0/+14
This patch adds support for the -mprefer-vector-width= command line option. The parsing of this options is equivalent to Clang's and it is implemented by setting the "prefer-vector-width" function attribute. Co-authored-by: Cameron McInally <cmcinally@nvidia.com>
2025-05-21[flang] add -floop-interchange and enable it with opt levels (#140182)Sebastian Pop1-0/+3
Enable the use of -floop-interchange from the flang driver. Enable in flang LLVM's loop interchange at levels -O2, -O3, -Ofast, and -Os.
2025-05-20[flang][veclib] Adding AMDLIBM target to fveclib (#140533)shivaramaarao1-0/+1
This commit adds AMDLIBM support to fveclib targets. The support is already present in clang and this patch extends it to flang.
2025-05-07[flang][AIX] Predefine __64BIT__ and _AIX macros (#138591)Kelvin Li1-5/+12
2025-05-06[Clang][Flang][Driver] Fix target parsing for -fveclib=libmvec option. (#138288)Paul Walker1-1/+1
There are various places where the -fveclib option is parsed to determine whether its value is correct for the target. Unfortunately these places assume case-insensitivity and subsequently use "LIBMVEC" where the driver mandates "libmvec", thus rendering the diagnosistic useless. This PR corrects the naming along with similar incorrect uses within the test files.
2025-05-02[flang][flang-driver] Support flag -finstrument-functions (#137996)Anchu Rajendran S1-0/+3
2025-04-03[flang] Added driver options for arrays repacking. (#134002)Slava Zakharin1-0/+13
Added options: * -f[no-]repack-arrays * -f[no-]stack-repack-arrays * -frepack-arrays-contiguity=whole/innermost
2025-04-02[flang][OpenMP] Bump default OpenMP version to 3.1 (#133745)Tom Eccles1-2/+2
Precise OpenMP standards support information is being documented in #132707 Flang now has good support for OpenMP Version 3.1 and earlier.
2025-04-02[flang][OpenMP] Upstream first part of `do concurrent` mapping (#126026)Kareem Ergawy1-0/+28
This PR starts the effort to upstream AMD's internal implementation of `do concurrent` to OpenMP mapping. This replaces #77285 since we extended this WIP quite a bit on our fork over the past year. An important part of this PR is a document that describes the current status downstream, the upstreaming status, and next steps to make this pass much more useful. In addition to this document, this PR also contains the skeleton of the pass (no useful transformations are done yet) and some testing for the added command line options. This looks like a huge PR but a lot of the added stuff is documentation. It is also worth noting that the downstream pass has been validated on https://github.com/BerkeleyLab/fiats. For the CPU mapping, this achived performance speed-ups that match pure OpenMP, for GPU mapping we are still working on extending our support for implicit memory mapping and locality specifiers. PR stack: - https://github.com/llvm/llvm-project/pull/126026 (this PR) - https://github.com/llvm/llvm-project/pull/127595 - https://github.com/llvm/llvm-project/pull/127633 - https://github.com/llvm/llvm-project/pull/127634 - https://github.com/llvm/llvm-project/pull/127635
2025-03-28[clang][flang][Triple][llvm] Add isOffload function to LangOpts and isGPU ↵Nick Sarnie1-12/+4
function to Triple (#126956) I'm adding support for SPIR-V, so let's consolidate these checks. --------- Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
2025-03-26[flang] Add -f[no-]slp-vectorize flags (#132801)Kajetan Puchalski1-0/+3
Add -f[no-]slp-vectorize to the flang driver. Add corresponding -fvectorize-slp to the flang frontend. Enable -fslp-vectorize at -O2 and higher in flang to match the current behaviour in clang. --------- Signed-off-by: Kajetan Puchalski <kajetan.puchalski@arm.com>
2025-03-14[NFC][AMDGPU] Replace more direct arch comparison with isAMDGCN() (#131379)Shilei Tian1-2/+1
This is an extension of #131357. Hopefully this would be the last one.
2025-03-13[flang] Add support for -f[no-]verbose-asm (#130788)Tom Eccles1-0/+4
This flag provides extra commentary in the assembly output.
2025-03-12[flang] Align `-x` language modes with `gfortran` (#130268)Iñaki Amatria Barral1-0/+6
This PR addresses some of the issues described in https://github.com/llvm/llvm-project/issues/127617. Key changes: - Stop assuming fixed-form for `-x f95` unless the input is a `.i` file. This change ensures compatibility with `-save-temps` workflows while preventing unintended fixed-form assumptions. - Ensure `-x f95-cpp-input` enables `-cpp` by default, aligning Flang's behavior with `gfortran`.
2025-03-03[flang][Driver] Add support of -fd-lines-as-comments and -fd-lines-as-code ↵Jean-Didier PAILLEUX1-0/+26
flags (#127605) `-fd-lines-as-code` and `-fd-lines-as-comments` enables treatment for lines beginning with `d` or `D` in fixed form sources. Using these options in free form has no effect. If the `-fd-lines-as-code` option is given they are treated as if the first column contained a blank. If the `-fd-lines-as-comments` option is given, they are treated as comment lines.
2025-02-20[flang] Add -f[no-]vectorize flags (#119718)David Truby1-0/+4
This patch adds the -fvectorize and -fno-vectorize flags to flang. Note that this also changes the behaviour of `flang -fc1` to match that of `clang -cc1`, which is that vectorization is only enabled in the presence of the `-vectorize-loops` flag. Additionally, this patch changes the behaviour of the default optimisation levels to match clang, such that vectorization only happens at the same levels as it does there. This patch is in draft while I write an RFC to discuss the above two changes.
2025-02-13[flang][RISCV] Add target-abi ModuleFlag. (#126188)Craig Topper1-0/+1
This is needed to generate proper ABI flags in the ELF header for LTO builds. If these flags aren't set correctly, we can't link with objects that were built with the correct flags. For non-LTO builds the mcpu/mattr in the TargetMachine will cause the backend to infer an ABI. For LTO builds the mcpu/mattr aren't set. I've only added lp64, lp64f, and lp64d ABIs. ilp32* requires riscv32 which is not yet supported in flang. lp64e requires a different DataLayout string and would need additional plumbing. Fixes #115679
2025-02-13[Flang] Fix leftover use of 'OPT_nogpulib'Joseph Huber1-1/+1
Summary: This didn't show up as a failure in precommit and I don't build flang so this slipped by.
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.