-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[DebugInfo][RemoveDIs] Support finding DPValues as well as dbg.values in findDbgValues #71952
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 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
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 |
---|---|---|
|
@@ -234,6 +234,54 @@ TEST(DbgVariableIntrinsic, EmptyMDIsKillLocation) { | |
EXPECT_TRUE(DbgDeclare->isKillLocation()); | ||
} | ||
|
||
// Duplicate of above test, but in DPValue representation. | ||
TEST(MetadataTest, DeleteInstUsedByDPValue) { | ||
LLVMContext C; | ||
std::unique_ptr<Module> M = parseIR(C, R"( | ||
define i16 @f(i16 %a) !dbg !6 { | ||
%b = add i16 %a, 1, !dbg !11 | ||
call void @llvm.dbg.value(metadata i16 %b, metadata !9, metadata !DIExpression()), !dbg !11 | ||
call void @llvm.dbg.value(metadata !DIArgList(i16 %a, i16 %b), metadata !9, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus)), !dbg !11 | ||
ret i16 0, !dbg !11 | ||
} | ||
declare void @llvm.dbg.value(metadata, metadata, metadata) #0 | ||
attributes #0 = { nounwind readnone speculatable willreturn } | ||
|
||
!llvm.dbg.cu = !{!0} | ||
!llvm.module.flags = !{!5} | ||
|
||
!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) | ||
!1 = !DIFile(filename: "t.ll", directory: "/") | ||
!2 = !{} | ||
!5 = !{i32 2, !"Debug Info Version", i32 3} | ||
!6 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8) | ||
!7 = !DISubroutineType(types: !2) | ||
!8 = !{!9} | ||
!9 = !DILocalVariable(name: "1", scope: !6, file: !1, line: 1, type: !10) | ||
!10 = !DIBasicType(name: "ty16", size: 16, encoding: DW_ATE_unsigned) | ||
!11 = !DILocation(line: 1, column: 1, scope: !6) | ||
)"); | ||
|
||
bool OldDbgValueMode = UseNewDbgInfoFormat; | ||
UseNewDbgInfoFormat = true; | ||
Instruction &I = *M->getFunction("f")->getEntryBlock().getFirstNonPHI(); | ||
M->convertToNewDbgValues(); | ||
|
||
// Find the DPValues using %b. | ||
SmallVector<DbgValueInst *, 2> DVIs; | ||
SmallVector<DPValue *, 2> DPVs; | ||
findDbgValues(DVIs, &I, &DPVs); | ||
ASSERT_EQ(DPVs.size(), 2u); | ||
|
||
// Delete %b. The DPValue should now point to undef. | ||
I.eraseFromParent(); | ||
EXPECT_EQ(DPVs[0]->getNumVariableLocationOps(), 1u); | ||
EXPECT_TRUE(isa<UndefValue>(DPVs[0]->getVariableLocationOp(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. Worth also checking 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. SGTM |
||
EXPECT_EQ(DPVs[1]->getNumVariableLocationOps(), 2u); | ||
EXPECT_TRUE(isa<UndefValue>(DPVs[1]->getVariableLocationOp(1))); | ||
UseNewDbgInfoFormat = OldDbgValueMode; | ||
} | ||
|
||
TEST(DIBuiler, CreateFile) { | ||
LLVMContext Ctx; | ||
std::unique_ptr<Module> M(new Module("MyModule", Ctx)); | ||
|
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
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.
There's a template parameter for intrinsic type but not for DPValue type. What do you think of changing the signature to:
Filter DPValeus by
SpecificDPVType
unlessAnyDPVType == true
.wdyt?
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.
Hhhrrmmm. This is awkward because the intrinsics have an inherent hierarchy due to the instruction hierachy, i.e. DbgInfoIntrinsic -> DbgValueInst -> DbgAssignInst. We haven't yet created that for DPValues because we're focusing only on dbg.value replacement for the moment... but conceptually we'll end up replicating that hierarchy in the future. I'd prefer to wait until we implement that as it should line up with the instruction hierarchy perfectly (TM).