Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions llvm/lib/CodeGen/LiveRangeShrink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,24 @@ static MachineInstr *FindDominatedInstruction(MachineInstr &New,
return Old;
}

static bool isCodeMotionBarrier(MachineInstr &MI) {
return MI.hasUnmodeledSideEffects() && !MI.isPseudoProbe();
}
Comment on lines +102 to +104
Copy link
Contributor

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

Copy link
Contributor Author

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.


/// 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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MI.hasUnmodeledSideEffects() is redundant with the isSafeToMove check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, updated this code to only call one.

While reading the code I observed that the code to update SawStore in this pass is redundant with what isSafeToMove is doing, so I removed it.

break;
M[&I] = i++;
}
}

bool LiveRangeShrink::runOnMachineFunction(MachineFunction &MF) {
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,9 @@ static void AddNodeIDCustom(FoldingSetNodeID &ID, const SDNode *N) {
case ISD::INTRINSIC_W_CHAIN:
// Handled by MemIntrinsicSDNode check after the switch.
break;
case ISD::MDNODE_SDNODE:
ID.AddPointer(cast<MDNodeSDNode>(N)->getMD());
break;
} // end switch (N->getOpcode())

// MemIntrinsic nodes could also have subclass data, address spaces, and flags
Expand Down
Loading