[all-commits] [llvm/llvm-project] a8d8af: [OpenMP][OMPIRBuilder] Collect users of a value be...
Kareem Ergawy via All-commits
all-commits at lists.llvm.org
Wed May 28 08:40:55 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: a8d8af3bfa13bf3173e24097ee4017cf7648c5a6
https://github.com/llvm/llvm-project/commit/a8d8af3bfa13bf3173e24097ee4017cf7648c5a6
Author: Kareem Ergawy <kareem.ergawy at amd.com>
Date: 2025-05-28 (Wed, 28 May 2025)
Changed paths:
M llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
A mlir/test/Target/LLVMIR/omp-target-call-with-repeated-parameter.mlir
Log Message:
-----------
[OpenMP][OMPIRBuilder] Collect users of a value before replacing them in target outlined function (#139064)
This PR fixes a crash that curently happens given the following input:
```fortran
subroutine caller()
real :: x
integer :: i
!$omp target
x = i
call callee(x,x)
!$omp end target
endsubroutine caller
subroutine callee(x1,x2)
real :: x1, x2
endsubroutine callee
```
The crash happens because the following sequence of events is taken by
the `OMPIRBuilder`:
1. ....
2. An outlined function for the target region is created. At first the
outlined function still refers to the SSA values from the original
function of the target region.
3. The builder then iterates over the users of SSA values used in the
target region to replace them with the corresponding function arguments
of outlined function.
4. If the same instruction references the SSA value more than once (say
m), all uses of that SSA value are replaced in the instruction. Deleting
all m uses of the value.
5. The next m-1 iterations will still iterate over the same instruction
dropping the last m-1 actual users of the value.
Hence, we collect all users first before modifying them.
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