[flang-commits] [flang] [llvm] [mlir] [OpenMPIRBuilder] Don't drop debug info for target region. (PR #80692)

Abid Qadeer via flang-commits flang-commits at lists.llvm.org
Tue Jul 9 07:03:06 PDT 2024


================
@@ -0,0 +1,72 @@
+// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s
+
+module attributes {omp.is_target_device = true} {
+  llvm.func @_QQmain() {
+    %0 = llvm.mlir.constant(1 : i64) : i64
+    %1 = llvm.alloca %0 x i32 : (i64) -> !llvm.ptr<5>
+    %2 = llvm.addrspacecast %1 : !llvm.ptr<5> to !llvm.ptr
+    %3 = llvm.mlir.constant(1 : i64) : i64
+    %4 = llvm.alloca %3 x i32 : (i64) -> !llvm.ptr<5>
+    %5 = llvm.addrspacecast %4 : !llvm.ptr<5> to !llvm.ptr
+    %6 = llvm.mlir.constant(1 : i64) : i64
+    %7 = llvm.alloca %6 x i32 : (i64) -> !llvm.ptr<5>
+    %8 = llvm.addrspacecast %7 : !llvm.ptr<5> to !llvm.ptr
+    %9 = omp.map_info var_ptr(%2 : !llvm.ptr, i32) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
+    %10 = omp.map_info var_ptr(%5 : !llvm.ptr, i32) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
+    omp.target map_entries(%9 -> %arg0, %10 -> %arg1 : !llvm.ptr, !llvm.ptr) {
+    ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr):
+      %12 = llvm.mlir.constant(2 : i32) : i32
+      %13 = llvm.mlir.constant(1 : i32) : i32
+      %14 = llvm.load %arg0 : !llvm.ptr -> i32 loc(#loc2)
+      %15 = llvm.add %14, %13  : i32 loc(#loc2)
+      llvm.store %15, %arg0 : i32, !llvm.ptr loc(#loc2)
+      %16 = llvm.load %arg0 : !llvm.ptr -> i32 loc(#loc3)
+      %17 = llvm.add %16, %12  : i32 loc(#loc3)
+      llvm.store %17, %arg1 : i32, !llvm.ptr loc(#loc3)
+      omp.terminator
+    }
+    %11 = omp.map_info var_ptr(%8 : !llvm.ptr, i32) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
+    omp.target map_entries(%11 -> %arg0 : !llvm.ptr) {
+    ^bb0(%arg0: !llvm.ptr):
+      %12 = llvm.mlir.constant(1 : i32) : i32
+      omp.parallel {
+        %13 = llvm.load %arg0 : !llvm.ptr -> i32 loc(#loc4)
+        %14 = llvm.add %13, %12  : i32 loc(#loc4)
+        llvm.store %14, %arg0 : i32, !llvm.ptr loc(#loc4)
+        omp.terminator
+      }
+      omp.terminator
+    }
+    llvm.return
+  } loc(#loc5)
+} loc(#loc)
----------------
abidh wrote:

I have minimized the test. I also had to make one other small change after I rebased. There was debug info for variables that gets passed into the targer region. They can fail LLVM verifier checks as the scope of the variable may not match the function created for target region. This may require extra work so I have disabled the debug info for such variables.

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


More information about the flang-commits mailing list