-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[DebugInfo] Handle trailing empty blocks when seeking prologue_end spot #117320
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2192,14 +2192,45 @@ findPrologueEndLoc(const MachineFunction *MF) { | |
| // better off synthesising an early prologue_end. | ||
| auto CurBlock = MF->begin(); | ||
| auto CurInst = CurBlock->begin(); | ||
| while (true) { | ||
| // Skip empty blocks, in rare cases the entry can be empty. | ||
| if (CurInst == CurBlock->end()) { | ||
| ++CurBlock; | ||
| CurInst = CurBlock->begin(); | ||
| continue; | ||
|
|
||
| // Find the initial instruction, we're guaranteed one by the caller, but not | ||
| // which block it's in. | ||
| while (CurBlock->empty()) | ||
| CurInst = (++CurBlock)->begin(); | ||
| assert(CurInst != CurBlock->end()); | ||
|
|
||
| // Helper function for stepping through the initial sequence of | ||
| // unconditionally executed instructions. | ||
| auto getNextInst = [&CurBlock, &CurInst, MF]() -> bool { | ||
| // We've reached the end of the block. Did we just look at a terminator? | ||
| if (CurInst->isTerminator()) { | ||
| // Some kind of "real" control flow is occurring. At the very least | ||
| // we would have to start exploring the CFG, a good signal that the | ||
| // prologue is over. | ||
| return false; | ||
| } | ||
|
|
||
| // If we've already fallen through into a loop, don't fall through | ||
| // further, use a backup-location. | ||
| if (CurBlock->pred_size() > 1) | ||
| return false; | ||
|
|
||
| // Fall-through from entry to the next block. This is common at -O0 when | ||
| // there's no initialisation in the function. Bail if we're also at the | ||
| // end of the function, or the remaining blocks have no instructions. | ||
| // Skip empty blocks, in rare cases the entry can be empty, and | ||
| // other optimisations may add empty blocks that the control flow falls | ||
| // through. | ||
| do { | ||
| ++CurBlock; | ||
| if (CurBlock == MF->end()) | ||
| return false; | ||
| } while (CurBlock->empty()); | ||
| CurInst = CurBlock->begin(); | ||
| return true; | ||
| }; | ||
|
|
||
| while (true) { | ||
| // Check whether this non-meta instruction a good position for prologue_end. | ||
| if (!CurInst->isMetaInstruction()) { | ||
| auto FoundInst = ExamineInst(*CurInst); | ||
|
|
@@ -2216,25 +2247,8 @@ findPrologueEndLoc(const MachineFunction *MF) { | |
| continue; | ||
| } | ||
|
|
||
| // We've reached the end of the block. Did we just look at a terminator? | ||
| if (CurInst->isTerminator()) { | ||
| // Some kind of "real" control flow is occurring. At the very least | ||
| // we would have to start exploring the CFG, a good signal that the | ||
| // prologue is over. | ||
| break; | ||
| } | ||
|
|
||
| // If we've already fallen through into a loop, don't fall through | ||
| // further, use a backup-location. | ||
| if (CurBlock->pred_size() > 1) | ||
| break; | ||
|
|
||
| // Fall-through from entry to the next block. This is common at -O0 when | ||
| // there's no initialisation in the function. Bail if we're also at the | ||
| // end of the function. | ||
| if (++CurBlock == MF->end()) | ||
| if (!getNextInst()) | ||
|
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. I get what this is doing but from the name |
||
| break; | ||
| CurInst = CurBlock->begin(); | ||
| } | ||
|
|
||
| // We couldn't find any source-location, suggesting all meaningful information | ||
|
|
||
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
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.
// Find the initial instruction, we're guaranteed one by the caller.Can we assertCurInst != CurBlock->end()here to check that?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 suppose so, yeah -- you mean immediately after the loop terminates, yes? (I'll send that up in the patch to demonstrate)