[all-commits] [llvm/llvm-project] 24ce77: [Clang][OpenMP] Fix `if` clause not affecting `tea...
Jan André Reuter via All-commits
all-commits at lists.llvm.org
Fri Jul 10 01:42:52 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 24ce77ea005c1ef49d3552cbba74033d2662a0ad
https://github.com/llvm/llvm-project/commit/24ce77ea005c1ef49d3552cbba74033d2662a0ad
Author: Jan André Reuter <jan at zyten.de>
Date: 2026-07-10 (Fri, 10 Jul 2026)
Changed paths:
M clang/lib/CodeGen/CGStmtOpenMP.cpp
A clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_openmp52_codegen.cpp
A clang/test/OpenMP/teams_distribute_parallel_for_simd_if_openmp52_codegen.cpp
Log Message:
-----------
[Clang][OpenMP] Fix `if` clause not affecting `teams` construct on host (#207444)
In #205345, it was discovered that the `if` clause for the `teams`
construct
does not actually create a serial league when the code is built with
Clang.
Looking at the emitted IR, no call to `__kmpc_push_num_teams` was added
for an `if` clause. Hence, `__kmpc_fork_teams` always created the number
of
teams specified via the `num_teams` clause, or the _nteams-var_ ICV.
During `emitCommonOMPTeamsDirective`, only the `num_teams` and
`thread_limit`
clauses were checked, whereas the `if` clause was missing.
To fix the missing code, check for an `if` clause mapped to `teams` or
`unknown`. If the clause is present, and false, emit
`__kmpc_push_num_teams`
with the number of teams set to 1. The `thread_limit` clause is
unaffected.
Otherwise, stick to the existing implementation and only call
`__kmpc_push_num_teams` if `num_teams` or `thread_limit` are set.
This only applies for OpenMP v5.2 and newer. Earlier OpenMP versions did
not
support the `if` clause for the `teams` construct, hence should continue
to emit a number of teams based on attached `num_teams` and
`thread_limit`
clauses, or the _nteams-var_ ICV.
This fix also only affects host-side execution, as
`__kmpc_push_num_teams` is a
no-op for offloaded code. For offloaded code, the number of leagues is
set during
the call to `__tgt_target_kernel`, whose passed arguments are unchanged.
Closes #205345
---------
Signed-off-by: Jan André Reuter <j.reuter at fz-juelich.de>
Signed-off-by: Jan André Reuter <jan at zyten.de>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list