[clang] [llvm] [mlir] [OMPIRBuilder] always leave PARALLEL via the same barrier (PR #164586)

Tom Eccles via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 22 02:30:48 PDT 2025


tblah wrote:

PR stack:

- https://github.com/llvm/llvm-project/pull/164586
- https://github.com/llvm/llvm-project/pull/164587

This is all to fix the following code example provided by Themos Tsikas at AMD. (run with OMP_CANCELLATION=true in the environment)
```
Program cancel_bug
  Use OMP_LIB, Only: omp_get_thread_num
  Logical :: flag(0:11)

  flag = .FALSE.
  flag(11) = .TRUE.
  ! If no cancellation happens, we expect all flags to become true

  !$OMP PARALLEL NUM_THREADS(12)

  ! one thread activates cancellation
  !$OMP CANCEL PARALLEL IF(omp_get_thread_num()==11)

  print '(I4,1X,12L1)',omp_get_thread_num(), flag

  ! this one should act as cancellation point, even though expression evaluates to false and does not activate cancellation.
  !$OMP CANCEL PARALLEL IF(.FALSE.)

  flag(omp_get_thread_num()) = .TRUE.
  !$OMP END PARALLEL

  ! If all flags are true, second cancellation point was ignored, bug
  print '(12L1)', flag
End Program cancel_bug
```

https://github.com/llvm/llvm-project/pull/164586


More information about the llvm-commits mailing list