To: J3 J3/26-175r1 From: Mark LeAir Subject: Flang Liaison Report Date: 2026-June-16 #Reference: 26-117r1 Flang Open Source Fortran Report ================================ Flang is an open-source compiler for Fortran. It is an official subproject of the LLVM Project (llvm.org). NVIDIA's portion of the work was partially sponsored by the US Department of Energy Exascale Computing Project (particularly, LLNL, Sandia and LANL). The current goals of the project are to - Create an open source Fortran compiler with LLVM licensing, - that can be used for language and parallelization experimentation, - that exists as a peer in the LLVM community of languages, like Clang, - that can rely on LLVM code generation and parallelism support for CPUs and GPUs. There is a Slack workspace for Flang and a number of conference calls related to Flang development. - Flang biweekly sync call ("umbrella call") - Flang biweekly technical call - "Classic Flang" biweekly call - OpenMP in Flang Technical Call Details can be found on the Getting Involved page http://flang.llvm.org/docs/GettingInvolved.html. The New LLVM Flang Compiler --------------------------- The LLVM Fortran compiler is available at https://github.com/llvm/llvm-project (the LLVM monorepo) in the flang/ directory. LLVM Flang is being developed under the Apache 2.0 license with LLVM exceptions (the same as LLVM, Clang, OpenMP, etc.). New features added between 11-February-2026 and 11-June-2026: (Updates provided by Jean Perier) + Treat REAL(2) and COMPLEX(2) as C-interoperable types, with c_float16 and c_float16_complex in ISO_C_BINDING + Extension: accept '!' as a value separator in NAMELIST input (e.g. name=value!comment) + Added -frelaxed-c-loc-checks to relax some semantic constraints on C_LOC (usable more like LOC) + Added extension to allow multiple program units on the same line (semicolon-separated) Improvements to existing features added between 11-February-2026 and 11-June-2026: (Updates provided by Jean Perier) - Preprocessor: + Recognize compiler directives after expansion in comment (re-landed after fixing continuation-line issues). + Handle semicolons uniformly in program unit constructs. - Semantic checks: + Break recursion on illegal recursive type in defined I/O checking. + Better error for ALLOCATED() applied to a pointer. + Catch recursive call to non-recursive ENTRY. + Catch empty nested parenthesized format item lists. + Warn about assumed-rank items in I/O lists and catch more invalid assumed-rank actual argument uses. + Ignore -fno-realloc-lhs for polymorphic allocatable LHS with a warning. + Downgrade misplaced IGNORE_TKR directive from error to warning. + Clean up -frelaxed-c-loc-checks warning flag handling. + Fail more gracefully when reading a corrupt module file. + Improve generic resolution and missing-expression error messages. + Fixed missing definitions for array named constants from iso_fortran_env (e.g. character_kinds) - IO + Fix EXECUTE_COMMAND_LINE() on Windows, status management, and CMDMSG output padding. + Catch EOSHIFT ARRAY/BOUNDARY type mismatch at runtime. + Catch asynchronous parent or child I/O misuse. + Conditionally fail empty ALLOCATE. + Emit "Infinity" rather than "Inf" when the output format requires it. + Don't mis-parse 1X or X edit descriptors when unparsing format strings. - Driver + -fdisable-real-10 now affects only user code, not the runtime library. Codegen: + Disable copy-out to INTENT(IN) actual arguments passed through to other calls. + Fix WHERE self-updates on allocatable array sections. + Avoid introducing iteration dependencies in WHERE and FORALL temporaries. + Improve array section analysis for WHERE. + DO WHILE loops are now lowered to scf.while by default. + Inline MAX/MINVAL according to -ffp-maxmin-behavior (integer reductions use native min/max ops). + Inline trivial scalar allocatable assignments without runtime calls. + Only instantiate required symbols from parent modules, reducing compile time for large projects. + Preserve logical constant representation through TRANSFER. + Fix IGNORE_TKR(C) passing a descriptor instead of a base address for non-descriptor dummies. + Lower AINT with math.round. + Canonicalize array coordinate operations for contiguous arrays and array sections. + Improved alias analysis (declaration scoping, OPTIONAL handling, volatile casts, derived component accesses). + Continued loop invariant code motion improvements (nested regions, generic allocations). + Preserve UseErrorDetails in module files for clearer USE-associated error messages. + Improved debug info at -g and O0 by keeping argument values visible to the debugger. + Fix source locations reported for WHERE constructs. + Apply vectorization cost model even when IVDEP is present. + Removed legacy non-HLFIR lowering; HLFIR is now the only lowering path. Improvements to OpenMP added between 11-February-2026 - 16-June-2026 (Updates provided by Krzysztof Parzyszek) Command-line options: - Changed spelling of -Wopen-mp-* and -Wopen-acc-* options to -Wopenmp and -Wopenacc-* respectively. Extensions to the OpenMP specification: - Allowed specifying thread-private variables in EQUIVALENCE statements. Loop-transforming construct support: - Created an MLIR representation of FUSE operation. - Added parsing and semantic checks for DEPTH. - Implemented semantic checks for INTERCHANGE construct and PERMUTATION clause. - Enabled composition of FUSE operations. New constructs: - Added support for SCOPE construct. - Implemented frontend support for BEGIN/END METADIRECTIVE. - Implemented frontend support for DECLARE_VARIANT. MLIR and LLVMIR code generation: - Added support for AFFINITY clause. - Added support for ALLOCATE directive. - Added support for iterator modifiers in DEPEND, MAP and motion clauses. - Implemented initial codegen for METADIRECTIVE (including BEGIN/END variant). - Created MLIR representation of GROUPPRIVATE and DYN_GROUPPRIVATE. Atomic construct: - Implemented ATOMIC COMPARE. - Added support for WEAK clause. - Added semantic checks for memory-order clauses on ATOMIC construct. - Added support for complex types in ATOMIC UPDATE CAPTURE. Declare reduction construct: - Added support for derived types. - Added support for DECLARE_REDUCTION without explicit initializer. - Fixed component-level initializer implementation. - Fixed accessibility check for DECLARE_REDUCTION symbols in modules. - Fixed name resolution for USE-associated DECLARE_REDUCTION symbols. Mapper support: - Fixed handling of default implicit mappers for pointer variables. - Added support for custom mappers on motion clauses in TARGET_UPDATE. - Implemented MLIR code generation for implicit mappers on DO CONCURRENT when offloading to a device. Map support: - Added initial implementation of REF_PTR/REF_PTEE modifiers. - Implemented MLIR code generation for ATTACH and map-type modifiers. - Improved MLIR code generation for motion modifier in MAP clause. - Fixed handling of map flags in MLIR. Device memory allocation: - Added support for device shared memory allocation in MLIR. - Implemented a pass to replace alloca operations with device shared memory allocations. Privatization: - Implemented using managed memory for device allocatable descriptors in CUDA. - Implemented using cuf.alloc for privatized device arrays in CUDA. - Added an option to allocate private automatic arrays on heap. - Fixed privatization of common blocks. - Added privatization of indirectly referenced symbols. - Fixed privatization of variables in EQUIVALENCE statements. Data-sharing attribute handling: - Improved semantic checks in the presence of DEFAULT(NONE). - Improved detection of conflicts between predetermined and explicit data-sharing attributes. - Implemented semantic checks of data-sharing attributed of assumed size arrays. - Fixed handling of data-sharing attributes on USE-renamed arrays. Improvements to handling of LINEAR clause: - Added semantic checks for uses of symbols from statement functions in LINEAR clause. - Fixed data race on LINEAR variables in PARALLEL DO SIMD. - Fixed diagnosis of uses of common blocks in LINEAR clause. - Fixed diagnosis of uses of subobjects in LINEAR clause. - Fixed MLIR code generation for LINEAR clause. - Implemented MLIR code generation for linear modifiers. Semantic checks for loop nests: - Implemented framework for analysis of loop-nest-associated OpenMP constructs. - Implemented semantic checks for loop-nest-associated constructs. - Improved diagnostic messages, added additional explanatory messages. General improvements to semantic checks: - Generalized checks of list items against clause-specific restrictions. Summary The current state of the LLVM Flang compiler: - written in modern C++ following LLVM conventions - over 200,000 lines of code, tests and scripts - parses all of Fortran 2018 to abstract syntax trees (AST) - parses OpenMP 4.5, some OpenMP 5.0, and some OpenMP 6.0. - parses OpenACC 3.0 - defines a "Fortran Intermediate Representation" (FIR) based on LLVM's MLIR - can analyze most OpenMP and OpenACC constructs - can compile and correctly run Fortran 77 programs (passes FCVS test suite), nearly all Fortran 95 programs, and many programs that use Fortran 2003+ modern features. - supports end-to-end compilation of all OpenMP 1.1 except for reduction, privatization, and one atomic construct. - for later versions of OpenMP, Flang has support for simd, task, taskgroup etc. Classic Flang Compiler ---------------------- The previous version of Flang, now known as Classic Flang, is derived from the PGI Fortran compiler, with some proprietary features removed (e.g., OpenACC support, Interprocedural Analysis). It is the basis for commercial Fortran compilers from AMD and Huawei. Previous commercial versions of the Arm Fortran compiler also used Classic Flang as its basis. Commercial Arm Fortran compilers are now based on LLVM Flang. Classic Flang is available for Linux on x86-64, OpenPOWER, and Arm processors. Also, experimental support for RISCV is available. OpenPower support is not currently being maintained but it is still available. More information is available at https://github.com/flang-compiler/flang.