[Mlir-commits] [llvm] [mlir] [OpenMP][OMPIRBuilder] Collect users of a value before replacing them in target outlined function (PR #139064)
Sergio Afonso
llvmlistbot at llvm.org
Thu May 8 04:25:20 PDT 2025
================
@@ -0,0 +1,37 @@
+// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s
+
+llvm.func @caller_() {
+ %c1 = llvm.mlir.constant(1 : i64) : i64
+ %x_host = llvm.alloca %c1 x f32 {bindc_name = "x"} : (i64) -> !llvm.ptr
+ %i_host = llvm.alloca %c1 x i32 {bindc_name = "i"} : (i64) -> !llvm.ptr
+ %x_map = omp.map.info var_ptr(%x_host : !llvm.ptr, f32) map_clauses(implicit, exit_release_or_enter_alloc) capture(ByCopy) -> !llvm.ptr {name = "x"}
+ %i_map = omp.map.info var_ptr(%i_host : !llvm.ptr, i32) map_clauses(implicit, exit_release_or_enter_alloc) capture(ByCopy) -> !llvm.ptr {name = "i"}
+ omp.target map_entries(%x_map -> %x_arg, %i_map -> %i_arg : !llvm.ptr, !llvm.ptr) {
+ %1 = llvm.load %i_arg : !llvm.ptr -> i32
+ %2 = llvm.sitofp %1 : i32 to f32
+ llvm.store %2, %x_arg : f32, !llvm.ptr
+ // The call instruction uses %x_arg more than once. Hence modifying users
+ // while iterating them invalidates the iteration. Which is what is tested
+ // by here.
----------------
skatrak wrote:
```suggestion
// by this.
```
https://github.com/llvm/llvm-project/pull/139064
More information about the Mlir-commits
mailing list