[flang-commits] [flang] [llvm] [flang] __fortran_builtins: Update __builtin_team_type to meet PRIF specification (PR #202450)
Dan Bonachea via flang-commits
flang-commits at lists.llvm.org
Thu Jun 11 07:51:26 PDT 2026
https://github.com/bonachea updated https://github.com/llvm/llvm-project/pull/202450
>From 638b3a0e6add013d96d728c011a4ca7c4544cf92 Mon Sep 17 00:00:00 2001
From: Dan Bonachea <dobonachea at lbl.gov>
Date: Thu, 4 Jun 2026 12:02:23 -0700
Subject: [PATCH 1/2] __fortran_builtins: Update __builtin_team_type to meet
PRIF specification
The representation of `TEAM_TYPE` in the `ISO_FORTRAN_ENV` module is opaque to
the compiler, but the size (and alignment) needs to match the PRIF
specification for `prif_team_type` to ensure ABI compatibility with the
multi-image runtime library.
Flang's old definition as a derived type containing only an
`integer(int64)` component was leading to an 8-byte `TEAM_TYPE`.
However PRIF specifies the `prif_team_type` component as a `pointer` to an
opaque scalar type, which flang compiles to a 40-byte representation.
This mismatch was leading to incorrect behavior at runtime for programs
compiled with `-fcoarray` and using `TEAM_TYPE`, where `TEAM_TYPE` values
returned by PRIF were being silently truncated by the compiler.
Change the declaration of `__builtin_team_type` to match the PRIF
specification, thus ensuring the representation of `TEAM_TYPE` has the required
size.
---
flang-rt/lib/runtime/__fortran_builtins.f90 | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/flang-rt/lib/runtime/__fortran_builtins.f90 b/flang-rt/lib/runtime/__fortran_builtins.f90
index 4f9874a9bef29..840ad33eb2674 100644
--- a/flang-rt/lib/runtime/__fortran_builtins.f90
+++ b/flang-rt/lib/runtime/__fortran_builtins.f90
@@ -99,8 +99,13 @@
__builtin_ieee_other = &
__builtin_ieee_round_type(_FORTRAN_RUNTIME_IEEE_OTHER)
+ type, private :: __builtin_dummy_team_descriptor_type
+ ! this type is a placeholder for the opaque PRIF type
+ integer(kind=int64), private :: __placeholder = -1
+ end type
+
type, public :: __builtin_team_type
- integer(kind=int64), private :: __id = -1
+ type(__builtin_dummy_team_descriptor_type), pointer, private :: info => null()
end type
integer, parameter, public :: __builtin_atomic_int_kind = selected_int_kind(18)
>From 0762fbedb5eba95388b42c95facc014086260887 Mon Sep 17 00:00:00 2001
From: Dan Bonachea <dobonachea at lbl.gov>
Date: Mon, 8 Jun 2026 19:31:50 -0700
Subject: [PATCH 2/2] Dummy commit for CI
This spurious blankspace change is a workaround for a dependency analysis
problem in CI.
---
flang/CMakeLists.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 6d03080d71029..bb74465411ad6 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -590,3 +590,4 @@ install(
COMPONENT flang-fortran-binding)
add_llvm_install_targets(install-flang-fortran-binding
COMPONENT flang-fortran-binding)
+
More information about the flang-commits
mailing list