From: Serguei Katkov Date: Tue, 7 Apr 2020 04:04:19 +0000 (+0700) Subject: [DAG] Consolidate require spill slot logic in lambda. NFC. X-Git-Tag: llvmorg-12-init~9833 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b7e3759e177ef2ddc5adaf7951bb6fba1e5533fe;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp index 8cb6090..ffe3563 100644 --- a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp @@ -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 &Ops, - SmallVectorImpl &MemRefs, - SelectionDAGBuilder &Builder) { +static void +lowerIncomingStatepointValue(SDValue Incoming, bool RequireSpillSlot, + SmallVectorImpl &Ops, + SmallVectorImpl &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 &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 &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 &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