LLVM  6.0.0svn
Macros | Functions
StatepointLowering.cpp File Reference
#include "StatepointLowering.h"
#include "SelectionDAGBuilder.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/FunctionLoweringInfo.h"
#include "llvm/CodeGen/GCMetadata.h"
#include "llvm/CodeGen/GCStrategy.h"
#include "llvm/CodeGen/ISDOpcodes.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/MachineValueType.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/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/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <iterator>
#include <tuple>
#include <utility>
Include dependency graph for StatepointLowering.cpp:

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 removeDuplicateGCPtrs (SmallVectorImpl< const Value *> &Bases, SmallVectorImpl< const Value *> &Ptrs, SmallVectorImpl< const GCRelocateInst *> &Relocs, SelectionDAGBuilder &Builder, FunctionLoweringInfo::StatepointSpillMap &SSM)
 Remove any duplicate (as SDValues) from the derived pointer pairs. 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 std::pair< SDValue, SDValuespillIncomingStatepointValue (SDValue Incoming, SDValue Chain, SelectionDAGBuilder &Builder)
 Spill a value incoming to the statepoint. More...
 
static void lowerIncomingStatepointValue (SDValue Incoming, bool LiveInOnly, SmallVectorImpl< SDValue > &Ops, SelectionDAGBuilder &Builder)
 Lower a single value incoming to a statepoint node. More...
 
static void lowerStatepointMetaArgs (SmallVectorImpl< SDValue > &Ops, SelectionDAGBuilder::StatepointLoweringInfo &SI, SelectionDAGBuilder &Builder)
 Lower deopt state and gc pointer arguments of the statepoint. More...
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "statepoint-lowering"

Definition at line 57 of file StatepointLowering.cpp.

Function Documentation

◆ findPreviousSpillSlot()

static Optional<int> findPreviousSpillSlot ( const Value Val,
SelectionDAGBuilder Builder,
int  LookUpDepth 
)
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 145 of file StatepointLowering.cpp.

References llvm::SelectionDAGBuilder::FuncInfo, llvm::Optional< T >::hasValue(), llvm::None, and llvm::FunctionLoweringInfo::StatepointSpillMaps.

Referenced by reservePreviousStackSlotForValue().

◆ lowerCallFromStatepointLoweringInfo()

static std::pair<SDValue, SDNode *> lowerCallFromStatepointLoweringInfo ( SelectionDAGBuilder::StatepointLoweringInfo SI,
SelectionDAGBuilder Builder,
SmallVectorImpl< SDValue > &  PendingExports 
)
static

◆ lowerIncomingStatepointValue()

static void lowerIncomingStatepointValue ( SDValue  Incoming,
bool  LiveInOnly,
SmallVectorImpl< SDValue > &  Ops,
SelectionDAGBuilder Builder 
)
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 399 of file StatepointLowering.cpp.

References assert(), C, llvm::SelectionDAGBuilder::DAG, llvm::SelectionDAGBuilder::getFrameIndexTy(), 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().

◆ lowerStatepointMetaArgs()

static void lowerStatepointMetaArgs ( SmallVectorImpl< SDValue > &  Ops,
SelectionDAGBuilder::StatepointLoweringInfo SI,
SelectionDAGBuilder Builder 
)
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 451 of file StatepointLowering.cpp.

References assert(), llvm::SelectionDAGBuilder::StatepointLoweringInfo::Bases, llvm::SelectionDAGBuilder::DAG, llvm::DeoptLiveIn, llvm::SelectionDAGBuilder::StatepointLoweringInfo::DeoptState, llvm::SelectionDAGBuilder::ExportFromCurrentBlock(), llvm::SelectionDAGBuilder::FuncInfo, llvm::SelectionDAGBuilder::StatepointLoweringInfo::GCArgs, llvm::SelectionDAGBuilder::StatepointLoweringInfo::GCRelocates, llvm::GCRelocateInst::getDerivedPtr(), llvm::SelectionDAGBuilder::getFrameIndexTy(), llvm::StatepointLoweringState::getLocation(), llvm::SDValue::getNode(), llvm::Instruction::getParent(), llvm::Type::getScalarType(), llvm::SelectionDAG::getTargetFrameIndex(), llvm::Value::getType(), llvm::SelectionDAGBuilder::getValue(), llvm::SDValue::getValueType(), llvm::SelectionDAGBuilder::GFI, llvm::is_contained(), llvm::GCStrategy::isGCManagedPointer(), lowerIncomingStatepointValue(), llvm::None, llvm::SelectionDAGBuilder::StatepointLoweringInfo::Ptrs, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), pushStackMapConstant(), reservePreviousStackSlotForValue(), llvm::SelectionDAGBuilder::StatepointLoweringInfo::StatepointFlags, llvm::SelectionDAGBuilder::StatepointLoweringInfo::StatepointInstr, llvm::SelectionDAGBuilder::StatepointLowering, and llvm::FunctionLoweringInfo::StatepointSpillMaps.

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

◆ pushStackMapConstant()

static void pushStackMapConstant ( SmallVectorImpl< SDValue > &  Ops,
SelectionDAGBuilder Builder,
uint64_t  Value 
)
static

◆ removeDuplicateGCPtrs()

static void removeDuplicateGCPtrs ( SmallVectorImpl< const Value *> &  Bases,
SmallVectorImpl< const Value *> &  Ptrs,
SmallVectorImpl< const GCRelocateInst *> &  Relocs,
SelectionDAGBuilder Builder,
FunctionLoweringInfo::StatepointSpillMap SSM 
)
static

◆ reservePreviousStackSlotForValue()

static void reservePreviousStackSlotForValue ( const Value IncomingValue,
SelectionDAGBuilder Builder 
)
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 224 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::Optional< T >::hasValue(), llvm::StatepointLoweringState::isStackSlotAllocated(), llvm::StatepointLoweringState::reserveStackSlot(), llvm::StatepointLoweringState::setLocation(), llvm::SelectionDAGBuilder::StatepointLowering, and llvm::FunctionLoweringInfo::StatepointStackSlots.

Referenced by lowerStatepointMetaArgs().

◆ spillIncomingStatepointValue()

static std::pair<SDValue, SDValue> spillIncomingStatepointValue ( SDValue  Incoming,
SDValue  Chain,
SelectionDAGBuilder Builder 
)
static

◆ STATISTIC() [1/3]

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

◆ STATISTIC() [2/3]

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

◆ STATISTIC() [3/3]

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