LLVM
15.0.0git
|
#include "StatepointLowering.h"
#include "SelectionDAGBuilder.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/FunctionLoweringInfo.h"
#include "llvm/CodeGen/GCMetadata.h"
#include "llvm/CodeGen/ISDOpcodes.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/RuntimeLibcalls.h"
#include "llvm/CodeGen/SelectionDAG.h"
#include "llvm/CodeGen/SelectionDAGNodes.h"
#include "llvm/CodeGen/StackMaps.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetOpcodes.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/GCStrategy.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Statepoint.h"
#include "llvm/IR/Type.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/MachineValueType.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <iterator>
#include <tuple>
#include <utility>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "statepoint-lowering" |
Typedefs | |
typedef FunctionLoweringInfo::StatepointRelocationRecord | RecordType |
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 Optional< int > | findPreviousSpillSlot (const Value *Val, SelectionDAGBuilder &Builder, int LookUpDepth) |
Utility function for reservePreviousStackSlotForValue. More... | |
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. More... | |
static void | reservePreviousStackSlotForValue (const Value *IncomingValue, SelectionDAGBuilder &Builder) |
Try to find existing copies of the incoming values in stack slots used for statepoint spilling. More... | |
static std::pair< SDValue, SDNode * > | lowerCallFromStatepointLoweringInfo (SelectionDAGBuilder::StatepointLoweringInfo &SI, SelectionDAGBuilder &Builder, SmallVectorImpl< SDValue > &PendingExports) |
Extract call from statepoint, lower it and return pointer to the call node. More... | |
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. More... | |
static void | lowerIncomingStatepointValue (SDValue Incoming, bool RequireSpillSlot, SmallVectorImpl< SDValue > &Ops, SmallVectorImpl< MachineMemOperand * > &MemRefs, SelectionDAGBuilder &Builder) |
Lower a single value incoming to a statepoint node. More... | |
static bool | isGCValue (const Value *V, SelectionDAGBuilder &Builder) |
Return true if value V represents the GC value. More... | |
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. More... | |
static std::pair< const GCResultInst *, const GCResultInst * > | getGCResultLocality (const GCStatepointInst &S) |
Return two gc.results if present. More... | |
Variables | |
cl::opt< bool > | UseRegistersForDeoptValues ("use-registers-for-deopt-values", cl::Hidden, cl::init(false), cl::desc("Allow using registers for non pointer deopt args")) |
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")) |
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")) |
#define DEBUG_TYPE "statepoint-lowering" |
Definition at line 59 of file StatepointLowering.cpp.
Definition at line 79 of file StatepointLowering.cpp.
|
static |
Utility function for reservePreviousStackSlotForValue.
Tries to find stack slot index to which we have spilled value for previous statepoints. LookUpDepth specifies maximum DFS depth this function is allowed to look.
Definition at line 163 of file StatepointLowering.cpp.
References Builder, llvm::Optional< T >::hasValue(), llvm::None, and llvm::FunctionLoweringInfo::StatepointRelocationRecord::Spill.
Referenced by reservePreviousStackSlotForValue().
|
static |
Return two gc.results if present.
First result is a block local gc.result, second result is a non-block local gc.result. Corresponding entry will be nullptr if not present.
Definition at line 1018 of file StatepointLowering.cpp.
References S.
Referenced by llvm::SelectionDAGBuilder::LowerStatepoint().
|
static |
Definition at line 353 of file StatepointLowering.cpp.
References llvm::MachinePointerInfo::getFixedStack(), llvm::MachineFunction::getFrameInfo(), llvm::FrameIndexSDNode::getIndex(), llvm::MachineFunction::getMachineMemOperand(), llvm::MachineMemOperand::MOLoad, llvm::MachineMemOperand::MOStore, and llvm::MachineMemOperand::MOVolatile.
Referenced by llvm::MachineFunction::getMachineMemOperand(), lowerIncomingStatepointValue(), lowerStatepointMetaArgs(), and spillIncomingStatepointValue().
|
static |
Return true if value V represents the GC value.
The behavior is conservative in case it is not sure that value is not GC the function returns true.
Definition at line 497 of file StatepointLowering.cpp.
References Builder, and llvm::Value::getType().
Referenced by llvm::SelectionDAGBuilder::LowerStatepoint(), and lowerStatepointMetaArgs().
|
static |
Extract call from statepoint, lower it and return pointer to the call node.
Also update NodeMap so that getValue(statepoint) will reference lowered call result
Definition at line 316 of file StatepointLowering.cpp.
References assert(), Builder, llvm::ISD::CALLSEQ_END, llvm::ISD::CopyFromReg, llvm::SDValue::getNode(), llvm::SDNode::getOpcode(), llvm::SDNode::getOperand(), llvm::ISD::LOAD, and SI.
Referenced by llvm::SelectionDAGBuilder::LowerAsSTATEPOINT().
|
static |
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 419 of file StatepointLowering.cpp.
References assert(), Builder, getMachineMemOperand(), llvm::EVT::getSizeInBits(), llvm::SDValue::getValueType(), llvm::SDValue::isUndef(), llvm_unreachable, pushStackMapConstant(), spillIncomingStatepointValue(), and willLowerDirectly().
Referenced by lowerStatepointMetaArgs().
|
static |
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 515 of file StatepointLowering.cpp.
References llvm::SmallVectorImpl< T >::append(), Arg, assert(), llvm::sampleprof::Base, Builder, llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::count(), llvm::SmallSet< T, N, C >::count(), llvm::dbgs(), llvm::DeoptLiveIn, llvm::SDValue::dump(), getMachineMemOperand(), llvm::SDValue::getNode(), llvm::Type::getScalarType(), llvm::Value::getType(), llvm::SDValue::getValueType(), i, llvm::MVT::i64, llvm::SetVector< T, SmallVector< T, N >, SmallDenseSet< T, N > >::insert(), llvm::SmallSet< T, N, C >::insert(), isGCValue(), llvm::EVT::isVector(), LLVM_DEBUG, lowerIncomingStatepointValue(), MaxRegistersForGCPointers, pushStackMapConstant(), reservePreviousStackSlotForValue(), S, SI, llvm::SetVector< T, SmallVector< T, N >, SmallDenseSet< T, N > >::size(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::size(), UseRegistersForDeoptValues, UseRegistersForGCPointersInLandingPad, and willLowerDirectly().
Referenced by llvm::SelectionDAGBuilder::LowerAsSTATEPOINT().
|
static |
Definition at line 81 of file StatepointLowering.cpp.
References Builder, and llvm::MVT::i64.
Referenced by llvm::SelectionDAGBuilder::LowerAsSTATEPOINT(), lowerIncomingStatepointValue(), and lowerStatepointMetaArgs().
|
static |
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 266 of file StatepointLowering.cpp.
References assert(), Builder, llvm::find(), findPreviousSpillSlot(), llvm::SDValue::getNode(), Offset, and willLowerDirectly().
Referenced by lowerStatepointMetaArgs().
|
static |
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 371 of file StatepointLowering.cpp.
References assert(), Builder, llvm::MachinePointerInfo::getFixedStack(), getMachineMemOperand(), llvm::SDValue::getNode(), llvm::MachineFrameInfo::getObjectAlign(), llvm::MachineFrameInfo::getObjectSize(), llvm::SDValue::getValueSizeInBits(), llvm::SDValue::getValueType(), and llvm::MachineMemOperand::MOStore.
Referenced by lowerIncomingStatepointValue().
STATISTIC | ( | NumSlotsAllocatedForStatepoints | , |
"Number of stack slots allocated for statepoints" | |||
) |
STATISTIC | ( | StatepointMaxSlotsRequired | , |
"Maximum number of stack slots required for a singe statepoint" | |||
) |
|
static |
Return true if-and-only-if the given SDValue can be lowered as either a constant argument or a stack reference.
The key point is that the value doesn't need to be spilled or tracked as a vreg use.
Definition at line 244 of file StatepointLowering.cpp.
References llvm::EVT::getSizeInBits(), llvm::SDValue::getValueType(), and llvm::SDValue::isUndef().
Referenced by lowerIncomingStatepointValue(), lowerStatepointMetaArgs(), and reservePreviousStackSlotForValue().
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")) |
Referenced by lowerStatepointMetaArgs().
cl::opt<bool> UseRegistersForDeoptValues("use-registers-for-deopt-values", cl::Hidden, cl::init(false), cl::desc("Allow using registers for non pointer deopt args")) |
Referenced by lowerStatepointMetaArgs().