aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/FileCheck/FileCheck.cpp
diff options
context:
space:
mode:
authorSergio Afonso <safonsof@amd.com>2025-03-17 11:44:29 +0000
committerGitHub <noreply@github.com>2025-03-17 11:44:29 +0000
commit6085f3f6a80dc3be97d31a4c31a22fd77dbb6e83 (patch)
tree42900ee537143917e8b8cb0a941bbd935f747ebb /llvm/lib/FileCheck/FileCheck.cpp
parentf4feab927ba33e897c4f05bf3b52226bc0a824c7 (diff)
downloadllvm-6085f3f6a80dc3be97d31a4c31a22fd77dbb6e83.zip
llvm-6085f3f6a80dc3be97d31a4c31a22fd77dbb6e83.tar.gz
llvm-6085f3f6a80dc3be97d31a4c31a22fd77dbb6e83.tar.bz2
[OpenMP] Address __kmp_dist_for_static_init issue (#129902)
This patch attempts to provide a fix for an issue that appears when the `__kmp_dist_for_static_init` function is called from a serialized team. This is triggered by code generated by flang for `distribute parallel do` constructs whenever an `if` clause for the `parallel` leaf construct is present. This results in the introduction of a call to `__kmpc_fork_call_if` in place of `__kmpc_fork_call`. When it evaluates to `false`, it defers execution to `__kmp_serialized_parallel`, which creates a new serial team that is picked up by `__kmp_dist_for_static_init`, resulting in an incorrect `team` pointer that causes the `nteams == (kmp_uint32)team->t.t_parent->t.t_nproc` assertion to fail. The sequence of calls replicating this issue can be summarized as: - `__kmpc_fork_teams` - `__kmpc_fork_call_if` - `__kmpc_dist_for_static_init_*` Since I am not familiar with the implementation of the OpenMP runtime, it is possible that the above sequence of calls is incorrect, or that the bug can be better fixed in another way, so I am open to discussing this. The following Fortran program can be compiled with flang to show the issue: ```f90 ! Compile and run: flang -fopenmp test.f90 -o test && ./test ! Check LLVM IR: flang -fc1 -emit-llvm -fopenmp test.f90 -o - program main implicit none integer, parameter :: n = 10 integer :: i, idx(n) !$omp teams !$omp distribute parallel do if(.false.) do i=1,n idx(i) = i end do !$omp end teams print *, idx end program ```
Diffstat (limited to 'llvm/lib/FileCheck/FileCheck.cpp')
0 files changed, 0 insertions, 0 deletions