-
Notifications
You must be signed in to change notification settings - Fork 14.5k
[OMPIRBuilder] Don't use invalid debug loc in task proxy function. #148284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This is similar to llvm#147950 but for task proxy function.
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-llvm Author: Abid Qadeer (abidh) ChangesThis is similar to #147950 but for task proxy function. Full diff: https://github.com/llvm/llvm-project/pull/148284.diff 2 Files Affected:
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 170224616ac64..4f08ea97378c2 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -7229,9 +7229,11 @@ static Function *emitTargetTaskProxyFunction(
bool HasShareds = SharedArgsOperandNo > 0;
bool HasOffloadingArrays = NumOffloadingArrays > 0;
+ IRBuilder<>::InsertPointGuard IPG(Builder);
BasicBlock *EntryBB =
BasicBlock::Create(Builder.getContext(), "entry", ProxyFn);
Builder.SetInsertPoint(EntryBB);
+ Builder.SetCurrentDebugLocation(llvm::DebugLoc());
SmallVector<Value *> KernelLaunchArgs;
KernelLaunchArgs.reserve(StaleCI->arg_size());
diff --git a/mlir/test/Target/LLVMIR/omptarget-debug-target-task.mlir b/mlir/test/Target/LLVMIR/omptarget-debug-target-task.mlir
new file mode 100644
index 0000000000000..dbd465a97645b
--- /dev/null
+++ b/mlir/test/Target/LLVMIR/omptarget-debug-target-task.mlir
@@ -0,0 +1,49 @@
+// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s
+
+module attributes {omp.is_target_device = false} {
+ llvm.func @omp_target_depend_() {
+ %0 = llvm.mlir.constant(39 : index) : i64
+ %1 = llvm.mlir.constant(1 : index) : i64
+ %2 = llvm.mlir.constant(40 : index) : i64
+ %3 = omp.map.bounds lower_bound(%1 : i64) upper_bound(%0 : i64) extent(%2 : i64) stride(%1 : i64) start_idx(%1 : i64)
+ %4 = llvm.mlir.addressof @_QFEa : !llvm.ptr
+ %5 = omp.map.info var_ptr(%4 : !llvm.ptr, !llvm.array<40 x i32>) map_clauses(from) capture(ByRef) bounds(%3) -> !llvm.ptr {name = "a"}
+ omp.target depend(taskdependin -> %4 : !llvm.ptr) map_entries(%5 -> %arg0 : !llvm.ptr) {
+ %6 = llvm.mlir.constant(100 : index) : i32
+ llvm.store %6, %arg0 : i32, !llvm.ptr
+ omp.terminator
+ } loc(#loc13)
+ llvm.return
+ } loc(#loc12)
+
+ llvm.mlir.global internal @_QFEa() {addr_space = 0 : i32} : !llvm.array<40 x i32> {
+ %0 = llvm.mlir.zero : !llvm.array<40 x i32>
+ llvm.return %0 : !llvm.array<40 x i32>
+ }
+}
+
+#loc1 = loc("test.f90":4:18)
+#loc2 = loc("test.f90":8:7)
+
+#di_file = #llvm.di_file<"test.f90" in "">
+#di_null_type = #llvm.di_null_type
+#di_compile_unit = #llvm.di_compile_unit<id = distinct[0]<>,
+ sourceLanguage = DW_LANG_Fortran95, file = #di_file, producer = "flang",
+ isOptimized = false, emissionKind = LineTablesOnly>
+#di_subroutine_type = #llvm.di_subroutine_type<
+ callingConvention = DW_CC_program, types = #di_null_type>
+#di_subprogram = #llvm.di_subprogram<id = distinct[1]<>,
+ compileUnit = #di_compile_unit, scope = #di_file, name = "main",
+ file = #di_file, subprogramFlags = "Definition|MainSubprogram",
+ type = #di_subroutine_type>
+#di_subprogram1 = #llvm.di_subprogram<compileUnit = #di_compile_unit,
+ name = "target", file = #di_file, subprogramFlags = "Definition",
+ type = #di_subroutine_type>
+
+
+#loc12 = loc(fused<#di_subprogram>[#loc1])
+#loc13 = loc(fused<#di_subprogram1>[#loc2])
+
+// CHECK: define internal void @.omp_target_task_proxy_func
+// CHECK-NOT: !dbg
+// CHECK: }
|
@llvm/pr-subscribers-flang-openmp Author: Abid Qadeer (abidh) ChangesThis is similar to #147950 but for task proxy function. Full diff: https://github.com/llvm/llvm-project/pull/148284.diff 2 Files Affected:
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 170224616ac64..4f08ea97378c2 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -7229,9 +7229,11 @@ static Function *emitTargetTaskProxyFunction(
bool HasShareds = SharedArgsOperandNo > 0;
bool HasOffloadingArrays = NumOffloadingArrays > 0;
+ IRBuilder<>::InsertPointGuard IPG(Builder);
BasicBlock *EntryBB =
BasicBlock::Create(Builder.getContext(), "entry", ProxyFn);
Builder.SetInsertPoint(EntryBB);
+ Builder.SetCurrentDebugLocation(llvm::DebugLoc());
SmallVector<Value *> KernelLaunchArgs;
KernelLaunchArgs.reserve(StaleCI->arg_size());
diff --git a/mlir/test/Target/LLVMIR/omptarget-debug-target-task.mlir b/mlir/test/Target/LLVMIR/omptarget-debug-target-task.mlir
new file mode 100644
index 0000000000000..dbd465a97645b
--- /dev/null
+++ b/mlir/test/Target/LLVMIR/omptarget-debug-target-task.mlir
@@ -0,0 +1,49 @@
+// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s
+
+module attributes {omp.is_target_device = false} {
+ llvm.func @omp_target_depend_() {
+ %0 = llvm.mlir.constant(39 : index) : i64
+ %1 = llvm.mlir.constant(1 : index) : i64
+ %2 = llvm.mlir.constant(40 : index) : i64
+ %3 = omp.map.bounds lower_bound(%1 : i64) upper_bound(%0 : i64) extent(%2 : i64) stride(%1 : i64) start_idx(%1 : i64)
+ %4 = llvm.mlir.addressof @_QFEa : !llvm.ptr
+ %5 = omp.map.info var_ptr(%4 : !llvm.ptr, !llvm.array<40 x i32>) map_clauses(from) capture(ByRef) bounds(%3) -> !llvm.ptr {name = "a"}
+ omp.target depend(taskdependin -> %4 : !llvm.ptr) map_entries(%5 -> %arg0 : !llvm.ptr) {
+ %6 = llvm.mlir.constant(100 : index) : i32
+ llvm.store %6, %arg0 : i32, !llvm.ptr
+ omp.terminator
+ } loc(#loc13)
+ llvm.return
+ } loc(#loc12)
+
+ llvm.mlir.global internal @_QFEa() {addr_space = 0 : i32} : !llvm.array<40 x i32> {
+ %0 = llvm.mlir.zero : !llvm.array<40 x i32>
+ llvm.return %0 : !llvm.array<40 x i32>
+ }
+}
+
+#loc1 = loc("test.f90":4:18)
+#loc2 = loc("test.f90":8:7)
+
+#di_file = #llvm.di_file<"test.f90" in "">
+#di_null_type = #llvm.di_null_type
+#di_compile_unit = #llvm.di_compile_unit<id = distinct[0]<>,
+ sourceLanguage = DW_LANG_Fortran95, file = #di_file, producer = "flang",
+ isOptimized = false, emissionKind = LineTablesOnly>
+#di_subroutine_type = #llvm.di_subroutine_type<
+ callingConvention = DW_CC_program, types = #di_null_type>
+#di_subprogram = #llvm.di_subprogram<id = distinct[1]<>,
+ compileUnit = #di_compile_unit, scope = #di_file, name = "main",
+ file = #di_file, subprogramFlags = "Definition|MainSubprogram",
+ type = #di_subroutine_type>
+#di_subprogram1 = #llvm.di_subprogram<compileUnit = #di_compile_unit,
+ name = "target", file = #di_file, subprogramFlags = "Definition",
+ type = #di_subroutine_type>
+
+
+#loc12 = loc(fused<#di_subprogram>[#loc1])
+#loc13 = loc(fused<#di_subprogram1>[#loc2])
+
+// CHECK: define internal void @.omp_target_task_proxy_func
+// CHECK-NOT: !dbg
+// CHECK: }
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this PR, @abidh. While this LGTM, i have a question - this seems to be a pattern that is repeating itself. Wouldn't we be better off with a static
utility function in OMPIRBuilder.cpp
for creating entry basic blocks in newly created functions which would also set up the debug location correctly?
Thanks @bhandarkar-pranav for the suggestion. I will merge this and open a cleanup PR to add the utility function. |
… proxy function." (#148728) There is a sanitizer fail in CI after this which I need to investigate. Reverting for now. Reverts llvm/llvm-project#148284
This is similar to #147950 but for task proxy function.