[Mlir-commits] [mlir] 5fa55b2 - Revert "[flang][OpenMP] Skip runtime mapping with no offload targets (#144534)" (#145478)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Jun 24 01:51:29 PDT 2025


Author: antoine moynault
Date: 2025-06-24T10:51:26+02:00
New Revision: 5fa55b2dfc2ca8ae04ad23ce0d702a24963f42af

URL: https://github.com/llvm/llvm-project/commit/5fa55b2dfc2ca8ae04ad23ce0d702a24963f42af
DIFF: https://github.com/llvm/llvm-project/commit/5fa55b2dfc2ca8ae04ad23ce0d702a24963f42af.diff

LOG: Revert "[flang][OpenMP] Skip runtime mapping with no offload targets (#144534)" (#145478)

And also revert 6ba1955 "[flang][OpenMP] Fix ignore-target-data.f90 test"

As it causes several bot failures
https://github.com/llvm/llvm-project/pull/144534#issuecomment-2995303224

Added: 
    

Modified: 
    mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
    mlir/test/Target/LLVMIR/omptarget-llvm.mlir
    mlir/test/Target/LLVMIR/omptargetdata-nowait-llvm.mlir
    mlir/test/Target/LLVMIR/openmp-data-target-device.mlir

Removed: 
    flang/test/Lower/OpenMP/ignore-target-data.f90


################################################################################
diff  --git a/flang/test/Lower/OpenMP/ignore-target-data.f90 b/flang/test/Lower/OpenMP/ignore-target-data.f90
deleted file mode 100644
index f1a150d5dfabc..0000000000000
--- a/flang/test/Lower/OpenMP/ignore-target-data.f90
+++ /dev/null
@@ -1,30 +0,0 @@
-!RUN: %flang_fc1 -emit-llvm -fopenmp %s -o - | FileCheck %s --check-prefix=NORT
-!RUN: %flang_fc1 -emit-llvm -fopenmp %s -o - | FileCheck %s --check-prefix=LLVM
-
-!Make sure that there are no calls to the mapper.
-!NORT-NOT: call{{.*}}__tgt_target_data_begin_mapper
-!NORT-NOT: call{{.*}}__tgt_target_data_end_mapper
-
-!Make sure we generate the body
-!LLVM: define internal void @_QFPf(ptr %[[A0:[0-9]+]], ptr %[[A1:[0-9]+]])
-!LLVM:   %[[V0:[0-9]+]] = load i32, ptr %[[A0]], align 4
-!LLVM:   %[[V1:[0-9]+]] = load i32, ptr %[[A1]], align 4
-!LLVM:   %[[V2:[0-9]+]] = add i32 %[[V0]], %[[V1]]
-!LLVM:   store i32 %[[V2]], ptr %[[A0]], align 4
-!LLVM:   ret void
-!LLVM: }
-
-
-program test
-
-call f(1, 2)
-
-contains
-
-subroutine f(x, y)
-  integer :: x, y
-  !$omp target data map(tofrom: x, y)
-  x = x + y
-  !$omp end target data
-end subroutine
-end

diff  --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index eece8573f00ec..90ce06a0345c0 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -4378,9 +4378,6 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
   llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
   llvm::OpenMPIRBuilder::TargetDataInfo info(/*RequiresDevicePointerInfo=*/true,
                                              /*SeparateBeginEndCalls=*/true);
-  bool isTargetDevice = ompBuilder->Config.isTargetDevice();
-  bool isOffloadEntry =
-      isTargetDevice || !ompBuilder->Config.TargetTriples.empty();
 
   LogicalResult result =
       llvm::TypeSwitch<Operation *, LogicalResult>(op)
@@ -4470,9 +4467,6 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
 
   if (failed(result))
     return failure();
-  // Pretend we have IF(false) if we're not doing offload.
-  if (!isOffloadEntry)
-    ifCond = builder.getFalse();
 
   using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
   MapInfoData mapData;

diff  --git a/mlir/test/Target/LLVMIR/omptarget-llvm.mlir b/mlir/test/Target/LLVMIR/omptarget-llvm.mlir
index e6ea3aaeec656..971bea2068544 100644
--- a/mlir/test/Target/LLVMIR/omptarget-llvm.mlir
+++ b/mlir/test/Target/LLVMIR/omptarget-llvm.mlir
@@ -1,17 +1,15 @@
 // RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s
 
-module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
-  llvm.func @_QPopenmp_target_data() {
-    %0 = llvm.mlir.constant(1 : i64) : i64
-    %1 = llvm.alloca %0 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFopenmp_target_dataEi"} : (i64) -> !llvm.ptr
-    %2 = omp.map.info var_ptr(%1 : !llvm.ptr, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
-    omp.target_data map_entries(%2 : !llvm.ptr) {
-      %3 = llvm.mlir.constant(99 : i32) : i32
-      llvm.store %3, %1 : i32, !llvm.ptr
-      omp.terminator
-    }
-    llvm.return
+llvm.func @_QPopenmp_target_data() {
+  %0 = llvm.mlir.constant(1 : i64) : i64
+  %1 = llvm.alloca %0 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFopenmp_target_dataEi"} : (i64) -> !llvm.ptr
+  %2 = omp.map.info var_ptr(%1 : !llvm.ptr, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
+  omp.target_data map_entries(%2 : !llvm.ptr) {
+    %3 = llvm.mlir.constant(99 : i32) : i32
+    llvm.store %3, %1 : i32, !llvm.ptr
+    omp.terminator
   }
+  llvm.return
 }
 
 // CHECK:         @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4]
@@ -40,25 +38,23 @@ module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
 
 // -----
 
-module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
-  llvm.func @_QPopenmp_target_data_region(%0 : !llvm.ptr) {
-    %1 = llvm.mlir.constant(1023 : index) : i64
-    %2 = llvm.mlir.constant(0 : index) : i64
-    %3 = llvm.mlir.constant(1024 : index) : i64
-    %4 = llvm.mlir.constant(1 : index) : i64
-    %5 = omp.map.bounds   lower_bound(%2 : i64) upper_bound(%1 : i64) extent(%3 : i64) stride(%4 : i64) start_idx(%4 : i64)
-    %6 = omp.map.info var_ptr(%0 : !llvm.ptr, !llvm.array<1024 x i32>)   map_clauses(from) capture(ByRef) bounds(%5)  -> !llvm.ptr {name = ""}
-    omp.target_data map_entries(%6 : !llvm.ptr) {
-      %7 = llvm.mlir.constant(99 : i32) : i32
-      %8 = llvm.mlir.constant(1 : i64) : i64
-      %9 = llvm.mlir.constant(1 : i64) : i64
-      %10 = llvm.mlir.constant(0 : i64) : i64
-      %11 = llvm.getelementptr %0[0, %10] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<1024 x i32>
-      llvm.store %7, %11 : i32, !llvm.ptr
-      omp.terminator
-    }
-    llvm.return
+llvm.func @_QPopenmp_target_data_region(%0 : !llvm.ptr) {
+  %1 = llvm.mlir.constant(1023 : index) : i64
+  %2 = llvm.mlir.constant(0 : index) : i64
+  %3 = llvm.mlir.constant(1024 : index) : i64
+  %4 = llvm.mlir.constant(1 : index) : i64
+  %5 = omp.map.bounds   lower_bound(%2 : i64) upper_bound(%1 : i64) extent(%3 : i64) stride(%4 : i64) start_idx(%4 : i64)
+  %6 = omp.map.info var_ptr(%0 : !llvm.ptr, !llvm.array<1024 x i32>)   map_clauses(from) capture(ByRef) bounds(%5)  -> !llvm.ptr {name = ""}
+  omp.target_data map_entries(%6 : !llvm.ptr) {
+    %7 = llvm.mlir.constant(99 : i32) : i32
+    %8 = llvm.mlir.constant(1 : i64) : i64
+    %9 = llvm.mlir.constant(1 : i64) : i64
+    %10 = llvm.mlir.constant(0 : i64) : i64
+    %11 = llvm.getelementptr %0[0, %10] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<1024 x i32>
+    llvm.store %7, %11 : i32, !llvm.ptr
+    omp.terminator
   }
+  llvm.return
 }
 
 // CHECK:         @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4096]
@@ -89,52 +85,50 @@ module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
 
 // -----
 
-module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
-  llvm.func @_QPomp_target_enter_exit(%1 : !llvm.ptr, %3 : !llvm.ptr) {
-    %4 = llvm.mlir.constant(1 : i64) : i64
-    %5 = llvm.alloca %4 x i32 {bindc_name = "dvc", in_type = i32, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_enter_exitEdvc"} : (i64) -> !llvm.ptr
-    %6 = llvm.mlir.constant(1 : i64) : i64
-    %7 = llvm.alloca %6 x i32 {bindc_name = "i", in_type = i32, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_enter_exitEi"} : (i64) -> !llvm.ptr
-    %8 = llvm.mlir.constant(5 : i32) : i32
-    llvm.store %8, %7 : i32, !llvm.ptr
-    %9 = llvm.mlir.constant(2 : i32) : i32
-    llvm.store %9, %5 : i32, !llvm.ptr
-    %10 = llvm.load %7 : !llvm.ptr -> i32
-    %11 = llvm.mlir.constant(10 : i32) : i32
-    %12 = llvm.icmp "slt" %10, %11 : i32
-    %13 = llvm.load %5 : !llvm.ptr -> i32
-    %14 = llvm.mlir.constant(1023 : index) : i64
-    %15 = llvm.mlir.constant(0 : index) : i64
-    %16 = llvm.mlir.constant(1024 : index) : i64
-    %17 = llvm.mlir.constant(1 : index) : i64
-    %18 = omp.map.bounds   lower_bound(%15 : i64) upper_bound(%14 : i64) extent(%16 : i64) stride(%17 : i64) start_idx(%17 : i64)
-    %map1 = omp.map.info var_ptr(%1 : !llvm.ptr, !llvm.array<1024 x i32>)   map_clauses(to) capture(ByRef) bounds(%18) -> !llvm.ptr {name = ""}
-    %19 = llvm.mlir.constant(511 : index) : i64
-    %20 = llvm.mlir.constant(0 : index) : i64
-    %21 = llvm.mlir.constant(512 : index) : i64
-    %22 = llvm.mlir.constant(1 : index) : i64
-    %23 = omp.map.bounds   lower_bound(%20 : i64) upper_bound(%19 : i64) extent(%21 : i64) stride(%22 : i64) start_idx(%22 : i64)
-    %map2 = omp.map.info var_ptr(%3 : !llvm.ptr, !llvm.array<512 x i32>)   map_clauses(exit_release_or_enter_alloc) capture(ByRef) bounds(%23) -> !llvm.ptr {name = ""}
-    omp.target_enter_data   if(%12) device(%13 : i32) map_entries(%map1, %map2 : !llvm.ptr, !llvm.ptr)
-    %24 = llvm.load %7 : !llvm.ptr -> i32
-    %25 = llvm.mlir.constant(10 : i32) : i32
-    %26 = llvm.icmp "sgt" %24, %25 : i32
-    %27 = llvm.load %5 : !llvm.ptr -> i32
-    %28 = llvm.mlir.constant(1023 : index) : i64
-    %29 = llvm.mlir.constant(0 : index) : i64
-    %30 = llvm.mlir.constant(1024 : index) : i64
-    %31 = llvm.mlir.constant(1 : index) : i64
-    %32 = omp.map.bounds   lower_bound(%29 : i64) upper_bound(%28 : i64) extent(%30 : i64) stride(%31 : i64) start_idx(%31 : i64)
-    %map3 = omp.map.info var_ptr(%1 : !llvm.ptr, !llvm.array<1024 x i32>)   map_clauses(from) capture(ByRef) bounds(%32) -> !llvm.ptr {name = ""}
-    %33 = llvm.mlir.constant(511 : index) : i64
-    %34 = llvm.mlir.constant(0 : index) : i64
-    %35 = llvm.mlir.constant(512 : index) : i64
-    %36 = llvm.mlir.constant(1 : index) : i64
-    %37 = omp.map.bounds   lower_bound(%34 : i64) upper_bound(%33 : i64) extent(%35 : i64) stride(%36 : i64) start_idx(%36 : i64)
-    %map4 = omp.map.info var_ptr(%3 : !llvm.ptr, !llvm.array<512 x i32>)   map_clauses(exit_release_or_enter_alloc) capture(ByRef) bounds(%37) -> !llvm.ptr {name = ""}
-    omp.target_exit_data   if(%26) device(%27 : i32) map_entries(%map3, %map4 : !llvm.ptr, !llvm.ptr)
-    llvm.return
-  }
+llvm.func @_QPomp_target_enter_exit(%1 : !llvm.ptr, %3 : !llvm.ptr) {
+  %4 = llvm.mlir.constant(1 : i64) : i64
+  %5 = llvm.alloca %4 x i32 {bindc_name = "dvc", in_type = i32, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_enter_exitEdvc"} : (i64) -> !llvm.ptr
+  %6 = llvm.mlir.constant(1 : i64) : i64
+  %7 = llvm.alloca %6 x i32 {bindc_name = "i", in_type = i32, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_enter_exitEi"} : (i64) -> !llvm.ptr
+  %8 = llvm.mlir.constant(5 : i32) : i32
+  llvm.store %8, %7 : i32, !llvm.ptr
+  %9 = llvm.mlir.constant(2 : i32) : i32
+  llvm.store %9, %5 : i32, !llvm.ptr
+  %10 = llvm.load %7 : !llvm.ptr -> i32
+  %11 = llvm.mlir.constant(10 : i32) : i32
+  %12 = llvm.icmp "slt" %10, %11 : i32
+  %13 = llvm.load %5 : !llvm.ptr -> i32
+  %14 = llvm.mlir.constant(1023 : index) : i64
+  %15 = llvm.mlir.constant(0 : index) : i64
+  %16 = llvm.mlir.constant(1024 : index) : i64
+  %17 = llvm.mlir.constant(1 : index) : i64
+  %18 = omp.map.bounds   lower_bound(%15 : i64) upper_bound(%14 : i64) extent(%16 : i64) stride(%17 : i64) start_idx(%17 : i64)
+  %map1 = omp.map.info var_ptr(%1 : !llvm.ptr, !llvm.array<1024 x i32>)   map_clauses(to) capture(ByRef) bounds(%18) -> !llvm.ptr {name = ""}
+  %19 = llvm.mlir.constant(511 : index) : i64
+  %20 = llvm.mlir.constant(0 : index) : i64
+  %21 = llvm.mlir.constant(512 : index) : i64
+  %22 = llvm.mlir.constant(1 : index) : i64
+  %23 = omp.map.bounds   lower_bound(%20 : i64) upper_bound(%19 : i64) extent(%21 : i64) stride(%22 : i64) start_idx(%22 : i64)
+  %map2 = omp.map.info var_ptr(%3 : !llvm.ptr, !llvm.array<512 x i32>)   map_clauses(exit_release_or_enter_alloc) capture(ByRef) bounds(%23) -> !llvm.ptr {name = ""}
+  omp.target_enter_data   if(%12) device(%13 : i32) map_entries(%map1, %map2 : !llvm.ptr, !llvm.ptr)
+  %24 = llvm.load %7 : !llvm.ptr -> i32
+  %25 = llvm.mlir.constant(10 : i32) : i32
+  %26 = llvm.icmp "sgt" %24, %25 : i32
+  %27 = llvm.load %5 : !llvm.ptr -> i32
+  %28 = llvm.mlir.constant(1023 : index) : i64
+  %29 = llvm.mlir.constant(0 : index) : i64
+  %30 = llvm.mlir.constant(1024 : index) : i64
+  %31 = llvm.mlir.constant(1 : index) : i64
+  %32 = omp.map.bounds   lower_bound(%29 : i64) upper_bound(%28 : i64) extent(%30 : i64) stride(%31 : i64) start_idx(%31 : i64)
+  %map3 = omp.map.info var_ptr(%1 : !llvm.ptr, !llvm.array<1024 x i32>)   map_clauses(from) capture(ByRef) bounds(%32) -> !llvm.ptr {name = ""}
+  %33 = llvm.mlir.constant(511 : index) : i64
+  %34 = llvm.mlir.constant(0 : index) : i64
+  %35 = llvm.mlir.constant(512 : index) : i64
+  %36 = llvm.mlir.constant(1 : index) : i64
+  %37 = omp.map.bounds   lower_bound(%34 : i64) upper_bound(%33 : i64) extent(%35 : i64) stride(%36 : i64) start_idx(%36 : i64)
+  %map4 = omp.map.info var_ptr(%3 : !llvm.ptr, !llvm.array<512 x i32>)   map_clauses(exit_release_or_enter_alloc) capture(ByRef) bounds(%37) -> !llvm.ptr {name = ""}
+  omp.target_exit_data   if(%26) device(%27 : i32) map_entries(%map3, %map4 : !llvm.ptr, !llvm.ptr)
+  llvm.return
 }
 
 // CHECK:         @.offload_sizes = private unnamed_addr constant [2 x i64] [i64 4096, i64 2048]
@@ -211,20 +205,18 @@ module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
 
 // -----
 
-module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
-  llvm.func @_QPopenmp_target_use_dev_ptr() {
-    %0 = llvm.mlir.constant(1 : i64) : i64
-    %a = llvm.alloca %0 x !llvm.ptr : (i64) -> !llvm.ptr
-    %map1 = omp.map.info var_ptr(%a : !llvm.ptr, !llvm.ptr)   map_clauses(from) capture(ByRef) -> !llvm.ptr {name = ""}
-    %map2 = omp.map.info var_ptr(%a : !llvm.ptr, !llvm.ptr)   map_clauses(from) capture(ByRef) -> !llvm.ptr {name = ""}
-    omp.target_data  map_entries(%map1 : !llvm.ptr) use_device_ptr(%map2 -> %arg0 : !llvm.ptr)  {
-      %1 = llvm.mlir.constant(10 : i32) : i32
-      %2 = llvm.load %arg0 : !llvm.ptr -> !llvm.ptr
-      llvm.store %1, %2 : i32, !llvm.ptr
-      omp.terminator
-    }
-    llvm.return
+llvm.func @_QPopenmp_target_use_dev_ptr() {
+  %0 = llvm.mlir.constant(1 : i64) : i64
+  %a = llvm.alloca %0 x !llvm.ptr : (i64) -> !llvm.ptr
+  %map1 = omp.map.info var_ptr(%a : !llvm.ptr, !llvm.ptr)   map_clauses(from) capture(ByRef) -> !llvm.ptr {name = ""}
+  %map2 = omp.map.info var_ptr(%a : !llvm.ptr, !llvm.ptr)   map_clauses(from) capture(ByRef) -> !llvm.ptr {name = ""}
+  omp.target_data  map_entries(%map1 : !llvm.ptr) use_device_ptr(%map2 -> %arg0 : !llvm.ptr)  {
+    %1 = llvm.mlir.constant(10 : i32) : i32
+    %2 = llvm.load %arg0 : !llvm.ptr -> !llvm.ptr
+    llvm.store %1, %2 : i32, !llvm.ptr
+    omp.terminator
   }
+  llvm.return
 }
 
 // CHECK:         @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 8]
@@ -257,20 +249,18 @@ module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
 
 // -----
 
-module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
-  llvm.func @_QPopenmp_target_use_dev_addr() {
-    %0 = llvm.mlir.constant(1 : i64) : i64
-    %a = llvm.alloca %0 x !llvm.ptr : (i64) -> !llvm.ptr
-    %map = omp.map.info var_ptr(%a : !llvm.ptr, !llvm.ptr)   map_clauses(from) capture(ByRef) -> !llvm.ptr {name = ""}
-    %map2 = omp.map.info var_ptr(%a : !llvm.ptr, !llvm.ptr)   map_clauses(from) capture(ByRef) -> !llvm.ptr {name = ""}
-    omp.target_data  map_entries(%map : !llvm.ptr) use_device_addr(%map2 -> %arg0 : !llvm.ptr)  {
-      %1 = llvm.mlir.constant(10 : i32) : i32
-      %2 = llvm.load %arg0 : !llvm.ptr -> !llvm.ptr
-      llvm.store %1, %2 : i32, !llvm.ptr
-      omp.terminator
-    }
-    llvm.return
+llvm.func @_QPopenmp_target_use_dev_addr() {
+  %0 = llvm.mlir.constant(1 : i64) : i64
+  %a = llvm.alloca %0 x !llvm.ptr : (i64) -> !llvm.ptr
+  %map = omp.map.info var_ptr(%a : !llvm.ptr, !llvm.ptr)   map_clauses(from) capture(ByRef) -> !llvm.ptr {name = ""}
+  %map2 = omp.map.info var_ptr(%a : !llvm.ptr, !llvm.ptr)   map_clauses(from) capture(ByRef) -> !llvm.ptr {name = ""}
+  omp.target_data  map_entries(%map : !llvm.ptr) use_device_addr(%map2 -> %arg0 : !llvm.ptr)  {
+    %1 = llvm.mlir.constant(10 : i32) : i32
+    %2 = llvm.load %arg0 : !llvm.ptr -> !llvm.ptr
+    llvm.store %1, %2 : i32, !llvm.ptr
+    omp.terminator
   }
+  llvm.return
 }
 
 // CHECK:         @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 8]
@@ -301,19 +291,17 @@ module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
 
 // -----
 
-module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
-  llvm.func @_QPopenmp_target_use_dev_addr_no_ptr() {
-    %0 = llvm.mlir.constant(1 : i64) : i64
-    %a = llvm.alloca %0 x i32 : (i64) -> !llvm.ptr
-    %map = omp.map.info var_ptr(%a : !llvm.ptr, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
-    %map2 = omp.map.info var_ptr(%a : !llvm.ptr, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
-    omp.target_data  map_entries(%map : !llvm.ptr) use_device_addr(%map2 -> %arg0 : !llvm.ptr)  {
-      %1 = llvm.mlir.constant(10 : i32) : i32
-      llvm.store %1, %arg0 : i32, !llvm.ptr
-      omp.terminator
-    }
-    llvm.return
+llvm.func @_QPopenmp_target_use_dev_addr_no_ptr() {
+  %0 = llvm.mlir.constant(1 : i64) : i64
+  %a = llvm.alloca %0 x i32 : (i64) -> !llvm.ptr
+  %map = omp.map.info var_ptr(%a : !llvm.ptr, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
+  %map2 = omp.map.info var_ptr(%a : !llvm.ptr, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
+  omp.target_data  map_entries(%map : !llvm.ptr) use_device_addr(%map2 -> %arg0 : !llvm.ptr)  {
+    %1 = llvm.mlir.constant(10 : i32) : i32
+    llvm.store %1, %arg0 : i32, !llvm.ptr
+    omp.terminator
   }
+  llvm.return
 }
 
 // CHECK:         @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4]
@@ -343,25 +331,23 @@ module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
 
 // -----
 
-module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
-  llvm.func @_QPopenmp_target_use_dev_addr_nomap() {
-    %0 = llvm.mlir.constant(1 : i64) : i64
-    %a = llvm.alloca %0 x !llvm.ptr : (i64) -> !llvm.ptr
-    %1 = llvm.mlir.constant(1 : i64) : i64
-    %b = llvm.alloca %0 x !llvm.ptr : (i64) -> !llvm.ptr
-    %map = omp.map.info var_ptr(%b : !llvm.ptr, !llvm.ptr)   map_clauses(from) capture(ByRef) -> !llvm.ptr {name = ""}
-    %map2 = omp.map.info var_ptr(%a : !llvm.ptr, !llvm.ptr)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
-    omp.target_data  map_entries(%map : !llvm.ptr) use_device_addr(%map2 -> %arg0 : !llvm.ptr)  {
-      %2 = llvm.mlir.constant(10 : i32) : i32
-      %3 = llvm.load %arg0 : !llvm.ptr -> !llvm.ptr
-      llvm.store %2, %3 : i32, !llvm.ptr
-      %4 = llvm.mlir.constant(20 : i32) : i32
-      %5 = llvm.load %b : !llvm.ptr -> !llvm.ptr
-      llvm.store %4, %5 : i32, !llvm.ptr
-      omp.terminator
-    }
-    llvm.return
+llvm.func @_QPopenmp_target_use_dev_addr_nomap() {
+  %0 = llvm.mlir.constant(1 : i64) : i64
+  %a = llvm.alloca %0 x !llvm.ptr : (i64) -> !llvm.ptr
+  %1 = llvm.mlir.constant(1 : i64) : i64
+  %b = llvm.alloca %0 x !llvm.ptr : (i64) -> !llvm.ptr
+  %map = omp.map.info var_ptr(%b : !llvm.ptr, !llvm.ptr)   map_clauses(from) capture(ByRef) -> !llvm.ptr {name = ""}
+  %map2 = omp.map.info var_ptr(%a : !llvm.ptr, !llvm.ptr)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
+  omp.target_data  map_entries(%map : !llvm.ptr) use_device_addr(%map2 -> %arg0 : !llvm.ptr)  {
+    %2 = llvm.mlir.constant(10 : i32) : i32
+    %3 = llvm.load %arg0 : !llvm.ptr -> !llvm.ptr
+    llvm.store %2, %3 : i32, !llvm.ptr
+    %4 = llvm.mlir.constant(20 : i32) : i32
+    %5 = llvm.load %b : !llvm.ptr -> !llvm.ptr
+    llvm.store %4, %5 : i32, !llvm.ptr
+    omp.terminator
   }
+  llvm.return
 }
 
 // CHECK:         @.offload_sizes = private unnamed_addr constant [2 x i64] [i64 8, i64 0]
@@ -401,27 +387,25 @@ module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
 
 // -----
 
-module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
-  llvm.func @_QPopenmp_target_use_dev_both() {
-    %0 = llvm.mlir.constant(1 : i64) : i64
-    %a = llvm.alloca %0 x !llvm.ptr : (i64) -> !llvm.ptr
-    %1 = llvm.mlir.constant(1 : i64) : i64
-    %b = llvm.alloca %0 x !llvm.ptr : (i64) -> !llvm.ptr
-    %map = omp.map.info var_ptr(%a : !llvm.ptr, !llvm.ptr)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
-    %map1 = omp.map.info var_ptr(%b : !llvm.ptr, !llvm.ptr)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
-    %map2 = omp.map.info var_ptr(%a : !llvm.ptr, !llvm.ptr)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
-    %map3 = omp.map.info var_ptr(%b : !llvm.ptr, !llvm.ptr)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
-    omp.target_data  map_entries(%map, %map1 : !llvm.ptr, !llvm.ptr) use_device_addr(%map3 -> %arg0 : !llvm.ptr) use_device_ptr(%map2 -> %arg1 : !llvm.ptr)  {
-      %2 = llvm.mlir.constant(10 : i32) : i32
-      %3 = llvm.load %arg1 : !llvm.ptr -> !llvm.ptr
-      llvm.store %2, %3 : i32, !llvm.ptr
-      %4 = llvm.mlir.constant(20 : i32) : i32
-      %5 = llvm.load %arg0 : !llvm.ptr -> !llvm.ptr
-      llvm.store %4, %5 : i32, !llvm.ptr
-      omp.terminator
-    }
-    llvm.return
+llvm.func @_QPopenmp_target_use_dev_both() {
+  %0 = llvm.mlir.constant(1 : i64) : i64
+  %a = llvm.alloca %0 x !llvm.ptr : (i64) -> !llvm.ptr
+  %1 = llvm.mlir.constant(1 : i64) : i64
+  %b = llvm.alloca %0 x !llvm.ptr : (i64) -> !llvm.ptr
+  %map = omp.map.info var_ptr(%a : !llvm.ptr, !llvm.ptr)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
+  %map1 = omp.map.info var_ptr(%b : !llvm.ptr, !llvm.ptr)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
+  %map2 = omp.map.info var_ptr(%a : !llvm.ptr, !llvm.ptr)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
+  %map3 = omp.map.info var_ptr(%b : !llvm.ptr, !llvm.ptr)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
+  omp.target_data  map_entries(%map, %map1 : !llvm.ptr, !llvm.ptr) use_device_addr(%map3 -> %arg0 : !llvm.ptr) use_device_ptr(%map2 -> %arg1 : !llvm.ptr)  {
+    %2 = llvm.mlir.constant(10 : i32) : i32
+    %3 = llvm.load %arg1 : !llvm.ptr -> !llvm.ptr
+    llvm.store %2, %3 : i32, !llvm.ptr
+    %4 = llvm.mlir.constant(20 : i32) : i32
+    %5 = llvm.load %arg0 : !llvm.ptr -> !llvm.ptr
+    llvm.store %4, %5 : i32, !llvm.ptr
+    omp.terminator
   }
+  llvm.return
 }
 
 // CHECK:         @.offload_sizes = private unnamed_addr constant [2 x i64] [i64 8, i64 8]
@@ -464,21 +448,19 @@ module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
 
 // -----
 
-module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
-  llvm.func @_QPopenmp_target_data_update() {
-    %0 = llvm.mlir.constant(1 : i64) : i64
-    %1 = llvm.alloca %0 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFopenmp_target_dataEi"} : (i64) -> !llvm.ptr
-    %2 = omp.map.info var_ptr(%1 : !llvm.ptr, i32)   map_clauses(to) capture(ByRef) -> !llvm.ptr {name = ""}
-    omp.target_data map_entries(%2 : !llvm.ptr) {
-      %3 = llvm.mlir.constant(99 : i32) : i32
-      llvm.store %3, %1 : i32, !llvm.ptr
-      omp.terminator
-    }
+llvm.func @_QPopenmp_target_data_update() {
+  %0 = llvm.mlir.constant(1 : i64) : i64
+  %1 = llvm.alloca %0 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFopenmp_target_dataEi"} : (i64) -> !llvm.ptr
+  %2 = omp.map.info var_ptr(%1 : !llvm.ptr, i32)   map_clauses(to) capture(ByRef) -> !llvm.ptr {name = ""}
+  omp.target_data map_entries(%2 : !llvm.ptr) {
+    %3 = llvm.mlir.constant(99 : i32) : i32
+    llvm.store %3, %1 : i32, !llvm.ptr
+    omp.terminator
+  }
 
-    omp.target_update map_entries(%2 : !llvm.ptr)
+  omp.target_update map_entries(%2 : !llvm.ptr)
 
-    llvm.return
-  }
+  llvm.return
 }
 
 // CHECK-LABEL: define void @_QPopenmp_target_data_update
@@ -506,28 +488,26 @@ module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
 
 // -----
 
-module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
-  omp.declare_mapper @_QQFmy_testmy_mapper : !llvm.struct<"_QFmy_testTmy_type", (i32)> {
-  ^bb0(%arg0: !llvm.ptr):
-    %0 = llvm.mlir.constant(0 : i32) : i32
-    %1 = llvm.getelementptr %arg0[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<"_QFmy_testTmy_type", (i32)>
-    %2 = omp.map.info var_ptr(%1 : !llvm.ptr, i32) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = "var%data"}
-    %3 = omp.map.info var_ptr(%arg0 : !llvm.ptr, !llvm.struct<"_QFmy_testTmy_type", (i32)>) map_clauses(tofrom) capture(ByRef) members(%2 : [0] : !llvm.ptr) -> !llvm.ptr {name = "var", partial_map = true}
-    omp.declare_mapper.info map_entries(%3, %2 : !llvm.ptr, !llvm.ptr)
-  }
+omp.declare_mapper @_QQFmy_testmy_mapper : !llvm.struct<"_QFmy_testTmy_type", (i32)> {
+^bb0(%arg0: !llvm.ptr):
+  %0 = llvm.mlir.constant(0 : i32) : i32
+  %1 = llvm.getelementptr %arg0[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<"_QFmy_testTmy_type", (i32)>
+  %2 = omp.map.info var_ptr(%1 : !llvm.ptr, i32) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = "var%data"}
+  %3 = omp.map.info var_ptr(%arg0 : !llvm.ptr, !llvm.struct<"_QFmy_testTmy_type", (i32)>) map_clauses(tofrom) capture(ByRef) members(%2 : [0] : !llvm.ptr) -> !llvm.ptr {name = "var", partial_map = true}
+  omp.declare_mapper.info map_entries(%3, %2 : !llvm.ptr, !llvm.ptr)
+}
 
-  llvm.func @_QPopenmp_target_data_mapper() {
-    %0 = llvm.mlir.constant(1 : i64) : i64
-    %1 = llvm.alloca %0 x !llvm.struct<"_QFmy_testTmy_type", (i32)> {bindc_name = "a"} : (i64) -> !llvm.ptr
-    %2 = omp.map.info var_ptr(%1 : !llvm.ptr, !llvm.struct<"_QFmy_testTmy_type", (i32)>) map_clauses(tofrom) capture(ByRef) mapper(@_QQFmy_testmy_mapper) -> !llvm.ptr {name = "a"}
-    omp.target_data map_entries(%2 : !llvm.ptr) {
-      %3 = llvm.mlir.constant(10 : i32) : i32
-      %4 = llvm.getelementptr %1[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<"_QFmy_testTmy_type", (i32)>
-      llvm.store %3, %4 : i32, !llvm.ptr
-      omp.terminator
-    }
-    llvm.return
+llvm.func @_QPopenmp_target_data_mapper() {
+  %0 = llvm.mlir.constant(1 : i64) : i64
+  %1 = llvm.alloca %0 x !llvm.struct<"_QFmy_testTmy_type", (i32)> {bindc_name = "a"} : (i64) -> !llvm.ptr
+  %2 = omp.map.info var_ptr(%1 : !llvm.ptr, !llvm.struct<"_QFmy_testTmy_type", (i32)>) map_clauses(tofrom) capture(ByRef) mapper(@_QQFmy_testmy_mapper) -> !llvm.ptr {name = "a"}
+  omp.target_data map_entries(%2 : !llvm.ptr) {
+    %3 = llvm.mlir.constant(10 : i32) : i32
+    %4 = llvm.getelementptr %1[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<"_QFmy_testTmy_type", (i32)>
+    llvm.store %3, %4 : i32, !llvm.ptr
+    omp.terminator
   }
+  llvm.return
 }
 
 // CHECK:         @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4]

diff  --git a/mlir/test/Target/LLVMIR/omptargetdata-nowait-llvm.mlir b/mlir/test/Target/LLVMIR/omptargetdata-nowait-llvm.mlir
index f5c620a8942d7..dba8c553aaca5 100644
--- a/mlir/test/Target/LLVMIR/omptargetdata-nowait-llvm.mlir
+++ b/mlir/test/Target/LLVMIR/omptargetdata-nowait-llvm.mlir
@@ -1,15 +1,13 @@
 // RUN: mlir-translate -mlir-to-llvmir -split-input-file %s 2>&1 | FileCheck %s
 
-module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
-  llvm.func @_QPopenmp_target_data_enter() {
-    %0 = llvm.mlir.constant(1 : i64) : i64
-    %1 = llvm.alloca %0 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFopenmp_target_dataEi"} : (i64) -> !llvm.ptr
-    %2 = omp.map.info var_ptr(%1 : !llvm.ptr, i32)   map_clauses(to) capture(ByRef) -> !llvm.ptr {name = ""}
+llvm.func @_QPopenmp_target_data_enter() {
+  %0 = llvm.mlir.constant(1 : i64) : i64
+  %1 = llvm.alloca %0 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFopenmp_target_dataEi"} : (i64) -> !llvm.ptr
+  %2 = omp.map.info var_ptr(%1 : !llvm.ptr, i32)   map_clauses(to) capture(ByRef) -> !llvm.ptr {name = ""}
 
-    omp.target_enter_data map_entries(%2 : !llvm.ptr) nowait
+  omp.target_enter_data map_entries(%2 : !llvm.ptr) nowait
 
-    llvm.return
-  }
+  llvm.return
 }
 
 // CHECK: define void @_QPopenmp_target_data_enter() {
@@ -34,16 +32,14 @@ module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
 
 // -----
 
-module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
-  llvm.func @_QPopenmp_target_data_update() {
-    %0 = llvm.mlir.constant(1 : i64) : i64
-    %1 = llvm.alloca %0 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFopenmp_target_dataEi"} : (i64) -> !llvm.ptr
-    %2 = omp.map.info var_ptr(%1 : !llvm.ptr, i32)   map_clauses(to) capture(ByRef) -> !llvm.ptr {name = ""}
+llvm.func @_QPopenmp_target_data_update() {
+  %0 = llvm.mlir.constant(1 : i64) : i64
+  %1 = llvm.alloca %0 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFopenmp_target_dataEi"} : (i64) -> !llvm.ptr
+  %2 = omp.map.info var_ptr(%1 : !llvm.ptr, i32)   map_clauses(to) capture(ByRef) -> !llvm.ptr {name = ""}
 
-    omp.target_update map_entries(%2 : !llvm.ptr) nowait
+  omp.target_update map_entries(%2 : !llvm.ptr) nowait
 
-    llvm.return
-  }
+  llvm.return
 }
 
 // CHECK: define void @_QPopenmp_target_data_update() {
@@ -68,16 +64,14 @@ module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
 
 // -----
 
-module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
-  llvm.func @_QPopenmp_target_data_exit() {
-    %0 = llvm.mlir.constant(1 : i64) : i64
-    %1 = llvm.alloca %0 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFopenmp_target_dataEi"} : (i64) -> !llvm.ptr
-    %2 = omp.map.info var_ptr(%1 : !llvm.ptr, i32)   map_clauses(from) capture(ByRef) -> !llvm.ptr {name = ""}
+llvm.func @_QPopenmp_target_data_exit() {
+  %0 = llvm.mlir.constant(1 : i64) : i64
+  %1 = llvm.alloca %0 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFopenmp_target_dataEi"} : (i64) -> !llvm.ptr
+  %2 = omp.map.info var_ptr(%1 : !llvm.ptr, i32)   map_clauses(from) capture(ByRef) -> !llvm.ptr {name = ""}
 
-    omp.target_exit_data map_entries(%2 : !llvm.ptr) nowait
+  omp.target_exit_data map_entries(%2 : !llvm.ptr) nowait
 
-    llvm.return
-  }
+  llvm.return
 }
 
 // CHECK: define void @_QPopenmp_target_data_exit() {

diff  --git a/mlir/test/Target/LLVMIR/openmp-data-target-device.mlir b/mlir/test/Target/LLVMIR/openmp-data-target-device.mlir
index 53c9b4f559645..717a77e61b9a1 100644
--- a/mlir/test/Target/LLVMIR/openmp-data-target-device.mlir
+++ b/mlir/test/Target/LLVMIR/openmp-data-target-device.mlir
@@ -3,7 +3,7 @@
 // This tests checks that a target op inside a data op
 // We are only interested in ensuring that the -mlir-to-llmvir pass doesn't crash.
 // CHECK: {{.*}} = add i32 {{.*}}, 1
-module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
+module attributes { } {
   llvm.mlir.global weak_odr hidden local_unnamed_addr constant @__oclc_ABI_version(400 : i32) {addr_space = 4 : i32} : i32
   llvm.func @_QQmain() attributes {fir.bindc_name = "main", omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (to)>} {
     %0 = llvm.mlir.constant(99 : index) : i64


        


More information about the Mlir-commits mailing list