[flang-commits] [flang] [llvm] [mlir] [MLIR][OpenMP] Emit nullary check for mapped pointer members and appropriate size select based on results (PR #124604)

Kareem Ergawy via flang-commits flang-commits at lists.llvm.org
Tue Jan 28 03:57:00 PST 2025


================
@@ -0,0 +1,22 @@
+// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s
+
+// This test checks that we generate a select statement in cases where we're
+// mapping a pointer, to select a size of 0 when the pointer is null and
+// select the size of the mapped type when it is not null. Preventing a runtime
+// mapping error in cases where we legally map null data to device.
+
+module attributes {omp.is_target_device = false, omp.target_triples = ["amdgcn-amd-amdhsa"]} {
+  llvm.func @test_select_gen(%arg0: !llvm.ptr, %arg1: !llvm.ptr) {
+    %0 = omp.map.info var_ptr(%arg0 : !llvm.ptr, i32) var_ptr_ptr(%arg1 : !llvm.ptr) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr
+    %1 = omp.map.info var_ptr(%arg0 : !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)>) map_clauses(to) capture(ByRef) members(%0 : [0] : !llvm.ptr) -> !llvm.ptr
----------------
ergawy wrote:

Just a sanity check, should that be `var_ptr(%arg1 : ....)`? We are mapping `%arg0` twice with 2 different types. I think this does not matter for the test. Just to verify my understanding.

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


More information about the flang-commits mailing list