-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[DebugInfo] Handle additional types of stores in assignment tracking #129070
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
7 commits
Select commit
Hold shift + click to select a range
208e535
Handle non-contiguous stores in assignment tracking
SLTozer 5caeff0
Add tests
SLTozer 52b2a06
Don't try to get info from vp.stores; needs work for alignment
SLTozer e0ba7e2
Slight comment update
SLTozer fae7510
Fixup some editing and test mistakes
SLTozer b1a158b
Include llvm.masked.compressstore, relax verifier
SLTozer 517c286
Update test to account for relaxed check
SLTozer 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
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,65 @@ | ||
; RUN: llc -mtriple=riscv64 < %s | FileCheck %s --implicit-check-not=DEBUG_VALUE | ||
|
||
;; Verify that tagged and untagged non-contiguous stores are handled correctly | ||
;; by assignment tracking. | ||
;; * The store to "i" is untagged, and results in the memory location being | ||
;; dropped in favour of the debug value 1010 after the store. | ||
;; * The store to "j" is tagged with a corresponding dbg_assign, which allows | ||
;; us to keep using the memory location. | ||
|
||
; CHECK-LABEL: foo: | ||
; CHECK-NEXT: .Lfunc_begin0: | ||
; CHECK: # %bb.0 | ||
; CHECK: addi a1, sp, 48 | ||
; CHECK-NEXT: #DEBUG_VALUE: foo:i <- [DW_OP_deref] $x12 | ||
; CHECK-NEXT: #DEBUG_VALUE: foo:j <- [DW_OP_deref] $x12 | ||
; CHECK: vsse32.v | ||
; CHECK-NEXT: #DEBUG_VALUE: foo:i <- 1010 | ||
; CHECK-NEXT: vsse32.v | ||
|
||
|
||
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128" | ||
target triple = "riscv64-unknown-linux-gnu" | ||
|
||
define void @foo() #0 !dbg !5 { | ||
entry: | ||
%i = alloca i64, align 8, !DIAssignID !6 | ||
%j = alloca i64, align 8, !DIAssignID !12 | ||
%sar_height.i = getelementptr i8, ptr %i, i64 24 | ||
store ptr %sar_height.i, ptr null, align 8 | ||
%vui.i = getelementptr i8, ptr %i, i64 44 | ||
%0 = load i32, ptr %vui.i, align 4 | ||
%sar_width.i = getelementptr i8, ptr %i, i64 20 | ||
%i_sar_width.i = getelementptr i8, ptr %i, i64 48 | ||
%j_sar_width.j = getelementptr i8, ptr %j, i64 48 | ||
#dbg_assign(i32 1010, !7, !DIExpression(), !6, ptr %i_sar_width.i, !DIExpression(), !9) | ||
#dbg_assign(i32 2121, !17, !DIExpression(), !12, ptr %i_sar_width.i, !DIExpression(), !9) | ||
%1 = load <2 x i32>, ptr %sar_width.i, align 4 | ||
call void @llvm.experimental.vp.strided.store.v2i32.p0.i64(<2 x i32> %1, ptr align 4 %i_sar_width.i, i64 -4, <2 x i1> splat (i1 true), i32 2) | ||
call void @llvm.experimental.vp.strided.store.v2i32.p0.i64(<2 x i32> %1, ptr align 4 %j_sar_width.j, i64 -4, <2 x i1> splat (i1 true), i32 2), !DIAssignID !13 | ||
#dbg_assign(i32 1010, !7, !DIExpression(), !14, ptr %i_sar_width.i, !DIExpression(), !9) | ||
#dbg_assign(i32 2121, !17, !DIExpression(), !13, ptr %i_sar_width.i, !DIExpression(), !9) | ||
ret void | ||
} | ||
|
||
attributes #0 = { "target-features"="+v" } | ||
|
||
!llvm.dbg.cu = !{!0} | ||
!llvm.module.flags = !{!3, !4} | ||
|
||
!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, producer: "clang version 21.0.0git") | ||
!1 = !DIFile(filename: "test.c", directory: "/") | ||
!2 = !{} | ||
!3 = !{i32 2, !"Debug Info Version", i32 3} | ||
!4 = !{i32 7, !"debug-info-assignment-tracking", i1 true} | ||
!5 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 1, scopeLine: 1, type: !10, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11) | ||
!6 = distinct !DIAssignID() | ||
!7 = !DILocalVariable(name: "i", scope: !5, file: !1, line: 7, type: !8) | ||
!8 = !DIBasicType(name: "int32_t", size: 32, encoding: DW_ATE_signed) | ||
!9 = !DILocation(line: 5, scope: !5) | ||
!10 = !DISubroutineType(types: !2) | ||
!11 = !{!7, !17} | ||
!12 = distinct !DIAssignID() | ||
!13 = distinct !DIAssignID() | ||
!14 = distinct !DIAssignID() | ||
!17 = !DILocalVariable(name: "j", scope: !5, file: !1, line: 7, type: !8) |
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,39 @@ | ||
; RUN: llvm-as -disable-output <%s 2>&1 | FileCheck %s --implicit-check-not="attached to unexpected instruction kind" | ||
;; Check that we allow intrinsics to have !DIAssignID attachments, but we do not | ||
;; allow non-intrinsic calls to have them. | ||
;; FIXME: Ideally we would also not allow non-store intrinsics, e.g. the | ||
;; llvm.vp.load intrinsic in this test. | ||
|
||
; CHECK: !DIAssignID attached to unexpected instruction kind | ||
; CHECK-NEXT: call void @g() | ||
|
||
declare void @g() | ||
|
||
define void @f() !dbg !5 { | ||
call void @llvm.vp.store.v2i8.p0(<2 x i8> poison, ptr poison, <2 x i1> poison, i32 poison), !DIAssignID !6 | ||
call void @llvm.vp.scatter.v2i8.v2p0(<2 x i8> poison, <2 x ptr> poison, <2 x i1> poison, i32 poison), !DIAssignID !7 | ||
call void @llvm.experimental.vp.strided.store.v2i8.i64(<2 x i8> poison, ptr poison, i64 poison, <2 x i1> poison, i32 poison), !DIAssignID !8 | ||
call void @llvm.masked.store.v2i8.p0(<2 x i8> poison, ptr poison, i32 1, <2 x i1> poison), !DIAssignID !9 | ||
call void @llvm.masked.scatter.v2i8.v2p0(<2 x i8> poison, <2 x ptr> poison, i32 1, <2 x i1> poison), !DIAssignID !10 | ||
%r = call <2 x i8> @llvm.vp.load.v2i8.p0(ptr poison, <2 x i1> poison, i32 poison), !DIAssignID !11 | ||
call void @g(), !DIAssignID !12 | ||
ret void | ||
} | ||
|
||
!llvm.module.flags = !{!0} | ||
!llvm.dbg.cu = !{!1} | ||
|
||
!0 = !{i32 2, !"Debug Info Version", i32 3} | ||
!1 = distinct !DICompileUnit(language: DW_LANG_Swift, producer: "clang", | ||
file: !2, emissionKind: 2) | ||
!2 = !DIFile(filename: "path/to/file", directory: "/path/to/dir") | ||
!3 = !{null} | ||
!4 = !DISubroutineType(types: !3) | ||
!5 = distinct !DISubprogram(name: "f", scope: !2, file: !2, line: 1, type: !4, scopeLine: 2, unit: !1) | ||
!6 = distinct !DIAssignID() | ||
!7 = distinct !DIAssignID() | ||
!8 = distinct !DIAssignID() | ||
!9 = distinct !DIAssignID() | ||
!10 = distinct !DIAssignID() | ||
!11 = distinct !DIAssignID() | ||
!12 = distinct !DIAssignID() |
Oops, something went wrong.
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.
Could a
vp_scatter
store to multiple different allocas? My question is basically whether it's a given that we can return a single "base" pointer for any given scatter?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.
It isn't a given, but all the examples I've seen do store to different offsets at a single alloca though, so I decided not to over-complicate this logic. In practice this is, as far as I can tell, quite a narrowly used intrinsic and the default behaviour of simply ignoring the intrinsic won't cause any errors, so it's probably not worth trying to cover all our bases here until we see this be a problem.