-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[OpenMPIRBuilder] Don't drop debug info for target region. #80692
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
31472fe
[OpenMPIRBuilder] Don't drop debug info for target region.
abidh 9978dc3
Move the test into MLIR.
abidh da3ac09
Correct the case on variable name.
abidh d3585a8
Minimize testcase as per review comments.
abidh f1b4e54
Don't generate debug info for variable in target region.
abidh 4d1507a
Improve test case.
abidh 9370c29
Use InsertPointGuard instead of manual save/restore.
abidh a4b6b77
Check DebugLoc is valid before using it.
abidh beda51c
Add testcase with is_target_device = false
abidh bab8185
Avoid using stale debug location.
abidh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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]]) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
These can also be variables from Fortran BLOCK constructs, or the selectors from ASSOCIATE/SELECT TYPE/SELECT RANK/SELECT CASE.
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.
I think it is fine to do it the way you are doing given we will want to lift this restriction, so any compiler performance gain would be temporary and artificial (it would otherwise be more efficient to walk only the front block).