-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[DebugInfo][RemoveDIs] Use autoupgrader to convert old debug-info #143452
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
Changes from 2 commits
8525072
3021087
8506550
d41ece6
add20db
4c75936
bf1e168
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,8 +32,6 @@ using namespace llvm; | |
| STATISTIC(NumInstrRenumberings, "Number of renumberings across all blocks"); | ||
|
|
||
| DbgMarker *BasicBlock::createMarker(Instruction *I) { | ||
| assert(IsNewDbgInfoFormat && | ||
| "Tried to create a marker in a non new debug-info block!"); | ||
| if (I->DebugMarker) | ||
| return I->DebugMarker; | ||
| DbgMarker *Marker = new DbgMarker(); | ||
|
|
@@ -43,8 +41,6 @@ DbgMarker *BasicBlock::createMarker(Instruction *I) { | |
| } | ||
|
|
||
| DbgMarker *BasicBlock::createMarker(InstListType::iterator It) { | ||
| assert(IsNewDbgInfoFormat && | ||
| "Tried to create a marker in a non new debug-info block!"); | ||
|
Contributor
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. Are the
Member
Author
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. I did actually hit this while developing this patch; LLParser was setting the flag to false, then Autoupgrade, upon upgrading, would create a marker and hit this assertion. Deleting the assertion (as the flag should be true everywhere anyway) was part of that process. (Technically this could be taken out of this patch now as there's nothing setting the flag to false, anywhere, but it's got to be deleted at some point). |
||
| if (It != end()) | ||
| return createMarker(&*It); | ||
| DbgMarker *DM = getTrailingDbgRecords(); | ||
|
|
||
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.
Not 100% sure but could this be UB if MD is in fact not a DILocation? Or is that only if it's read through the ptr... I guess it's still not ideal to introduce the chance of UB...
Would it be more correct to return nullptr in that case, and allow nullptrs in DbgRecords which are checked against in the verifier (I don't like it, but not sure this is right either?). I guess the same comment applies to the reinterpret_cast above
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 feel like it's the dereference that's the problem; while my instinct is to go "It'll be fiiiinnnneeee", it turns out we've been here before, and the
createUnresolvedDbgVariableRecordconstructor works exactly for this purpose. I've reshuffled this code to cast to MDNodes and pass into that constructor.What we lose out on is some error-case ergonomics: in some of the verifier tests, we now no longer have a spurious empty-string metadata printed in the middle of a
DbgRecordand instead have (null). That's because the autoupgrade process drops the string reference because it'sMetadata*rather than an MDNode, so it returns null. Theoretically this harms the ability to localise where a faulty debug record is in the input. However, for MDNodes we'll still pass the illegal node in and print it out, I've added a little coverage tollvm.dbg.declare-variable.ll.I don't think this is likely to seriously harm diagnosing what's wrong with an LLVM-IR file; there are also block and function references printed to localise where the faulty record is.