-
Notifications
You must be signed in to change notification settings - Fork 15.2k
LiveRangeShrink: Early exit when encountering a code motion barrier. #136806
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
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 |
|---|---|---|
|
|
@@ -95,14 +95,24 @@ static MachineInstr *FindDominatedInstruction(MachineInstr &New, | |
| return Old; | ||
| } | ||
|
|
||
| static bool isCodeMotionBarrier(MachineInstr &MI) { | ||
| return MI.hasUnmodeledSideEffects() && !MI.isPseudoProbe(); | ||
| } | ||
|
|
||
| /// Builds Instruction to its dominating order number map \p M by traversing | ||
| /// from instruction \p Start. | ||
| static void BuildInstOrderMap(MachineBasicBlock::iterator Start, | ||
| InstOrderMap &M) { | ||
| M.clear(); | ||
| unsigned i = 0; | ||
| for (MachineInstr &I : make_range(Start, Start->getParent()->end())) | ||
| bool SawStore = false; | ||
| for (MachineInstr &I : make_range(Start, Start->getParent()->end())) { | ||
| if (I.mayStore()) | ||
| SawStore = true; | ||
| if (!I.isSafeToMove(SawStore) && isCodeMotionBarrier(I)) | ||
|
||
| break; | ||
| M[&I] = i++; | ||
| } | ||
| } | ||
|
|
||
| bool LiveRangeShrink::runOnMachineFunction(MachineFunction &MF) { | ||
|
|
@@ -166,8 +176,7 @@ bool LiveRangeShrink::runOnMachineFunction(MachineFunction &MF) { | |
| // If MI has side effects, it should become a barrier for code motion. | ||
| // IOM is rebuild from the next instruction to prevent later | ||
| // instructions from being moved before this MI. | ||
| if (MI.hasUnmodeledSideEffects() && !MI.isPseudoProbe() && | ||
| Next != MBB.end()) { | ||
| if (isCodeMotionBarrier(MI) && Next != MBB.end()) { | ||
| BuildInstOrderMap(Next, IOM); | ||
| SawStore = false; | ||
| } | ||
|
|
||
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.
Document this? What is the exact problematic condition? We have several different barrier concepts already spread in MachineInstr and TargetInstrInfo, can we use one of those
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.
Added a comment that describes the situation to the best of my understanding. I don't think the existing ones can be used because the condition is specific to what this pass is doing.