-
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
Changes from 1 commit
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 |
|---|---|---|
|
|
@@ -2192,14 +2192,42 @@ findPrologueEndLoc(const MachineFunction *MF) { | |
| // better off synthesising an early prologue_end. | ||
| auto CurBlock = MF->begin(); | ||
| auto CurInst = CurBlock->begin(); | ||
| while (true) { | ||
|
|
||
| // Find the initial instruction, we're guaranteed one by the caller. | ||
| while (CurBlock->empty()) | ||
| CurInst = (++CurBlock)->begin(); | ||
|
|
||
| // Helper function for stepping through the initial sequence of | ||
| // unconditionally executed instructions. The optimiser will also chuck in | ||
| // sequences of empty blocks alas. | ||
|
||
| 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. | ||
| if (CurInst == CurBlock->end()) { | ||
| do { | ||
| ++CurBlock; | ||
| CurInst = CurBlock->begin(); | ||
| continue; | ||
| } | ||
| 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 +2244,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 | ||
|
|
||
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)