-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Globalopt pass produces invalid debug info #100654
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
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,34 @@ | ||
; RUN: opt -S -passes=globalopt --experimental-debuginfo-iterators=false <%s | FileCheck %s | ||
; CHECK: #dbg_value(ptr undef, | ||
; CHECK-SAME: [[VAR:![0-9]+]], | ||
; CHECK-SAME: !DIExpression() | ||
; CHECK: [[VAR]] = !DILocalVariable(name: "_format" | ||
|
||
|
||
; ModuleID = '<stdin>' | ||
source_filename = "test.cpp" | ||
|
||
@_ZZZZ4main_format = internal constant [24 x i8] c"Result1: Hello, World!\0A\00", align 16, !dbg !9 | ||
|
||
define void @foo() align 2 !dbg !5 { | ||
entry: | ||
call void @llvm.dbg.value(metadata ptr @_ZZZZ4main_format, metadata !11, metadata !DIExpression()), !dbg !12 | ||
ret void | ||
} | ||
|
||
!llvm.dbg.cu = !{!0} | ||
!llvm.module.flags = !{!3, !4} | ||
|
||
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang", isOptimized: true, emissionKind: FullDebug) | ||
!1 = !DIFile(filename: "test.cpp", directory: "/path/to") | ||
!2 = !{} | ||
!3 = !{i32 7, !"Dwarf Version", i32 4} | ||
!4 = !{i32 2, !"Debug Info Version", i32 3} | ||
!5 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 27, type: !6, scopeLine: 27, spFlags: DISPFlagDefinition, unit: !0) | ||
!6 = !DISubroutineType(types: !7) | ||
!7 = !{null} | ||
!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) | ||
!9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression()) | ||
!10 = distinct !DIGlobalVariable(name: "_format", scope: !5, file: !1, line: 49, type: !8, isLocal: true, isDefinition: true) | ||
!11 = !DILocalVariable(name: "_format", arg: 1, scope: !5, file: !1, line: 79, type: !8) | ||
!12 = !DILocation(line: 0, scope: !5) |
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.
Is this line necessary? I believe
GV.removeDeadConstantUsers();
should already call this ifGV
is dead, as part ofconstantIsDead(..., /*RemoveDeadUsers=*/true)
.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.
The loop responsible for removing dead users and potentially calling constantIsDead() does not execute in this case. It looks like both the iterators I and E are null indicating it does not count debug intrinsic as users.
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 might be more appropriate to put this into
removeDeadConstantUsers
then, after the loop - I think we'd want to perform the salvage step for any constant that dies with debug users regardless of the pass that does it. However, that might end up affecting other tests; if so it can easily be left for another patch.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.
Yes, I can investigate more and follow up on a different patch if it's a viable approach.