1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

[DAG] Consolidate require spill slot logic in lambda. NFC.

Move the logic whether lowering of deopt value requires a spill slot in
a separate lambda.

Reviewers: reames, dantrushin
Reviewed By: dantrushin
Subscribers: hiraditya, llvm-commits
Differential Revision: https://reviews.llvm.org/D77629
This commit is contained in:
Serguei Katkov 2020-04-07 11:04:19 +07:00
parent 41cc727b1c
commit 2f91488468

View File

@ -372,10 +372,11 @@ spillIncomingStatepointValue(SDValue Incoming, SDValue Chain,
/// Lower a single value incoming to a statepoint node. This value can be
/// either a deopt value or a gc value, the handling is the same. We special
/// case constants and allocas, then fall back to spilling if required.
static void lowerIncomingStatepointValue(SDValue Incoming, bool LiveInOnly,
SmallVectorImpl<SDValue> &Ops,
SmallVectorImpl<MachineMemOperand*> &MemRefs,
SelectionDAGBuilder &Builder) {
static void
lowerIncomingStatepointValue(SDValue Incoming, bool RequireSpillSlot,
SmallVectorImpl<SDValue> &Ops,
SmallVectorImpl<MachineMemOperand *> &MemRefs,
SelectionDAGBuilder &Builder) {
// Note: We know all of these spills are independent, but don't bother to
// exploit that chain wise. DAGCombine will happily do so as needed, so
// doing it here would be a small compile time win at most.
@ -401,8 +402,8 @@ static void lowerIncomingStatepointValue(SDValue Incoming, bool LiveInOnly,
auto &MF = Builder.DAG.getMachineFunction();
auto *MMO = getMachineMemOperand(MF, *FI);
MemRefs.push_back(MMO);
} else if (LiveInOnly) {
} else if (!RequireSpillSlot) {
// If this value is live in (not live-on-return, or live-through), we can
// treat it the same way patchpoint treats it's "live in" values. We'll
// end up folding some of these into stack references, but they'll be
@ -492,13 +493,17 @@ lowerStatepointMetaArgs(SmallVectorImpl<SDValue> &Ops,
return true; // conservative
};
auto requireSpillSlot = [&](const Value *V) {
return !LiveInDeopt || isGCValue(V);
};
// Before we actually start lowering (and allocating spill slots for values),
// reserve any stack slots which we judge to be profitable to reuse for a
// particular value. This is purely an optimization over the code below and
// doesn't change semantics at all. It is important for performance that we
// reserve slots for both deopt and gc values before lowering either.
for (const Value *V : SI.DeoptState) {
if (!LiveInDeopt || isGCValue(V))
if (requireSpillSlot(V))
reservePreviousStackSlotForValue(V, Builder);
}
for (unsigned i = 0; i < SI.Bases.size(); ++i) {
@ -525,8 +530,8 @@ lowerStatepointMetaArgs(SmallVectorImpl<SDValue> &Ops,
}
if (!Incoming.getNode())
Incoming = Builder.getValue(V);
const bool LiveInValue = LiveInDeopt && !isGCValue(V);
lowerIncomingStatepointValue(Incoming, LiveInValue, Ops, MemRefs, Builder);
lowerIncomingStatepointValue(Incoming, requireSpillSlot(V), Ops, MemRefs,
Builder);
}
// Finally, go ahead and lower all the gc arguments. There's no prefixed
@ -536,12 +541,14 @@ lowerStatepointMetaArgs(SmallVectorImpl<SDValue> &Ops,
// (base[0], ptr[0], base[1], ptr[1], ...)
for (unsigned i = 0; i < SI.Bases.size(); ++i) {
const Value *Base = SI.Bases[i];
lowerIncomingStatepointValue(Builder.getValue(Base), /*LiveInOnly*/ false,
Ops, MemRefs, Builder);
lowerIncomingStatepointValue(Builder.getValue(Base),
/*RequireSpillSlot*/ true, Ops, MemRefs,
Builder);
const Value *Ptr = SI.Ptrs[i];
lowerIncomingStatepointValue(Builder.getValue(Ptr), /*LiveInOnly*/ false,
Ops, MemRefs, Builder);
lowerIncomingStatepointValue(Builder.getValue(Ptr),
/*RequireSpillSlot*/ true, Ops, MemRefs,
Builder);
}
// If there are any explicit spill slots passed to the statepoint, record