-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[DebugInfo][RemoveDIs] Instrument jump-threading to update DPValues #73127
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
3 commits
Select commit
Hold shift + click to select a range
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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
; RUN: opt -S -passes=jump-threading < %s | FileCheck %s | ||
; RUN: opt -S -passes=jump-threading < %s --try-experimental-debuginfo-iterators | FileCheck %s | ||
|
||
@a = global i32 0, align 4 | ||
; Test that the llvm.dbg.value calls in a threaded block are correctly updated to | ||
|
@@ -91,6 +92,47 @@ exit: ; preds = %bb.f4, %bb.f3, %bb. | |
ret void, !dbg !29 | ||
} | ||
|
||
; Test for the cloning of dbg.values on elided instructions -- down one path | ||
; being threaded, the `and` in the function below is optimised away, but its | ||
; debug-info should still be preserved. | ||
; Similarly, the call to f1 gets cloned, its dbg.value should be cloned too. | ||
define void @test16(i1 %c, i1 %c2, i1 %c3, i1 %c4) nounwind ssp !dbg !30 { | ||
; CHECK-LABEL: define void @test16(i1 | ||
entry: | ||
%cmp = icmp sgt i32 undef, 1, !dbg !33 | ||
br i1 %c, label %land.end, label %land.rhs, !dbg !33 | ||
|
||
land.rhs: | ||
br i1 %c2, label %lor.lhs.false.i, label %land.end, !dbg !33 | ||
|
||
lor.lhs.false.i: | ||
br i1 %c3, label %land.end, label %land.end, !dbg !33 | ||
|
||
; CHECK-LABEL: land.end.thr_comm: | ||
; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you give the dbg.values different constant values to easily identify which is which in the output/CHECK lines? |
||
; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 1, | ||
; CHECK-NEXT: call void @f1() | ||
; CHECK-NEXT: br i1 %c4, | ||
|
||
; CHECK-LABEL: land.end: | ||
; CHECK-NEXT: %0 = phi i1 | ||
; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 0, | ||
land.end: | ||
%0 = phi i1 [ true, %entry ], [ false, %land.rhs ], [false, %lor.lhs.false.i], [false, %lor.lhs.false.i] | ||
call void @llvm.dbg.value(metadata i32 0, metadata !32, metadata !DIExpression()), !dbg !33 | ||
%cmp12 = and i1 %cmp, %0, !dbg !33 | ||
%xor1 = xor i1 %cmp12, %c4, !dbg !33 | ||
call void @llvm.dbg.value(metadata i32 1, metadata !32, metadata !DIExpression()), !dbg !33 | ||
call void @f1() | ||
br i1 %xor1, label %if.then, label %if.end, !dbg !33 | ||
|
||
if.then: | ||
ret void, !dbg !33 | ||
|
||
if.end: | ||
ret void, !dbg !33 | ||
} | ||
|
||
declare void @f1() | ||
|
||
declare void @f2() | ||
|
@@ -138,3 +180,7 @@ attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memo | |
!27 = !DILocation(line: 13, column: 1, scope: !5) | ||
!28 = !DILocation(line: 14, column: 1, scope: !5) | ||
!29 = !DILocation(line: 15, column: 1, scope: !5) | ||
!30 = distinct !DISubprogram(name: "test13", linkageName: "test13", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) | ||
!31 = !{!32} | ||
!32 = !DILocalVariable(name: "1", scope: !30, file: !1, line: 1, type: !10) | ||
!33 = !DILocation(line: 1, column: 1, scope: !30) |
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.
Is the
AllowEmpty
(3rd parameter) situation something to do with use-before-defs?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's more of a check-my-errors flag -- using replaceVariableLocationOp on debug intrinsics that don't use the "Source" value is considered an error, and there's an assertion for that. Wheras this code here is speculatively trying to "replace this value if it's used, never mind if it isn't", and the AllowEmpty parameter signals that there shouldn't be an error if the Source value can't be found.
There are a bunch of different ways of doing this, I'll admit I haven't thought about how to restructure it, but it's an existing API call on DbgValueInst, so I didn't want to get too far away from that.