-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OpenMPIRBuilder] Don't drop debug info for target region. (#80692)
When an outlined function is generated for omp target region, a corresponding DISubprogram was not being generated. This resulted in all the debug information for the target region being dropped. This commit adds DISubprogram for the outlined function if there is one available for the parent function. It also updates the current debug location so that the right scope is used for the entries in the outlined function. There are places in the OpenMPIRBuilder which changes insertion point but don't update the debug location accordingly. They cause issue when debug info is enabled. I have fixed a few that I observed to cause issue. But there may be more and a systematic cleanup may be required. With this change in place, I can set source line breakpoint in target region and run to them in debugger.
- Loading branch information
Showing
6 changed files
with
134 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
! RUN: %flang_fc1 -fopenmp -emit-llvm -debug-info-kind=standalone %s -o - | FileCheck %s | ||
|
||
! Test that variables inside OpenMP target region don't cause build failure. | ||
subroutine test1 | ||
implicit none | ||
real, allocatable :: xyz(:) | ||
integer :: i | ||
|
||
!$omp target simd map(from:xyz) | ||
do i = 1, size(xyz) | ||
xyz(i) = 5.0 * xyz(i) | ||
end do | ||
end subroutine | ||
|
||
subroutine test2 (xyz) | ||
integer :: i | ||
integer :: xyz(:) | ||
|
||
!$omp target map(from:xyz) | ||
!$omp do private(xyz) | ||
do i = 1, 10 | ||
xyz(i) = i | ||
end do | ||
!$omp end target | ||
end subroutine | ||
|
||
!CHECK: DISubprogram(name: "test1"{{.*}}) | ||
!CHECK: DISubprogram(name: "test2"{{.*}}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s | ||
|
||
module attributes {omp.is_target_device = true} { | ||
llvm.func @_QQmain() { | ||
%0 = llvm.mlir.constant(1 : i32) : i32 | ||
%1 = llvm.alloca %0 x i32 : (i32) -> !llvm.ptr | ||
%9 = omp.map.info var_ptr(%1 : !llvm.ptr, i32) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""} | ||
omp.target map_entries(%9 -> %arg0 : !llvm.ptr) { | ||
^bb0(%arg0: !llvm.ptr): | ||
%13 = llvm.mlir.constant(1 : i32) : i32 | ||
llvm.store %13, %arg0 : i32, !llvm.ptr loc(#loc2) | ||
omp.terminator | ||
} | ||
llvm.return | ||
} loc(#loc3) | ||
} | ||
#file = #llvm.di_file<"target.f90" in ""> | ||
#cu = #llvm.di_compile_unit<id = distinct[0]<>, | ||
sourceLanguage = DW_LANG_Fortran95, file = #file, isOptimized = false, | ||
emissionKind = LineTablesOnly> | ||
#sp_ty = #llvm.di_subroutine_type<callingConvention = DW_CC_normal> | ||
#sp = #llvm.di_subprogram<id = distinct[1]<>, compileUnit = #cu, scope = #file, | ||
name = "_QQmain", file = #file, subprogramFlags = "Definition", type = #sp_ty> | ||
#loc1 = loc("target.f90":1:1) | ||
#loc2 = loc("target.f90":46:3) | ||
#loc3 = loc(fused<#sp>[#loc1]) | ||
|
||
// CHECK-DAG: ![[SP:.*]] = {{.*}}!DISubprogram(name: "__omp_offloading_{{.*}}"{{.*}}) | ||
// CHECK-DAG: !DILocation(line: 46, column: 3, scope: ![[SP]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s | ||
|
||
// Same test as omptarget-debug.mlir but with is_target_device = false. | ||
// Somehow test with omp.target don't work with -split-input-file. | ||
module attributes {omp.is_target_device = false} { | ||
llvm.func @_QQmain() { | ||
%0 = llvm.mlir.constant(1 : i32) : i32 | ||
%1 = llvm.alloca %0 x i32 : (i32) -> !llvm.ptr | ||
%9 = omp.map.info var_ptr(%1 : !llvm.ptr, i32) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""} | ||
omp.target map_entries(%9 -> %arg0 : !llvm.ptr) { | ||
^bb0(%arg0: !llvm.ptr): | ||
%13 = llvm.mlir.constant(1 : i32) : i32 | ||
llvm.store %13, %arg0 : i32, !llvm.ptr loc(#loc2) | ||
omp.terminator | ||
} | ||
llvm.return | ||
} loc(#loc3) | ||
} | ||
#file = #llvm.di_file<"target.f90" in ""> | ||
#cu = #llvm.di_compile_unit<id = distinct[0]<>, | ||
sourceLanguage = DW_LANG_Fortran95, file = #file, isOptimized = false, | ||
emissionKind = LineTablesOnly> | ||
#sp_ty = #llvm.di_subroutine_type<callingConvention = DW_CC_normal> | ||
#sp = #llvm.di_subprogram<id = distinct[1]<>, compileUnit = #cu, scope = #file, | ||
name = "_QQmain", file = #file, subprogramFlags = "Definition", type = #sp_ty> | ||
#loc1 = loc("target.f90":1:1) | ||
#loc2 = loc("target.f90":46:3) | ||
#loc3 = loc(fused<#sp>[#loc1]) | ||
|
||
// CHECK-DAG: ![[SP:.*]] = {{.*}}!DISubprogram(name: "__omp_offloading_{{.*}}"{{.*}}) | ||
// CHECK-DAG: !DILocation(line: 46, column: 3, scope: ![[SP]]) |