[all-commits] [llvm/llvm-project] 3db2c5: [OpenMP][OMPIRBuilder] Collect users of a value be...
Kareem Ergawy via All-commits
all-commits at lists.llvm.org
Thu May 8 04:31:24 PDT 2025
Branch: refs/heads/users/ergawy/handle_users_with_repeated_args
Home: https://github.com/llvm/llvm-project
Commit: 3db2c56779f76838def2b8a5475d77233a004cc5
https://github.com/llvm/llvm-project/commit/3db2c56779f76838def2b8a5475d77233a004cc5
Author: ergawy <kareem.ergawy at amd.com>
Date: 2025-05-08 (Thu, 08 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
This PR fixes a crash that curently happens given the following input:
```fortran
subroutine caller()
real :: x, y, z
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. ....
n. 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.
n+1. 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.
n+2. 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.
n+3. The next m-1 iterations will still iterate over the same
instruction dropping the last m-1 actual users of the value.
Hence, we call 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