To: J3 J3/25-151r1 From: Mark LeAir Subject: Flang Liaison Report Date: 2025-June-23 #Reference: 25-122r1 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 10-February-2025 and 10-June-2025: - Added support for VOLATILE - Implemented IEEE_DENORM - Added array repacking options (-f[no-]repack-arrays) - Extension: allow override of inaccessible DEFERRED binding - Extension: allow char string edit descriptors in input formats - Introduced AArch64-specific processor defines - Added support for the __COUNTER__ preprocessor macro - Implemented several intrinsics and directives forms: + Intrinsics: IERRNO, CO_REDUCE, ERF, ERFC, ERFC_SCALED (with Q and D prefixes), PERROR (GNU extension) + Directives: !DIR$ UNROLL_AND_JAM [N], !DIR$ NOVECTOR, !DIR$ NOUNROLL[_AND_JAM] Improvements to existing features added between 10-February-2025 and 10-June-2025: - More optimizations: + cshift inlining to avoid array temporary when possible + using constant extents from both LHS and RHS when generating array assignment loops + use llvm noalias attribute when dummy arguments cannot be modified indirectly + finer grain analysis of side effects in assignments. + propagate contiguous attribute in the IR. - Faster compilation times for program with large initialized derived type arrays - Improved hermetic module option and documentation. - Support -D for function-like macros - Don't insert spaces in -E output after line continuation - Ignore empty keyword macros before directives - Pad Hollerith actual arguments - Updated BOZ handling in assignment RHS to match Fortran new 2023 requirements. - Relaxed F2023 C7108 to a portability warning since it is not enforced by other compilers and enforcing it breaks existing code - Stricter checking of v_list DIO arguments - Emit error when DEFERRED binding overrides non-DEFERRED - Emit error for whole assumed-size array as RHS - Require contiguous actual pointer for contiguous dummy pointer - Improve runtime SAME_TYPE_AS() - Allow host-associated INTENT(OUT) in specification expr with portability warning (no universal support for this) - Added support for IEEE_SCALB and SCALE - kind=2, kind=3 - Update IEEE_SUPPORT_FLAG implementation to handle X array arguments - Handle IEEE_SUPPORT_FLAG(..., LOCAL) in specification expression - Update IEEE_SUPPORT_STANDARD on ARM to not always fold because halting may depend on actual processor architecture - Implement FSEEK, FTELL, UNLINK, TIME, HOSTNM, PUTENV, and QSORT lib3f extensions - More coarray semantic checks: complete semantic checks for FORM TEAM, CHANGE TEAM, EVENT_TYPE/LOCK_TYPE, MOVE_ALLOC, COSHAPE, F2023 C15104, C1027, C955, C917, and C918 - Added support of pointer assignments inside FORALL - Enforce F'2023 constraints C1503 about ABSTRACT INTERFACE - Support indirect calls with ABIs requiring LLVM argument attribute (like sret) - Add support for -mprefer-vector-width= - Warn when a volatile target is pointer associated with a non-volatile pointer - Change c_intmax_t to 64 bit to correspond to intmax_t in C Improvements to existing OpenMP features added between 10-February-2025 and 10-June-2025: - Improved support and fixes for constructs: atomic, cancel, cancellation point, declare mapper, declare reduction, declare simd, declare variant, metadirective, scan, target, task, taskgroup, taskloop, teams, threadprivate, interop, assume, assumes - Improved support and fixes for clauses: allocate, close, copyprivate, defaultmap, depend, grainsize, in_reduction, linear, num_tasks, ompx_hold, present, privatization, reduction, task_reduction, indirect - Added support for mapping DO CONCURRENT constructs to OpenMP. Debug Improvements added between 10-February-2025 and 10-June-2025: - General bug fixes and enhancements to improve debug reliability and metadata generation. Improvements to the Driver added between 10-February-2025 and 10-June-2025: - Added support for a range of flags to improve compatibility and feature control: -finstrument-functions, -f[no-]vectorize, -f[no-]slp-vectorize, -fd-lines-as-comments, -fd-lines-as-code, -m64, -f[no-]verbose-asm, -mmacos-version-min=, -fveclib - Aligned -x language mode behavior with gfortran for better consistency. Improvements to Codegen added between 10-February-2025 and 10-June-2025: - Improved alias analysis for locally allocated objects. - Enhanced math intrinsic handling with direct code generation for non-precise calls to: acosh, asin, asinh, atanh, erfc Documentation Improvements added between 10-February-2025 and 10-June-2025: - Introduced Sphinx-based documentation: + Man page and HTML generation for Flang + OpenMP standards support documentation + Fortran standards compliance documentation Build System Enhancements added between 10-February-2025 and 10-June-2025: - Enabled use of precompiled headers across major components: Frontend, Lower, Parser, Semantics, Evaluate. - Enabled LLVM_ENABLE_RUNTIMES=flang-rt to build the runtime separately from the compiler - Experimental GPU build support added. - Introduced FLANG_PARALLEL_COMPILE_JOBS build option to control the number of flang files compiled in parallel - Added support for IR-level Profile-Guided Optimization (IR PGO). 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 and some OpenMP 5.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. Current ("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, inter-procedure 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. OpenPower support is not currently being maintained but it is still available. Since our last report, Classic Flang was ported to work with LLVM-20. Also, experimental support for RISCV is available now. Detailed status can be found in the biweekly call Google doc at: docs.google.com/document/d/1-OuiKx4d7O6eLEJDBDKSRnSiUO2rgRR-c2Ga4AkrzOI