Commit Graph

506 Commits

Author SHA1 Message Date
Yusuke MINATO
c7ca7047a7 [flang][docs] Reorganize the table of contents (#171240)
This patch creates a section for user guidance.
2025-12-12 05:02:51 +00:00
Aashcharya Gorakh
a1b3586492 [flang][docs] Remove stale inline links to Intel and IBM compiler option
Remove all inline links to Intel and IBM compiler options from the
comparison tables, as these links have become stale (Intel links
redirect to generic pages, IBM links redirect to PDF-only pages).

Option names are preserved for readability. The Data sources section
still contains links to the main documentation pages.

Details:

- Removed 43 Intel compiler option links
- Removed 35 IBM compiler option links
- Removed 2 stale links in notes section
- Updated documentation text accordingly

Fixes #171464

---------

Co-authored-by: Tarun Prabhu <tarun@lanl.gov>
2025-12-11 18:45:54 -07:00
Tom Eccles
54b4bd510a [flang][AliasAnalysis] Cray pointers/pointees might alias with anything (#170900)
The LOC intrinsic allows a cray pointer to alias with ordinary variables
with no other attribute. See the new test for an example.

This is not enabled by default. The functionality can be used with
`-mmlir -funsafe-cray-pointers`.

First part of the un-revert of #169544. That will handle TBAA.
2025-12-10 15:32:27 +00:00
David Spickett
4c7b5dfbc2 [flang][docs] Do not recommend FLANG_ENABLE_WERROR=ON... (#171152)
...unless the reader is going to contribute to Flang.

Fixes #168911.

In which someone followed the getting started instructions but because
they were using GCC and it produced some warnings, those got upgraded to
errors and failed the build.

The GCC builds of anything in LLVM are always going to have some warning
of some kind, so while it would be nice to fix or silence them, let's
not inflict that on new developers.

This option defaults to `OFF` and is turned `ON` by a handful of bots,
so if the intent was to make developers more attentive to warnings, that
will still happen. Just a bit later, which that's better than putting
them off up front.

If they go on to contribute, they can switch to a Clang build and enable
the option to save themselves some post-commit hassle.
2025-12-10 09:29:09 +00:00
KAWASHIMA Takahiro
09eb25f1fa [flang][docs] Replace Flang to Classic Flang in old doc (#171558)
This document was written when Flang was known as F18 and Classic Flang
was known as Flang. The term "Flang" in this document refers to Classic
Flang, except in the first paragraph.

Also, a trivial HTML error is fixed.
2025-12-10 11:43:39 +09:00
KAWASHIMA Takahiro
17b13e9e3f [flang][docs] Correct the title in Unsigned.md (#171553)
Probablly the original author copied `Extensions.md` and forgot to
change the title.
2025-12-10 11:42:32 +09:00
Tarun Prabhu
2d4d7e369c [flang][docs] Tweak in-progress warning in the release notes page
Reformat the in-progress warning message in the release notes page. This
is now rendered in a style similar to that of clang. The warning will
be hidden on release builds of the documentation.
2025-12-04 09:37:13 -07:00
Valery Dmitriev
4b2714f12f [flang/flang-rt] Implement show_descriptor intrinsic, a non-standard extension. (#170389)
This is a reapply the original patch (#169137) with the flang-rt unit
test changes limiting it to linux platform only.
Additionally accommodated style changes from Peter Klausler (#170227)
    
show_descriptor intrinsic prints details of a descriptor (extended
Fortran pointer).
It accepts a descriptor for any type and rank, including scalars.
Requires use of flang_debug module.
    
Example:
```
    program test
      use flang_debug
      implicit none
      integer :: a(4) = (/ 1,3,5,7 /)
      call show_descriptor(a(1:3))
    end program test
```    
and its output:
```
    Descriptor @ 0x7ffe01ec6a98:
      base_addr 0x563b7035103c
      elem_len  4
      version   20240719
      rank      1
      type      9 "INTEGER(kind=4)"
      attribute 0
      extra     0
        addendum  0
        alloc_idx 0
```
2025-12-04 08:29:31 -08:00
Tarun Prabhu
836935197b [flang][docs] Fix title and text in the release notes page
The title of the release notes page always showed "|version|
(In-Progress)". This has been fixed so the release version is shown as
expected. '(In-Progress)' is now only shown on non-release branches.
Unlike clang, flang does not use ${LLVM_VERSION_SUFFIX}, so even on
non-release branches the 'git' suffix will not be shown.
2025-12-03 10:08:33 -07:00
Tom Eccles
5ccf8c90d1 [flang] implement VECTOR VECTORLENGTH directive (#170114)
This should match exactly the llvm attributes generated by classic
flang.
2025-12-03 09:36:22 +00:00
Michael Kruse
5681c71a80 Revert "[flang] implement show_descriptor intrinsic, a non-standard extension (#169137)"
This reverts commit e7748e92cd.

It broke the Windows build

https://github.com/llvm/llvm-project/actions/runs/19842117405/job/56852610863
https://lab.llvm.org/buildbot/#/builders/166/builds/4535

After #170142 fixed another issue, this was also the remaining reason
for this buildbot to fail:

https://lab.llvm.org/buildbot/#/builders/207/builds/10423
2025-12-02 17:48:28 +01:00
Jean-Didier PAILLEUX
b17e644eed [flang/flang-rt] Adding support of RAND, IRAND and SRAND intrinsics (#166780)
This PR adds support of
[RAND](https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gfortran/RAND.html),
[IRAND](https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gfortran/IRAND.html)
and
[SRAND](https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gfortran/SRAND.html)
intrinsics in Flang, which are part of the GNU extension.
These intrinsics are used in the following benchmark:
[floatingspeed](https://github.com/ahbarnett/floatingspeed/)
2025-12-02 10:19:11 +01:00
Valery Dmitriev
e7748e92cd [flang] implement show_descriptor intrinsic, a non-standard extension (#169137)
show_descriptor intrinsic prints details of a descriptor (extended
Fortran pointer).
It accepts a descriptor for any type and rank, including scalars.
Requires use of flang_debug module.

Example:
program test
  use flang_debug
  implicit none
  integer :: a(4) = (/ 1,3,5,7 /)
  call show_descriptor(a(1:3))
end program test

and its output:
Descriptor @ 0x7ffe01ec6a98:
  base_addr 0x563b7035103c
  elem_len  4
  version   20240719
  rank      1
  type      9 "INTEGER(kind=4)"
  attribute 0
  extra     0
    addendum  0
    alloc_idx 0
  dim[0] lower_bound 1
         extent      3
         sm          4
2025-12-01 13:53:13 -08:00
Miguel Saldivar
8bfca268ba [flang] Support FLUSH as an intrinsic subroutine (#165942)
Previously `FLUSH` was only recognized in statement form (e.g.
`flush(unit)`); a
subroutine invocation `call flush(unit)` was treated as a generic user
call with
no special semantics. This change teaches lowering/semantics to handle
`CALL FLUSH` equivalently.

Fixes #119418
2025-11-28 09:40:27 +00:00
Jack Styles
e5d229dc61 [Flang][OpenMP] Update OpenMPSupport docs (#169833)
After the merging of #152736, there are a number of OpenMP Features that
are now fully supported. Missing from the initial patch was changing the
status of this from `P` to `Y` to indicate they are now fully supported.
The notes around not supporting `dist_schedule` were removed in the
initial patch.
2025-11-28 08:46:25 +00:00
Jack Styles
47ae3eaa29 [MLIR][OpenMP] Add MLIR Lowering Support for dist_schedule (#152736)
`dist_schedule` was previously supported in Flang/Clang but was not
implemented in MLIR, instead a user would get a "not yet implemented"
error. This patch adds support for the `dist_schedule` clause to be
lowered to LLVM IR when used in an `omp.distribute` or `omp.wsloop`
section.

There has needed to be some rework required to ensure that MLIR/LLVM
emits the correct Schedule Type for the clause, as it uses a different
schedule type to other OpenMP directives/clauses in the runtime library.

This patch also ensures that when using dist_schedule or a chunked
schedule clause, the correct llvm loop parallel accesses details are
added.
2025-11-27 14:16:44 +00:00
Peter Klausler
a55e30b12c [flang][runtime] Control stream truncation via runtime environment (#168415)
The ISO Fortran standards don't say whether a WRITE to a formatted
stream unit should truncate the unit if there has been any repositioning
(via POS= control list specifiers) to an earlier point in the stream.
But units with sequential records do truncate on writes after BACKSPACE
and REWIND statements, and many compilers (including this one) truncate
stream units too. Since some compilers don't truncate streams, this
patch adds an environment variable FORT_TRUNCATE_STREAM that can be set
to 0 to disable truncation and ease porting to flang-new of codes that
depend on that behavior.

Fixes https://github.com/llvm/llvm-project/issues/167569.
2025-11-19 08:54:43 -08:00
Eugene Epshteyn
4f8943dfc1 [flang] Disallow passing array actual arguments to ignore_tkr(r) scalars with VALUE attribute (#166682)
Scalars with VALUE attribute are likely passed in registers, so it's now
clear what lowering should do with the array actual argument in this
case. Fail this case with an error before getting to lowering.
2025-11-12 06:04:09 -05:00
Naveen Seth Hanig
f63d33da0a Reland "[clang] Refactor option-related code from clangDriver into new clangOptions library" (#167374)
This relands #167348.

The original PR was reverted due to a reported build failure, which was
later diagnosed as a local issue in the developer’s checkout or build
state. See discussion here:
https://github.com/llvm/llvm-project/pull/163659#discussion_r2511546964

No additional changes have been made in this reland.
2025-11-10 21:24:39 +01:00
Naveen Seth Hanig
6bad2d139b Revert "[clang] Refactor option-related code from clangDriver into new clangOptions library" (#167348)
Reverts #163659 due to missing one reference clang/Driver/Options.h in 
clang/include/clang/Driver/Driver.h.

See https://github.com/llvm/llvm-project/pull/163659#issuecomment-3512979187
2025-11-10 18:27:20 +01:00
Naveen Seth Hanig
9a783b63e6 [clang] Refactor option-related code from clangDriver into new clangOptions library (#163659)
This change moves option-related code from clangDriver into a new
clangOptions library.

This refactoring is part of a broader effort to support driver-managed
builds for compilations using C++ named modules and/or Clang modules.
It is required for linking the dependency scanning tooling against the
driver without introducing cyclic dependencies, which would otherwise
cause build failures when dynamic linking is enabled.
In particular, clangFrontend must no longer depend on clangDriver
for this to be possible.

This PR is motivated by the following review comment:
https://github.com/llvm/llvm-project/pull/152770#discussion_r2430756918
2025-11-10 17:19:03 +01:00
Thirumalai Shaktivel
cf1f871023 [Flang] Add parser support for prefetch directive (#139702)
Implementation details:
* Recognize prefetch directive in the parser as `!dir$ prefetch ...`
* Unparse the prefetch directive
* Add required tests

Details on the prefetch directive:
`!dir$ prefetch designator[, designator]...`, where the designator list
can be a variable or an array reference. This directive is used to
insert a hint to the code generator to prefetch instructions for
memory references.
2025-11-10 09:44:22 +05:30
Peter Klausler
2abcb19af2 [flang] Don't allow function calls to PROCEDURE() (#165786)
PROCEDURE() declares a procedure with no interface or result type. (When
used to declare a derived type component, it must also be a NOPASS
POINTER.) Document that we allow such procedures to be called as
subroutines with implicit interfaces, despite the ISO standard -- this
is a universal extension to the language.

However, no longer allow such procedure entities to be referenced as
implicitly-typed functions -- this usage is neither portable nor
well-defined, as the compilers that do allow it do not respect the
implicit typing rules established at the point of declaration.
2025-10-31 10:27:30 -07:00
Eugene Epshteyn
edab7212c5 [flang] Implement IGNORE_TKR(P) (#165469)
Implemented IGNORE_TKR(P), which allows ignoring pointer and allocatable
matching (can pass an allocatable array to routine with pointer array
argument and vice versa). Updated documentation.
2025-10-29 08:34:51 -04:00
Jean-Didier PAILLEUX
c1779f33bd [flang] Implement !DIR$ [NO]INLINE and FORCEINLINE directives (#134350)
This patch adds the support of these two directives : `!dir$ inline` and
`!dir$ noinline`.
- `!dir$ noinline` tells to the compiler to not perform inlining on
specific function calls by adding the `noinline` metadata on the call.
- `!dir$ inline` tells to the compiler to attempt inlining on specific
function calls by adding the `inlinehint` metadata on the call.
- `!dir$ forceinline` tells to the compiler to always perfom inlining on
specific function calls by adding the `alwaysinline` metadata on the
call.

Currently, these directives can be placed before a `DO LOOP`, call
functions or assignments. Maybe other statements can be added in the
future if needed.

For the `inline` directive the correct name might be `forceinline` but
I'm not sure ?
2025-10-28 08:02:15 +01:00
Tarun Prabhu
e866c44b49 [flang][docs] Replace references to f18 with flang (Part 2)
IntrinsicTypes.md has not been edited because, at the time that this PR was posted, there was another open PR updating that file. The replacement of f18 with flang will either be performed as part of that PR, or in a later commit.
2025-10-27 09:12:08 -06:00
Tarun Prabhu
0c7617d818 [flang][docs] Replace references to f18 in the docs with flang (Part 1)
In addition to the replacement, some light editing of the text was also
carried out. These edits primarily address issues of grammar and
style.

The remaining references to "f18" will be replaced in a later commit.
2025-10-22 07:50:08 -06:00
Cameron McInally
925b10656b [Flang][Tests] Remove GPL notice to GFortran test suite documentation. (#162332)
Originally #161912, we've now decided that an explicit GPL notification
is redundant with the LICENSE file, which is a common convention for
relaying this information.

Co-authored-by: Cameron McInally <cmcinally@nvidia.com>
2025-10-21 13:47:21 -04:00
Tarun Prabhu
794f3dfd75 [flang][docs] Update flang call details
The technical call has been cancelled, so that text has been removed.
The description of the "general" call has been updated to indicate that
it is intended for both technical and general discussions.
2025-10-13 15:56:05 -06:00
Peter Klausler
e2ee91ed34 [flang] Clean up some optional<bool> usage (#161925)
Audit the use of std::optional<bool> as a tri-state logical value in
flang, correct a couple cases that need ".value_or()", add some explicit
".has_value()" calls, and document the possible pitfalls.
2025-10-10 10:09:02 -07:00
Cameron McInally
23e35bd43c [Flang][Tests] Add GPL notice to GFortran test suite documentation. (#161912)
Add a GPL notice to the GFortran test suite documentation and redirect
to the LICENSE file distributed with the test suite.

Co-authored-by: Cameron McInally <cmcinally@nvidia.com>
2025-10-06 10:59:17 -04:00
Shunsuke Watanabe
fd4e77cf33 [flang][driver] Accelerate complex division when -ffast-math is specified (#159689)
This patch accelerates complex division by passing
`-complex-range=basic` to the frontend when the `-ffast-math` option is
specified. This behavior is the same as `-fcomplex-arithmetic=basic`. A
warning is issued if a different value is specified for
`-fcomplex-arithmetic=`. The warning conditions will be unified with
clang.
2025-10-01 13:03:23 +09:00
Peter Klausler
673e3051b0 [flang][runtime] Let more list-directed child input advance (#160590)
Whether list-directed child READ statements should be allowed to advance
to further records is neither explicit in the standard nor consistent in
existing Fortran implementations. We allow child namelist READ
statements to advance, but not other list- directed child input.

This patch refines our interpretation of this case. Child namelist READ
statements continue to be able to advance; in addition, non-namelist
child READ statements can now advance if their parent READ statement is
a list-directed input statement at the top level, or a child that could.
But non-namelist list-directed child input taking place in a context
with explicit format control won't advance to following records, so that
the format-controlled parent READ statement can retain control over
record advancement.

Also corrects two cases of record repositioning in numeric input
editing, which were failing under child input because they weren't
allowing for left tab limits.

Fixes https://github.com/llvm/llvm-project/issues/160351.
2025-09-30 10:35:06 -07:00
Peter Klausler
2780c209e1 [flang] Emit error on impossible-to-implement construct (#160384)
An assignment to a whole polymorphic allocatable changes its dynamic
type to the type of the right-hand side expression. But when the
assignment is under control of a WHERE statement, or a FORALL / DO
CONCURRENT with a mask expression, there is no interpretation of the
assignment, as the type of a variable must be the same for all of its
elements.

There is no restriction in the standard against this usage, and no other
Fortran compiler complains about it. But it is not possible to implement
it in general, and the behavior produced by other compilers is not
reasonable, much less worthy of emulating. It's best to simply disallow
it with an error message.

Fixes https://github.com/llvm/llvm-project/issues/133669, or more
accurately, resolves it.
2025-09-30 10:34:41 -07:00
Peter Klausler
977e75c98d [flang] More graceful parse failures at EOF (#159834)
Rather than admit complete confusion with a "FAIL" message when parsing
runs into the end of the source file unexpectedly, deal better with
missing or garbled END statements through the use of `consumedAllInput`
in end-of-line and end-of-statement parsers and error recovery. Adds a
new test (the original motivation) and updates the expected results in
two extant tests that were failing before.
2025-09-23 15:44:40 -07:00
Peter Klausler
80fa3bddd0 [flang] Implement FNUM() (#159433)
The GNU Fortran library function FNUM(u) returns the UNIX file
descriptor that corresponds to an open Fortran unit number, if any;
otherwise -1.

This implementation is a library extension only, not an intrinsic.
2025-09-19 08:09:39 -07:00
Dan Bonachea
652325866a [flang] Update docs link to latest PRIF Specification (#159233)
The PRIF Committee is pleased to announce the publication of the
Parallel
Runtime Interface for Fortran (PRIF) Specification, Revision 0.6. The
latest
iteration of this specification represents the efforts of a
collaborative
design process involving multiple individuals across several
institutions.

The document is available here: <https://doi.org/10.25344/S4M01X>

The PRIF specification is now governed by a formal PRIF Committee.
For more details, see: <https://go.lbl.gov/prif-governance>

The Committee vote to approve the technical content in this revision
began on 2025-08-22 and concluded on 2025-09-07 with unanimous approval.

The 7-day Committee comment period for cosmetic feedback began on
2025-09-08 and concluded on 2025-09-15 with no comments.

See the Change Log in Section 1 of the document for the list of changes
relative to the prior revision.
2025-09-18 09:57:32 -07:00
Peter Klausler
bf684e0f2f [flang][runtime] Disable namelist storage sequence input when defined (#158708)
The runtime supports a near-universal extension to namelist input that
allows reading a sequence of values into a storage sequence beginning at
an array element, e.g. &NML A(2)=1. 2. 3. / .

Disable this extension when the type of the array has a defined
formatted READ subroutine defined. That defined input procedure may
itself not be using list-directed input, and might not notice a
following slash or new input item name as such.

Fixes https://github.com/llvm/llvm-project/issues/158496.
2025-09-17 09:14:32 -07:00
Madhur Amilkanthwar
a134b06217 Reapply "Introduce -fexperimental-loop-fusion to clang and flang (#158844)
This PR is a reapplication of
https://github.com/llvm/llvm-project/pull/142686
2025-09-16 16:43:37 +05:30
Vitaly Buka
cedceeb800 Revert "Introduce -fexperimental-loop-fuse to clang and flang (#142686)" (#158764)
This reverts commit 895cda70a9.
And fix attempt: 06f671e57a.

Performance regressions and broken sanitizers, see #142686.
2025-09-16 02:30:18 +00:00
Sebastian Pop
895cda70a9 Introduce -fexperimental-loop-fuse to clang and flang (#142686)
This patch adds the flag -fexperimental-loop-fuse to the clang and flang
drivers. This is primarily useful for experiments as we envision to
enable the pass one day.

The options are based on the same principles and reason on which we have
`floop-interchange`.

---------

Co-authored-by: Madhur Amilkanthwar <madhura@nvidia.com>
2025-09-15 18:48:32 +05:30
Šárka Holendová
3e254ed904 [flang] Implement DSECNDS intrinsic (PGI extension) (#157573)
Add support for DSECNDS, the double-precision variant of SECNDS. 
The implementation mirrors SECNDS, reusing the shared `SecndsImpl<T>`
runtime template.
Includes:
- Registration in intrinsics table
- Lowering handler and runtime call wiring
- Hook into shared SecndsImpl in extensions.cpp
- Documentation in Intrinsics.md
- Regression test dsecnds.f90

CC @eugeneepshteyn @klausler

---------

Co-authored-by: Eugene Epshteyn <eepshteyn@nvidia.com>
2025-09-14 12:30:31 -04:00
Aiden Grossman
3e17864e76 [Flang] Make all tests work with lit's internal shell
This patch removes REQUIRES: shell lines and updates the tests to not
need a shell, or adds REQUIRES lines for Linux where relevant. A lot of
these seem to have gotten introduced in
58c3f20bbf, but many are no longer
relevant as these tests no longer use shell scripts.

There was one test (missing_newline.f90) that needed to be modified to
work. Lit doesn't recognize -ne correctly for echo and the options need
to be split into separate flags.

Reviewers: clementval, Meinersbur, kiranchandramohan, klausler

Reviewed By: clementval

Pull Request: https://github.com/llvm/llvm-project/pull/156115
2025-08-29 15:58:03 -07:00
Peter Klausler
9005ae5d89 [flang][runtime] Handle null list-directed fields in child input (#155707)
List-directed input statements maintain two flags ("eatComma_" and
"hitSlash_") in their state that allow GetNextDataEdit() to detect and
handle field separators (usually ',') and slashes in the input stream.
For list-directed input in a defined input subroutine, it's necessary to
copy those flags from the parent list-directed input statement (if any)
and update them afterwards.

Fixes https://github.com/llvm/llvm-project/issues/154791.
2025-08-29 07:49:54 -07:00
Rageking8
988ab5aca0 [flang][docs][NFC] Remove stray backtick (#154974)
Remove stray backtick introduced in commit
10cd0e7a8b.
2025-08-28 11:42:20 +01:00
Šárka Holendová
86bca2963f [flang] Register and lower SECNDS (stubbed implementation) (#151878)
This patch registers and lowers the GNU extension intrinsic `SECNDS` in
Flang.

- Registration and lowering are wired through the intrinsic
infrastructure.
- genSecnds() currently emits a TODO fatal error, marking it as
unimplemented.
- Includes an XFAIL test to exercise the lowering path and reflect
current status.

Fixes https://github.com/llvm/llvm-project/issues/58728

---

CC @eugeneepshteyn @klausler

---------

Co-authored-by: Eugene Epshteyn <eepshteyn@nvidia.com>
2025-08-25 22:31:48 -04:00
Yanzuo Liu
3b27d50cc7 [LLVM][utils] Add script which clears release notes (#153593)
The script copies `ReleaseNotesTemplate.txt` to corresponding
`ReleaseNotes.rst`/`.md` to clear release notes.

The suffix of `ReleaseNotesTemplate.txt` must be `.txt`. If it is
`.rst`/`.md`, it will be treated as a documentation source file when
building documentation.
2025-08-15 19:00:08 +08:00
Peter Klausler
7a13a756d6 [flang][NFC] Document ALLOCATE/DEALLOCATE error semantics (#153027)
This compiler stops an ALLOCATE/DEALLOCATE statement with multiple
variables after encountering a recoverable error to avoid the risk of
ambiguity in the case of multiple errors. Document.
2025-08-13 14:36:51 -07:00
Peter Klausler
effa35d240 [flang][runtime] Don't always accept a bare exponent letter (#151597)
For more accurate compatibility with other compilers' extensions, accept
a bare exponent letter as valid real input to a formatted READ statement
only in a fixed-width input field. So it works with (G1.0) editing, but
not (G)/(D)/(E)/(F) or list-directed input.

Fixes https://github.com/llvm/llvm-project/issues/151465.
2025-08-05 13:39:33 -07:00
Connector Switch
b00d4f2350 [flang][doc] Update some F2023 status. (#151165)
- Trig functions: done with various earlier commits like #149343.
- c_f_pointer: #149870.
2025-07-31 08:09:12 +08:00