-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[OMPIRBuilder] Avoid crash in BasicBlock::splice. #154987
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 3 commits
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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -307,7 +307,15 @@ void llvm::spliceBB(IRBuilderBase::InsertPoint IP, BasicBlock *New, | |||||||||
|
|
||||||||||
| // Move instructions to new block. | ||||||||||
| BasicBlock *Old = IP.getBlock(); | ||||||||||
| New->splice(New->begin(), Old, IP.getPoint(), Old->end()); | ||||||||||
| // If the Old block is empty then there are no instructions to move. But in | ||||||||||
| // the new debug scheme, it could have trailing debug records which will be | ||||||||||
| // moved to New in spliceDebugInfoEmptyBlock. We dont want that for 2 reasons: | ||||||||||
| // 1. If New is also empty, it could cause a crash. | ||||||||||
| // 2. Even if New is not empty, we want to keep those debug records in the | ||||||||||
| // Old as that was the behavior with the old scheme (debug intrinsics). | ||||||||||
|
||||||||||
| // 2. Even if New is not empty, we want to keep those debug records in the | |
| // Old as that was the behavior with the old scheme (debug intrinsics). | |
| // 2. Even if New is not empty, we want to keep those debug records in the | |
| // Old as that was the behavior with the old scheme (debug intrinsics). |
[nit] Just being the legacy scheme doesn't mean it is more correct. Consider something that mentions the rationale from BasicBlock::spliceDebugInfoEmptyBlock:
// If the source block is completely empty, including no terminator, then
// transfer any trailing DbgRecords that are still hanging around. This can
// occur when a block is optimised away and the terminator has been moved
// somewhere else.
which does not apply here since we still want to use Old BB (like adding a BranchInst with CreateBranch). And/or that those trailing DbgRecords should only exist if Old is empty since there is no other place to attach them.
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.
[nit] to be specific. If it doesn't crash anymore, we know it has been fixed.