|
LLVM
3.7.0
|
#include "StatepointLowering.h"#include "SelectionDAGBuilder.h"#include "llvm/ADT/SmallSet.h"#include "llvm/ADT/Statistic.h"#include "llvm/CodeGen/FunctionLoweringInfo.h"#include "llvm/CodeGen/GCMetadata.h"#include "llvm/CodeGen/GCStrategy.h"#include "llvm/CodeGen/SelectionDAG.h"#include "llvm/CodeGen/StackMaps.h"#include "llvm/IR/CallingConv.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/Intrinsics.h"#include "llvm/IR/Statepoint.h"#include "llvm/Target/TargetLowering.h"#include <algorithm>Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "statepoint-lowering" |
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 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 void | removeDuplicatesGCPtrs (SmallVectorImpl< const Value * > &Bases, SmallVectorImpl< const Value * > &Ptrs, SmallVectorImpl< const Value * > &Relocs, SelectionDAGBuilder &Builder) |
| Remove any duplicate (as SDValues) from the derived pointer pairs. More... | |
| static SDNode * | lowerCallFromStatepoint (ImmutableStatepoint ISP, MachineBasicBlock *LandingPad, SelectionDAGBuilder &Builder, SmallVectorImpl< SDValue > &PendingExports) |
| Extract call from statepoint, lower it and return pointer to the call node. More... | |
| static void | getIncomingStatepointGCValues (SmallVectorImpl< const Value * > &Bases, SmallVectorImpl< const Value * > &Ptrs, SmallVectorImpl< const Value * > &Relocs, ImmutableStatepoint StatepointSite, SelectionDAGBuilder &Builder) |
| Callect all gc pointers coming into statepoint intrinsic, clean them up, and return two arrays: Bases - base pointers incoming to this statepoint Ptrs - derived pointers incoming to this statepoint Relocs - the gc_relocate corresponding to each base/ptr pair Elements of this arrays should be in one-to-one correspondence with each other i.e Bases[i], Ptrs[i] are from the same gcrelocate call. More... | |
| static std::pair< SDValue, SDValue > | spillIncomingStatepointValue (SDValue Incoming, SDValue Chain, SelectionDAGBuilder &Builder) |
| Spill a value incoming to the statepoint. More... | |
| static void | lowerIncomingStatepointValue (SDValue Incoming, SmallVectorImpl< SDValue > &Ops, SelectionDAGBuilder &Builder) |
| Lower a single value incoming to a statepoint node. More... | |
| static void | lowerStatepointMetaArgs (SmallVectorImpl< SDValue > &Ops, ImmutableStatepoint StatepointSite, SelectionDAGBuilder &Builder) |
| Lower deopt state and gc pointer arguments of the statepoint. More... | |
| #define DEBUG_TYPE "statepoint-lowering" |
Definition at line 33 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 119 of file StatepointLowering.cpp.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::SelectionDAGBuilder::FuncInfo, llvm::GCRelocateOperands::getDerivedPtr(), llvm::GCRelocateOperands::getStatepoint(), llvm::Optional< T >::hasValue(), llvm::isGCRelocate(), llvm::None, and llvm::FunctionLoweringInfo::StatepointRelocatedValues.
Referenced by reservePreviousStackSlotForValue().
|
static |
Callect all gc pointers coming into statepoint intrinsic, clean them up, and return two arrays: Bases - base pointers incoming to this statepoint Ptrs - derived pointers incoming to this statepoint Relocs - the gc_relocate corresponding to each base/ptr pair Elements of this arrays should be in one-to-one correspondence with each other i.e Bases[i], Ptrs[i] are from the same gcrelocate call.
Definition at line 371 of file StatepointLowering.cpp.
References llvm::StatepointBase< FunTy, InstructionTy, ValueTy, CallSiteTy >::getRelocates(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), removeDuplicatesGCPtrs(), and llvm::SmallVectorTemplateCommon< T >::size().
Referenced by 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 286 of file StatepointLowering.cpp.
References llvm::CallingConv::AnyReg, llvm::StatepointBase< const Function, const Instruction, const Value, ImmutableCallSite >::CallArgsBeginPos, llvm::ISD::CALLSEQ_END, llvm::ISD::CopyFromReg, llvm::FunctionLoweringInfo::CreateRegs(), llvm::CS, llvm::SelectionDAGBuilder::DAG, llvm::SelectionDAGBuilder::FuncInfo, llvm::StatepointBase< FunTy, InstructionTy, ValueTy, CallSiteTy >::getActualReturnType(), llvm::StatepointBase< FunTy, InstructionTy, ValueTy, CallSiteTy >::getCalledValue(), llvm::StatepointBase< FunTy, InstructionTy, ValueTy, CallSiteTy >::getCallSite(), llvm::SelectionDAG::getContext(), llvm::SelectionDAGBuilder::getCurSDLoc(), llvm::SelectionDAG::getDataLayout(), llvm::SelectionDAG::getEntryNode(), llvm::SelectionDAG::getIntPtrConstant(), llvm::SDValue::getNode(), llvm::StatepointBase< FunTy, InstructionTy, ValueTy, CallSiteTy >::getNumCallArgs(), llvm::SDNode::getOpcode(), llvm::SDNode::getOperand(), llvm::SelectionDAG::getTargetLoweringInfo(), llvm::SelectionDAGBuilder::getValue(), llvm::Type::isVoidTy(), llvm::ISD::LOAD, llvm::SelectionDAGBuilder::lowerCallOperands(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::SelectionDAGBuilder::setValue(), and llvm::FunctionLoweringInfo::ValueMap.
Referenced by llvm::SelectionDAGBuilder::LowerStatepoint().
|
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 427 of file StatepointLowering.cpp.
References llvm::SelectionDAGBuilder::DAG, llvm::SelectionDAGBuilder::getRoot(), llvm::SelectionDAG::getTargetFrameIndex(), llvm::SDValue::getValueType(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), pushStackMapConstant(), llvm::SelectionDAG::setRoot(), and spillIncomingStatepointValue().
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 467 of file StatepointLowering.cpp.
References llvm::SelectionDAGBuilder::DAG, llvm::SelectionDAGBuilder::ExportFromCurrentBlock(), llvm::SelectionDAGBuilder::FuncInfo, llvm::StatepointBase< FunTy, InstructionTy, ValueTy, CallSiteTy >::gc_args(), llvm::StatepointBase< FunTy, InstructionTy, ValueTy, CallSiteTy >::getCallSite(), getIncomingStatepointGCValues(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getInstruction(), llvm::StatepointLoweringState::getLocation(), llvm::SDValue::getNode(), llvm::StatepointBase< FunTy, InstructionTy, ValueTy, CallSiteTy >::getNumTotalVMSArgs(), llvm::StatepointBase< FunTy, InstructionTy, ValueTy, CallSiteTy >::getRelocates(), llvm::GCFunctionInfo::getStrategy(), llvm::SelectionDAG::getTargetFrameIndex(), llvm::SelectionDAGBuilder::getValue(), llvm::SDValue::getValueType(), llvm::SelectionDAGBuilder::GFI, llvm::GCStrategy::isGCManagedPointer(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::isInvoke(), lowerIncomingStatepointValue(), llvm::None, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), pushStackMapConstant(), reservePreviousStackSlotForValue(), llvm::SelectionDAGBuilder::StatepointLowering, llvm::FunctionLoweringInfo::StatepointRelocatedValues, llvm::StatepointBase< FunTy, InstructionTy, ValueTy, CallSiteTy >::vm_state_args(), llvm::StatepointBase< FunTy, InstructionTy, ValueTy, CallSiteTy >::vm_state_begin(), and llvm::StatepointBase< FunTy, InstructionTy, ValueTy, CallSiteTy >::vm_state_end().
Referenced by llvm::SelectionDAGBuilder::LowerStatepoint().
|
static |
Definition at line 41 of file StatepointLowering.cpp.
References llvm::StackMaps::ConstantOp, llvm::SelectionDAGBuilder::DAG, llvm::SelectionDAGBuilder::getCurSDLoc(), llvm::SelectionDAG::getTargetConstant(), llvm::MVT::i64, and llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back().
Referenced by lowerIncomingStatepointValue(), llvm::SelectionDAGBuilder::LowerStatepoint(), and lowerStatepointMetaArgs().
|
static |
Remove any duplicate (as SDValues) from the derived pointer pairs.
This is not required for correctness. It's purpose is to reduce the size of StackMap section. It has no effect on the number of spill slots required or the actual lowering.
Definition at line 253 of file StatepointLowering.cpp.
References llvm::SmallSet< T, N, C >::count(), llvm::SelectionDAGBuilder::getValue(), llvm::SmallSet< T, N, C >::insert(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), and llvm::SmallVectorTemplateCommon< T >::size().
Referenced by getIncomingStatepointGCValues().
|
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 resuffle values on the stack between calls.
Definition at line 201 of file StatepointLowering.cpp.
References llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::SelectionDAGBuilder::DAG, llvm::SmallVectorTemplateCommon< T, typename >::end(), findPreviousSpillSlot(), llvm::SelectionDAGBuilder::FuncInfo, llvm::StatepointLoweringState::getLocation(), llvm::SDValue::getNode(), llvm::SelectionDAG::getTargetFrameIndex(), llvm::SelectionDAGBuilder::getValue(), llvm::SDValue::getValueType(), llvm::Optional< T >::hasValue(), llvm::StatepointLoweringState::isStackSlotAllocated(), llvm::StatepointLoweringState::reserveStackSlot(), llvm::StatepointLoweringState::setLocation(), llvm::SelectionDAGBuilder::StatepointLowering, and llvm::FunctionLoweringInfo::StatepointStackSlots.
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 397 of file StatepointLowering.cpp.
References llvm::StatepointLoweringState::allocateStackSlot(), llvm::SelectionDAGBuilder::DAG, llvm::SelectionDAGBuilder::getCurSDLoc(), llvm::MachinePointerInfo::getFixedStack(), llvm::StatepointLoweringState::getLocation(), llvm::SDValue::getNode(), llvm::SelectionDAG::getStore(), llvm::SelectionDAG::getTargetFrameIndex(), llvm::SDValue::getValueType(), llvm::StatepointLoweringState::setLocation(), and llvm::SelectionDAGBuilder::StatepointLowering.
Referenced by lowerIncomingStatepointValue().
| STATISTIC | ( | NumSlotsAllocatedForStatepoints | , |
| "Number of stack slots allocated for statepoints" | |||
| ) |
| STATISTIC | ( | NumOfStatepoints | , |
| "Number of statepoint nodes encountered" | |||
| ) |
1.8.6