LLVM: lib/CodeGen/SelectionDAG/StatepointLowering.cpp File Reference (original) (raw)

Go to the source code of this file.

Functions
STATISTIC (NumSlotsAllocatedForStatepoints, "Number of stack slots allocated for statepoints")
STATISTIC (NumOfStatepoints, "Number of statepoint nodes encountered")
STATISTIC (StatepointMaxSlotsRequired, "Maximum number of stack slots required for a singe statepoint")
static void pushStackMapConstant (SmallVectorImpl< SDValue > &Ops, SelectionDAGBuilder &Builder, uint64_t Value)
static std::optional< int > findPreviousSpillSlot (const Value *Val, SelectionDAGBuilder &Builder, int LookUpDepth)
Utility function for reservePreviousStackSlotForValue.
static bool willLowerDirectly (SDValue Incoming)
Return true if-and-only-if the given SDValue can be lowered as either a constant argument or a stack reference.
static void reservePreviousStackSlotForValue (const Value *IncomingValue, SelectionDAGBuilder &Builder)
Try to find existing copies of the incoming values in stack slots used for statepoint spilling.
static std::pair< SDValue, SDNode * > lowerCallFromStatepointLoweringInfo (SelectionDAGBuilder::StatepointLoweringInfo &SI, SelectionDAGBuilder &Builder)
Extract call from statepoint, lower it and return pointer to the call node.
static MachineMemOperand * getMachineMemOperand (MachineFunction &MF, FrameIndexSDNode &FI)
static std::tuple< SDValue, SDValue, MachineMemOperand * > spillIncomingStatepointValue (SDValue Incoming, SDValue Chain, SelectionDAGBuilder &Builder)
Spill a value incoming to the statepoint.
static void lowerIncomingStatepointValue (SDValue Incoming, bool RequireSpillSlot, SmallVectorImpl< SDValue > &Ops, SmallVectorImpl< MachineMemOperand * > &MemRefs, SelectionDAGBuilder &Builder)
Lower a single value incoming to a statepoint node.
static bool isGCValue (const Value *V, SelectionDAGBuilder &Builder)
Return true if value V represents the GC value.
static void lowerStatepointMetaArgs (SmallVectorImpl< SDValue > &Ops, SmallVectorImpl< MachineMemOperand * > &MemRefs, SmallVectorImpl< SDValue > &GCPtrs, DenseMap< SDValue, int > &LowerAsVReg, SelectionDAGBuilder::StatepointLoweringInfo &SI, SelectionDAGBuilder &Builder)
Lower deopt state and gc pointer arguments of the statepoint.
static std::pair< const GCResultInst *, const GCResultInst * > getGCResultLocality (const GCStatepointInst &S)
Return two gc.results if present.
Variables
static cl::opt< bool > UseRegistersForDeoptValues ("use-registers-for-deopt-values", cl::Hidden, cl::init(false), cl::desc("Allow using registers for non pointer deopt args"))
static cl::opt< bool > UseRegistersForGCPointersInLandingPad ("use-registers-for-gc-values-in-landing-pad", cl::Hidden, cl::init(false), cl::desc("Allow using registers for gc pointer in landing pad"))
static cl::opt< unsigned > MaxRegistersForGCPointers ("max-registers-for-gc-values", cl::Hidden, cl::init(0), cl::desc("Max number of VRegs allowed to pass GC pointer meta args in"))

DEBUG_TYPE

#define DEBUG_TYPE "statepoint-lowering"

RecordType

findPreviousSpillSlot()

getGCResultLocality()

getMachineMemOperand()

isGCValue()

lowerCallFromStatepointLoweringInfo()

lowerIncomingStatepointValue()

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.

Definition at line 424 of file StatepointLowering.cpp.

References assert(), llvm::CallingConv::C, llvm::SelectionDAGBuilder::DAG, llvm::SelectionDAGBuilder::getFrameIndexTy(), llvm::SelectionDAG::getMachineFunction(), getMachineMemOperand(), llvm::SelectionDAGBuilder::getRoot(), llvm::SelectionDAG::getTargetFrameIndex(), llvm_unreachable, llvm::SmallVectorTemplateBase< T, bool >::push_back(), pushStackMapConstant(), llvm::SelectionDAG::setRoot(), spillIncomingStatepointValue(), and willLowerDirectly().

Referenced by lowerStatepointMetaArgs().

lowerStatepointMetaArgs()

Lower deopt state and gc pointer arguments of the statepoint.

The actual lowering is described in lowerIncomingStatepointValue. This function is responsible for lowering everything in the right position and playing some tricks to avoid redundant stack manipulation where possible. On completion, 'Ops' will contain ready to use operands for machine code statepoint. The chain nodes will have already been created and the DAG root will be set to the last value spilled (if any were).

Definition at line 520 of file StatepointLowering.cpp.

References llvm::SmallVectorImpl< T >::append(), assert(), llvm::sampleprof::Base, llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::SmallSet< T, N, C >::count(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::count(), llvm::SelectionDAGBuilder::DAG, llvm::dbgs(), llvm::DeoptLiveIn, llvm::SDValue::dump(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::SelectionDAGBuilder::FuncInfo, llvm::FunctionLoweringInfo::getArgumentFrameIndex(), llvm::SelectionDAGBuilder::getCurSDLoc(), llvm::SelectionDAG::getFrameIndex(), llvm::SelectionDAGBuilder::getFrameIndexTy(), llvm::SelectionDAG::getMachineFunction(), getMachineMemOperand(), llvm::SelectionDAG::getTargetConstant(), llvm::SelectionDAG::getTargetFrameIndex(), llvm::SelectionDAG::getTargetLoweringInfo(), llvm::SelectionDAGBuilder::getValue(), llvm::SDValue::getValueType(), llvm::SmallSet< T, N, C >::insert(), llvm::SetVector< T, Vector, Set, N >::insert(), isGCValue(), llvm::TargetLoweringBase::isTypeLegal(), llvm::EVT::isVector(), LLVM_DEBUG, lowerIncomingStatepointValue(), MaxRegistersForGCPointers, llvm::SmallVectorTemplateBase< T, bool >::push_back(), pushStackMapConstant(), reservePreviousStackSlotForValue(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::size(), llvm::SetVector< T, Vector, Set, N >::size(), llvm::SmallVectorBase< Size_T >::size(), llvm::SetVector< T, Vector, Set, N >::takeVector(), UseRegistersForDeoptValues, UseRegistersForGCPointersInLandingPad, and willLowerDirectly().

Referenced by llvm::SelectionDAGBuilder::LowerAsSTATEPOINT().

pushStackMapConstant()

reservePreviousStackSlotForValue()

Try to find existing copies of the incoming values in stack slots used for statepoint spilling.

If we can find a spill slot for the incoming value, mark that slot as allocated, and reuse the same slot for this safepoint. This helps to avoid series of loads and stores that only serve to reshuffle values on the stack between calls.

Definition at line 268 of file StatepointLowering.cpp.

References assert(), llvm::SelectionDAGBuilder::DAG, llvm::find(), findPreviousSpillSlot(), llvm::SelectionDAGBuilder::FuncInfo, llvm::SelectionDAGBuilder::getFrameIndexTy(), llvm::StatepointLoweringState::getLocation(), llvm::SDValue::getNode(), llvm::SelectionDAG::getTargetFrameIndex(), llvm::SelectionDAGBuilder::getValue(), llvm::StatepointLoweringState::isStackSlotAllocated(), llvm::Offset, llvm::StatepointLoweringState::reserveStackSlot(), llvm::StatepointLoweringState::setLocation(), llvm::SelectionDAGBuilder::StatepointLowering, llvm::FunctionLoweringInfo::StatepointStackSlots, and willLowerDirectly().

Referenced by lowerStatepointMetaArgs().

spillIncomingStatepointValue()

Spill a value incoming to the statepoint.

It might be either part of vmstate or gcstate. In both cases unconditionally spill it on the stack unless it is a null constant. Return pair with first element being frame index containing saved value and second element with outgoing chain from the emitted store

Definition at line 376 of file StatepointLowering.cpp.

References llvm::StatepointLoweringState::allocateStackSlot(), assert(), llvm::SelectionDAGBuilder::DAG, llvm::SelectionDAGBuilder::getCurSDLoc(), llvm::MachinePointerInfo::getFixedStack(), llvm::SelectionDAGBuilder::getFrameIndexTy(), llvm::MachineFunction::getFrameInfo(), llvm::StatepointLoweringState::getLocation(), llvm::SelectionDAG::getMachineFunction(), getMachineMemOperand(), llvm::SDValue::getNode(), llvm::MachineFrameInfo::getObjectAlign(), llvm::MachineFrameInfo::getObjectSize(), llvm::SelectionDAG::getStore(), llvm::SelectionDAG::getTargetFrameIndex(), llvm::MachineMemOperand::MOStore, llvm::StatepointLoweringState::setLocation(), and llvm::SelectionDAGBuilder::StatepointLowering.

Referenced by lowerIncomingStatepointValue().

STATISTIC() [1/3]

STATISTIC ( NumOfStatepoints ,
"Number of statepoint nodes encountered"
)

STATISTIC() [2/3]

STATISTIC ( NumSlotsAllocatedForStatepoints ,
"Number of stack slots allocated for statepoints"
)

STATISTIC() [3/3]

STATISTIC ( StatepointMaxSlotsRequired ,
"Maximum number of stack slots required for a singe statepoint"
)

willLowerDirectly()

static bool willLowerDirectly ( SDValue Incoming) static

MaxRegistersForGCPointers

cl::opt< unsigned > MaxRegistersForGCPointers("max-registers-for-gc-values", cl::Hidden, cl::init(0), cl::desc("Max number of VRegs allowed to pass GC pointer meta args in")) ( "max-registers-for-gc-values" , cl::Hidden , cl::init(0) , cl::desc("Max number of VRegs allowed to pass GC pointer meta args in") ) static

UseRegistersForDeoptValues

cl::opt< bool > UseRegistersForDeoptValues("use-registers-for-deopt-values", cl::Hidden, cl::init(false), cl::desc("Allow using registers for non pointer deopt args")) ( "use-registers-for-deopt-values" , cl::Hidden , cl::init(false) , cl::desc("Allow using registers for non pointer deopt args") ) static

UseRegistersForGCPointersInLandingPad

cl::opt< bool > UseRegistersForGCPointersInLandingPad("use-registers-for-gc-values-in-landing-pad", cl::Hidden, cl::init(false), cl::desc("Allow using registers for gc pointer in landing pad")) ( "use-registers-for-gc-values-in-landing-pad" , cl::Hidden , cl::init(false) , cl::desc("Allow using registers for gc pointer in landing pad") ) static