LLVM  13.0.0git
Classes | Namespaces | Macros | Typedefs | Functions | Variables
RewriteStatepointsForGC.cpp File Reference
#include "llvm/Transforms/Scalar/RewriteStatepointsForGC.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Analysis/DomTreeUpdater.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Statepoint.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/PromoteMemToReg.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <iterator>
#include <set>
#include <string>
#include <utility>
#include <vector>

Go to the source code of this file.

Classes

struct  false::GCPtrLivenessData
 
struct  false::PartiallyConstructedSafepointRecord
 

Namespaces

 false
 

Macros

#define DEBUG_TYPE   "rewrite-statepoints-for-gc"
 

Typedefs

using false::DefiningValueMapTy = MapVector< Value *, Value * >
 
using false::StatepointLiveSetTy = SetVector< Value * >
 
using false::RematerializedValueMapTy = MapVector< AssertingVH< Instruction >, AssertingVH< Value > >
 

Functions

static void stripNonValidData (Module &M)
 The IR fed into RewriteStatepointsForGC may have had attributes and metadata implying dereferenceability that are no longer valid/correct after RewriteStatepointsForGC has run. More...
 
static bool shouldRewriteStatepointsIn (Function &F)
 Returns true if this function should be rewritten by this pass. More...
 
 INITIALIZE_PASS_BEGIN (RewriteStatepointsForGCLegacyPass, "rewrite-statepoints-for-gc", "Make relocations explicit at statepoints", false, false) INITIALIZE_PASS_END(RewriteStatepointsForGCLegacyPass
 
static ArrayRef< UseGetDeoptBundleOperands (const CallBase *Call)
 
static void computeLiveInValues (DominatorTree &DT, Function &F, GCPtrLivenessData &Data)
 Compute the live-in set for every basic block in the function. More...
 
static void findLiveSetAtInst (Instruction *inst, GCPtrLivenessData &Data, StatepointLiveSetTy &out)
 Given results from the dataflow liveness computation, find the set of live Values at a particular instruction. More...
 
static bool isGCPointerType (Type *T)
 
static bool isHandledGCPointerType (Type *T)
 
static bool containsGCPtrType (Type *Ty)
 Returns true if this type contains a gc pointer whether we know how to handle that type or not. More...
 
static bool isUnhandledGCPointerType (Type *Ty)
 
static std::string suffixed_name_or (Value *V, StringRef Suffix, StringRef DefaultName)
 
static void analyzeParsePointLiveness (DominatorTree &DT, GCPtrLivenessData &OriginalLivenessData, CallBase *Call, PartiallyConstructedSafepointRecord &Result)
 
static bool isKnownBaseResult (Value *V)
 Given the result of a call to findBaseDefiningValue, or findBaseOrBDV, is it known to be a base pointer? Or do we need to continue searching. More...
 
static bool isOriginalBaseResult (Value *V)
 This value is a base pointer that is not generated by RS4GC, i.e. More...
 
static BaseDefiningValueResult findBaseDefiningValue (Value *I)
 Helper function for findBasePointer - Will return a value which either a) defines the base pointer for the input, b) blocks the simple search (i.e. More...
 
static BaseDefiningValueResult findBaseDefiningValueOfVector (Value *I)
 Return a base defining value for the 'Index' element of the given vector instruction 'I'. More...
 
static ValuefindBaseDefiningValueCached (Value *I, DefiningValueMapTy &Cache)
 Returns the base defining value for this value. More...
 
static ValuefindBaseOrBDV (Value *I, DefiningValueMapTy &Cache)
 Return a base pointer for this value if known. More...
 
static bool areBothVectorOrScalar (Value *First, Value *Second)
 
static raw_ostreamoperator<< (raw_ostream &OS, const BDVState &State)
 
static ValuefindBasePointer (Value *I, DefiningValueMapTy &Cache)
 For a given value or instruction, figure out what base ptr its derived from. More...
 
static void findBasePointers (const StatepointLiveSetTy &live, MapVector< Value *, Value * > &PointerToBase, DominatorTree *DT, DefiningValueMapTy &DVCache)
 
static void findBasePointers (DominatorTree &DT, DefiningValueMapTy &DVCache, CallBase *Call, PartiallyConstructedSafepointRecord &result)
 Find the required based pointers (and adjust the live set) for the given parse point. More...
 
static void recomputeLiveInValues (GCPtrLivenessData &RevisedLivenessData, CallBase *Call, PartiallyConstructedSafepointRecord &result)
 Given an updated version of the dataflow liveness results, update the liveset and base pointer maps for the call site CS. More...
 
static void recomputeLiveInValues (Function &F, DominatorTree &DT, ArrayRef< CallBase * > toUpdate, MutableArrayRef< struct PartiallyConstructedSafepointRecord > records)
 
static BasicBlocknormalizeForInvokeSafepoint (BasicBlock *BB, BasicBlock *InvokeParent, DominatorTree &DT)
 
static AttributeList legalizeCallAttributes (LLVMContext &Ctx, AttributeList AL)
 
static void CreateGCRelocates (ArrayRef< Value * > LiveVariables, ArrayRef< Value * > BasePtrs, Instruction *StatepointToken, IRBuilder<> &Builder)
 Helper function to place all gc relocates necessary for the given statepoint. More...
 
static StringRef getDeoptLowering (CallBase *Call)
 
static void makeStatepointExplicitImpl (CallBase *Call, const SmallVectorImpl< Value * > &BasePtrs, const SmallVectorImpl< Value * > &LiveVariables, PartiallyConstructedSafepointRecord &Result, std::vector< DeferredReplacement > &Replacements)
 
static void makeStatepointExplicit (DominatorTree &DT, CallBase *Call, PartiallyConstructedSafepointRecord &Result, std::vector< DeferredReplacement > &Replacements)
 
static void insertRelocationStores (iterator_range< Value::user_iterator > GCRelocs, DenseMap< Value *, AllocaInst * > &AllocaMap, DenseSet< Value * > &VisitedLiveValues)
 
static void insertRematerializationStores (const RematerializedValueMapTy &RematerializedValues, DenseMap< Value *, AllocaInst * > &AllocaMap, DenseSet< Value * > &VisitedLiveValues)
 
static void relocationViaAlloca (Function &F, DominatorTree &DT, ArrayRef< Value * > Live, ArrayRef< PartiallyConstructedSafepointRecord > Records)
 Do all the relocation update via allocas and mem2reg. More...
 
template<typename T >
static void unique_unsorted (SmallVectorImpl< T > &Vec)
 Implement a unique function which doesn't require we sort the input vector. More...
 
static void insertUseHolderAfter (CallBase *Call, const ArrayRef< Value * > Values, SmallVectorImpl< CallInst * > &Holders)
 Insert holders so that each Value is obviously live through the entire lifetime of the call. More...
 
static void findLiveReferences (Function &F, DominatorTree &DT, ArrayRef< CallBase * > toUpdate, MutableArrayRef< struct PartiallyConstructedSafepointRecord > records)
 
static ValuefindRematerializableChainToBasePointer (SmallVectorImpl< Instruction * > &ChainToBase, Value *CurrentValue)
 
static InstructionCost chainToBasePointerCost (SmallVectorImpl< Instruction * > &Chain, TargetTransformInfo &TTI)
 
static bool AreEquivalentPhiNodes (PHINode &OrigRootPhi, PHINode &AlternateRootPhi)
 
static void rematerializeLiveValues (CallBase *Call, PartiallyConstructedSafepointRecord &Info, TargetTransformInfo &TTI)
 
static bool inlineGetBaseAndOffset (Function &F, SmallVectorImpl< CallInst * > &Intrinsics)
 
static bool insertParsePoints (Function &F, DominatorTree &DT, TargetTransformInfo &TTI, SmallVectorImpl< CallBase * > &ToUpdate)
 
template<typename AttrHolder >
static void RemoveNonValidAttrAtIndex (LLVMContext &Ctx, AttrHolder &AH, unsigned Index)
 
static void stripNonValidAttributesFromPrototype (Function &F)
 
static void stripInvalidMetadataFromInstruction (Instruction &I)
 Certain metadata on instructions are invalid after running RS4GC. More...
 
static void stripNonValidDataFromBody (Function &F)
 
static void computeLiveInValues (BasicBlock::reverse_iterator Begin, BasicBlock::reverse_iterator End, SetVector< Value * > &LiveTmp)
 Compute the live-in set for the location rbegin starting from the live-out set of the basic block. More...
 
static void computeLiveOutSeed (BasicBlock *BB, SetVector< Value * > &LiveTmp)
 
static SetVector< Value * > computeKillSet (BasicBlock *BB)
 
static void checkBasicSSA (DominatorTree &DT, SetVector< Value * > &Live, Instruction *TI, bool TermOkay=false)
 Check that the items in 'Live' dominate 'TI'. More...
 
static void checkBasicSSA (DominatorTree &DT, GCPtrLivenessData &Data, BasicBlock &BB)
 Check that all the liveness sets used during the computation of liveness obey basic SSA properties. More...
 

Variables

static cl::opt< bool > PrintLiveSet ("spp-print-liveset", cl::Hidden, cl::init(false))
 
static cl::opt< bool > PrintLiveSetSize ("spp-print-liveset-size", cl::Hidden, cl::init(false))
 
static cl::opt< bool > PrintBasePointers ("spp-print-base-pointers", cl::Hidden, cl::init(false))
 
static cl::opt< unsigned > RematerializationThreshold ("spp-rematerialization-threshold", cl::Hidden, cl::init(6))
 
static bool ClobberNonLive = false
 
static cl::opt< bool, trueClobberNonLiveOverride ("rs4gc-clobber-non-live", cl::location(ClobberNonLive), cl::Hidden)
 
static cl::opt< bool > AllowStatepointWithNoDeoptInfo ("rs4gc-allow-statepoint-with-no-deopt-info", cl::Hidden, cl::init(true))
 
rewrite statepoints for gc
 
rewrite statepoints for Make relocations at statepoints
 
rewrite statepoints for Make relocations at false
 
static constexpr Attribute::AttrKind FnAttrsToStrip []
 
static constexpr Attribute::AttrKind ParamAttrsToStrip []
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "rewrite-statepoints-for-gc"

Definition at line 79 of file RewriteStatepointsForGC.cpp.

Function Documentation

◆ analyzeParsePointLiveness()

static void analyzeParsePointLiveness ( DominatorTree DT,
GCPtrLivenessData &  OriginalLivenessData,
CallBase Call,
PartiallyConstructedSafepointRecord &  Result 
)
static

◆ areBothVectorOrScalar()

static bool areBothVectorOrScalar ( Value First,
Value Second 
)
static

Definition at line 682 of file RewriteStatepointsForGC.cpp.

References First, and llvm::Value::getType().

Referenced by findBasePointer().

◆ AreEquivalentPhiNodes()

static bool AreEquivalentPhiNodes ( PHINode OrigRootPhi,
PHINode AlternateRootPhi 
)
static

◆ chainToBasePointerCost()

static InstructionCost chainToBasePointerCost ( SmallVectorImpl< Instruction * > &  Chain,
TargetTransformInfo TTI 
)
static

◆ checkBasicSSA() [1/2]

static void checkBasicSSA ( DominatorTree DT,
GCPtrLivenessData &  Data,
BasicBlock BB 
)
static

Check that all the liveness sets used during the computation of liveness obey basic SSA properties.

This is useful for finding cases where we miss a def.

Definition at line 3036 of file RewriteStatepointsForGC.cpp.

References BB, checkBasicSSA(), and llvm::Data.

◆ checkBasicSSA() [2/2]

static void checkBasicSSA ( DominatorTree DT,
SetVector< Value * > &  Live,
Instruction TI,
bool  TermOkay = false 
)
static

Check that the items in 'Live' dominate 'TI'.

This is used as a basic sanity check for the liveness computation.

Definition at line 3018 of file RewriteStatepointsForGC.cpp.

References assert(), llvm::DominatorTree::dominates(), and I.

Referenced by checkBasicSSA(), and computeLiveInValues().

◆ computeKillSet()

static SetVector<Value *> computeKillSet ( BasicBlock BB)
static

◆ computeLiveInValues() [1/2]

static void computeLiveInValues ( BasicBlock::reverse_iterator  Begin,
BasicBlock::reverse_iterator  End,
SetVector< Value * > &  LiveTmp 
)
static

Compute the live-in set for the location rbegin starting from the live-out set of the basic block.

Definition at line 2958 of file RewriteStatepointsForGC.cpp.

◆ computeLiveInValues() [2/2]

static void computeLiveInValues ( DominatorTree DT,
Function F,
GCPtrLivenessData &  Data 
)
static

◆ computeLiveOutSeed()

static void computeLiveOutSeed ( BasicBlock BB,
SetVector< Value * > &  LiveTmp 
)
static

◆ containsGCPtrType()

static bool containsGCPtrType ( Type Ty)
static

Returns true if this type contains a gc pointer whether we know how to handle that type or not.

Definition at line 341 of file RewriteStatepointsForGC.cpp.

References llvm::any_of(), isGCPointerType(), and llvm::ARM_MB::ST.

Referenced by isUnhandledGCPointerType().

◆ CreateGCRelocates()

static void CreateGCRelocates ( ArrayRef< Value * >  LiveVariables,
ArrayRef< Value * >  BasePtrs,
Instruction StatepointToken,
IRBuilder<> &  Builder 
)
static

Helper function to place all gc relocates necessary for the given statepoint.

Inputs: liveVariables - list of variables to be relocated. basePtrs - base pointers. statepointToken - statepoint instruction to which relocates should be bound. Builder - Llvm IR builder to be used to construct new calls.

Definition at line 1402 of file RewriteStatepointsForGC.cpp.

References assert(), llvm::ArrayRef< T >::begin(), Builder, llvm::CallingConv::Cold, llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::count(), llvm::ArrayRef< T >::end(), llvm::find(), llvm::FixedVectorType::get(), llvm::Intrinsic::getDeclaration(), llvm::Type::getInt8PtrTy(), llvm::Instruction::getModule(), i, Index, isHandledGCPointerType(), M, llvm::CallBase::setCallingConv(), llvm::ArrayRef< T >::size(), and suffixed_name_or().

Referenced by makeStatepointExplicitImpl().

◆ findBaseDefiningValue()

static BaseDefiningValueResult findBaseDefiningValue ( Value I)
static

Helper function for findBasePointer - Will return a value which either a) defines the base pointer for the input, b) blocks the simple search (i.e.

a PHI or Select of two derived pointers), or c) involves a change from pointer to vector type or back.

Definition at line 498 of file RewriteStatepointsForGC.cpp.

References assert(), llvm::tgtok::Def, findBaseDefiningValueOfVector(), GEP, llvm::ConstantPointerNull::get(), I, and llvm_unreachable.

Referenced by findBaseDefiningValueCached(), and findBaseDefiningValueOfVector().

◆ findBaseDefiningValueCached()

static Value* findBaseDefiningValueCached ( Value I,
DefiningValueMapTy &  Cache 
)
static

Returns the base defining value for this value.

Definition at line 632 of file RewriteStatepointsForGC.cpp.

References assert(), llvm::dbgs(), findBaseDefiningValue(), llvm::Value::getName(), I, and LLVM_DEBUG.

Referenced by findBaseOrBDV().

◆ findBaseDefiningValueOfVector()

static BaseDefiningValueResult findBaseDefiningValueOfVector ( Value I)
static

Return a base defining value for the 'Index' element of the given vector instruction 'I'.

If Index is null, returns a BDV for the entire vector 'I'. As an optimization, this method will try to determine when the element is known to already be a base pointer. If this can be established, the second value in the returned pair will be true. Note that either a vector or a pointer typed value can be returned. For the former, the vector returned is a BDV (and possibly a base) of the entire vector 'I'. If the later, the return pointer is a BDV (or possibly a base) for the particular element in 'I'.

Definition at line 440 of file RewriteStatepointsForGC.cpp.

References assert(), findBaseDefiningValue(), GEP, llvm::ConstantAggregateZero::get(), and I.

Referenced by findBaseDefiningValue().

◆ findBaseOrBDV()

static Value* findBaseOrBDV ( Value I,
DefiningValueMapTy &  Cache 
)
static

Return a base pointer for this value if known.

Otherwise, return it's base defining value.

Definition at line 645 of file RewriteStatepointsForGC.cpp.

References llvm::tgtok::Def, findBaseDefiningValueCached(), and I.

Referenced by findBasePointer().

◆ findBasePointer()

static Value* findBasePointer ( Value I,
DefiningValueMapTy &  Cache 
)
static

For a given value or instruction, figure out what base ptr its derived from.

For gc objects, this is simply itself. On success, returns a value which is the base pointer. (This is reliable and can be used for relocation.) On failure, returns nullptr.

Definition at line 806 of file RewriteStatepointsForGC.cpp.

References areBothVectorOrScalar(), llvm::tgtok::Def, findBaseOrBDV(), I, and isKnownBaseResult().

Referenced by findBasePointers(), and inlineGetBaseAndOffset().

◆ findBasePointers() [1/2]

static void findBasePointers ( const StatepointLiveSetTy &  live,
MapVector< Value *, Value * > &  PointerToBase,
DominatorTree DT,
DefiningValueMapTy &  DVCache 
)
static

◆ findBasePointers() [2/2]

static void findBasePointers ( DominatorTree DT,
DefiningValueMapTy &  DVCache,
CallBase Call,
PartiallyConstructedSafepointRecord &  result 
)
static

Find the required based pointers (and adjust the live set) for the given parse point.

Definition at line 1275 of file RewriteStatepointsForGC.cpp.

References llvm::errs(), findBasePointers(), llvm::LLVMContext::OB_deopt, PrintBasePointers, and result.

◆ findLiveReferences()

static void findLiveReferences ( Function F,
DominatorTree DT,
ArrayRef< CallBase * >  toUpdate,
MutableArrayRef< struct PartiallyConstructedSafepointRecord >  records 
)
static

◆ findLiveSetAtInst()

static void findLiveSetAtInst ( Instruction inst,
GCPtrLivenessData &  Data,
StatepointLiveSetTy &  out 
)
static

◆ findRematerializableChainToBasePointer()

static Value* findRematerializableChainToBasePointer ( SmallVectorImpl< Instruction * > &  ChainToBase,
Value CurrentValue 
)
static

Definition at line 2161 of file RewriteStatepointsForGC.cpp.

References GEP.

Referenced by rematerializeLiveValues().

◆ GetDeoptBundleOperands()

static ArrayRef<Use> GetDeoptBundleOperands ( const CallBase Call)
static

◆ getDeoptLowering()

static StringRef getDeoptLowering ( CallBase Call)
static

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( RewriteStatepointsForGCLegacyPass  ,
"rewrite-statepoints-for-gc ,
"Make relocations explicit at statepoints ,
false  ,
false   
)

◆ inlineGetBaseAndOffset()

static bool inlineGetBaseAndOffset ( Function F,
SmallVectorImpl< CallInst * > &  Intrinsics 
)
static

◆ insertParsePoints()

static bool insertParsePoints ( Function F,
DominatorTree DT,
TargetTransformInfo TTI,
SmallVectorImpl< CallBase * > &  ToUpdate 
)
static

◆ insertRelocationStores()

static void insertRelocationStores ( iterator_range< Value::user_iterator GCRelocs,
DenseMap< Value *, AllocaInst * > &  AllocaMap,
DenseSet< Value * > &  VisitedLiveValues 
)
static

◆ insertRematerializationStores()

static void insertRematerializationStores ( const RematerializedValueMapTy &  RematerializedValues,
DenseMap< Value *, AllocaInst * > &  AllocaMap,
DenseSet< Value * > &  VisitedLiveValues 
)
static

◆ insertUseHolderAfter()

static void insertUseHolderAfter ( CallBase Call,
const ArrayRef< Value * >  Values,
SmallVectorImpl< CallInst * > &  Holders 
)
static

Insert holders so that each Value is obviously live through the entire lifetime of the call.

Definition at line 2119 of file RewriteStatepointsForGC.cpp.

References llvm::CallInst::Create(), llvm::ArrayRef< T >::empty(), llvm::FunctionType::get(), llvm::Type::getVoidTy(), and M.

Referenced by insertParsePoints().

◆ isGCPointerType()

static bool isGCPointerType ( Type T)
static

Definition at line 313 of file RewriteStatepointsForGC.cpp.

References T.

Referenced by containsGCPtrType(), and isHandledGCPointerType().

◆ isHandledGCPointerType()

static bool isHandledGCPointerType ( Type T)
static

◆ isKnownBaseResult()

static bool isKnownBaseResult ( Value V)
static

Given the result of a call to findBaseDefiningValue, or findBaseOrBDV, is it known to be a base pointer? Or do we need to continue searching.

Definition at line 667 of file RewriteStatepointsForGC.cpp.

References isOriginalBaseResult().

Referenced by findBasePointer().

◆ isOriginalBaseResult()

static bool isOriginalBaseResult ( Value V)
static

This value is a base pointer that is not generated by RS4GC, i.e.

it already exists in the code.

Definition at line 658 of file RewriteStatepointsForGC.cpp.

Referenced by isKnownBaseResult().

◆ isUnhandledGCPointerType()

static bool isUnhandledGCPointerType ( Type Ty)
static

◆ legalizeCallAttributes()

static AttributeList legalizeCallAttributes ( LLVMContext Ctx,
AttributeList  AL 
)
static

◆ makeStatepointExplicit()

static void makeStatepointExplicit ( DominatorTree DT,
CallBase Call,
PartiallyConstructedSafepointRecord &  Result,
std::vector< DeferredReplacement > &  Replacements 
)
static

◆ makeStatepointExplicitImpl()

static void makeStatepointExplicitImpl ( CallBase Call,
const SmallVectorImpl< Value * > &  BasePtrs,
const SmallVectorImpl< Value * > &  LiveVariables,
PartiallyConstructedSafepointRecord &  Result,
std::vector< DeferredReplacement > &  Replacements 
)
static

◆ normalizeForInvokeSafepoint()

static BasicBlock* normalizeForInvokeSafepoint ( BasicBlock BB,
BasicBlock InvokeParent,
DominatorTree DT 
)
static

◆ operator<<()

static raw_ostream& operator<< ( raw_ostream OS,
const BDVState &  State 
)
static

Definition at line 796 of file RewriteStatepointsForGC.cpp.

◆ recomputeLiveInValues() [1/2]

static void recomputeLiveInValues ( Function F,
DominatorTree DT,
ArrayRef< CallBase * >  toUpdate,
MutableArrayRef< struct PartiallyConstructedSafepointRecord >  records 
)
static

◆ recomputeLiveInValues() [2/2]

static void recomputeLiveInValues ( GCPtrLivenessData &  RevisedLivenessData,
CallBase Call,
PartiallyConstructedSafepointRecord &  result 
)
static

Given an updated version of the dataflow liveness results, update the liveset and base pointer maps for the call site CS.

Definition at line 3129 of file RewriteStatepointsForGC.cpp.

References assert(), llvm::MCID::Call, findLiveSetAtInst(), Info, and llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert().

Referenced by insertParsePoints(), and recomputeLiveInValues().

◆ relocationViaAlloca()

static void relocationViaAlloca ( Function F,
DominatorTree DT,
ArrayRef< Value * >  Live,
ArrayRef< PartiallyConstructedSafepointRecord >  Records 
)
static

◆ rematerializeLiveValues()

static void rematerializeLiveValues ( CallBase Call,
PartiallyConstructedSafepointRecord &  Info,
TargetTransformInfo TTI 
)
static

◆ RemoveNonValidAttrAtIndex()

template<typename AttrHolder >
static void RemoveNonValidAttrAtIndex ( LLVMContext Ctx,
AttrHolder &  AH,
unsigned  Index 
)
static

◆ shouldRewriteStatepointsIn()

static bool shouldRewriteStatepointsIn ( Function F)
static

Returns true if this function should be rewritten by this pass.

The main point of this function is as an extension point for custom logic.

Definition at line 2784 of file RewriteStatepointsForGC.cpp.

References F.

Referenced by llvm::RewriteStatepointsForGC::run(), llvm::RewriteStatepointsForGC::runOnFunction(), and stripNonValidData().

◆ stripInvalidMetadataFromInstruction()

static void stripInvalidMetadataFromInstruction ( Instruction I)
static

Certain metadata on instructions are invalid after running RS4GC.

Optimizations that run after RS4GC can incorrectly use this metadata to optimize functions. We drop such metadata on the instruction.

Definition at line 2706 of file RewriteStatepointsForGC.cpp.

References I.

Referenced by stripNonValidDataFromBody().

◆ stripNonValidAttributesFromPrototype()

static void stripNonValidAttributesFromPrototype ( Function F)
static

◆ stripNonValidData()

static void stripNonValidData ( Module M)
static

The IR fed into RewriteStatepointsForGC may have had attributes and metadata implying dereferenceability that are no longer valid/correct after RewriteStatepointsForGC has run.

This is because semantically, after RewriteStatepointsForGC runs, all calls to gc.statepoint "free" the entire heap. stripNonValidData (conservatively) restores correctness by erasing all attributes in the module that externally imply dereferenceability. Similar reasoning also applies to the noalias attributes and metadata. gc.statepoint can touch the entire heap including noalias objects. Apart from attributes and metadata, we also remove instructions that imply constant physical memory: llvm.invariant.start.

Definition at line 2796 of file RewriteStatepointsForGC.cpp.

References llvm::any_of(), assert(), F, M, shouldRewriteStatepointsIn(), stripNonValidAttributesFromPrototype(), and stripNonValidDataFromBody().

Referenced by llvm::RewriteStatepointsForGC::run().

◆ stripNonValidDataFromBody()

static void stripNonValidDataFromBody ( Function F)
static

◆ suffixed_name_or()

static std::string suffixed_name_or ( Value V,
StringRef  Suffix,
StringRef  DefaultName 
)
static

◆ unique_unsorted()

template<typename T >
static void unique_unsorted ( SmallVectorImpl< T > &  Vec)
static

Implement a unique function which doesn't require we sort the input vector.

Doing so has the effect of changing the output of a couple of tests in ways which make them less useful in testing fused safepoints.

Definition at line 2112 of file RewriteStatepointsForGC.cpp.

References llvm::erase_if(), llvm::SmallSet< T, N, C >::insert(), and T.

Referenced by insertParsePoints().

Variable Documentation

◆ AllowStatepointWithNoDeoptInfo

cl::opt<bool> AllowStatepointWithNoDeoptInfo("rs4gc-allow-statepoint-with-no-deopt-info", cl::Hidden, cl::init(true))
static

◆ ClobberNonLive

bool ClobberNonLive = false
static

Definition at line 102 of file RewriteStatepointsForGC.cpp.

Referenced by relocationViaAlloca().

◆ ClobberNonLiveOverride

cl::opt<bool, true> ClobberNonLiveOverride("rs4gc-clobber-non-live", cl::location(ClobberNonLive), cl::Hidden)
static

◆ false

rewrite statepoints for Make relocations at false

Definition at line 229 of file RewriteStatepointsForGC.cpp.

◆ FnAttrsToStrip

constexpr Attribute::AttrKind FnAttrsToStrip[]
staticconstexpr
Initial value:
=
{Attribute::ReadNone, Attribute::ReadOnly, Attribute::WriteOnly,
Attribute::ArgMemOnly, Attribute::InaccessibleMemOnly,
Attribute::InaccessibleMemOrArgMemOnly,
Attribute::NoSync, Attribute::NoFree}

Definition at line 1356 of file RewriteStatepointsForGC.cpp.

Referenced by legalizeCallAttributes(), and stripNonValidAttributesFromPrototype().

◆ gc

Definition at line 228 of file RewriteStatepointsForGC.cpp.

◆ ParamAttrsToStrip

constexpr Attribute::AttrKind ParamAttrsToStrip[]
staticconstexpr
Initial value:
=
{Attribute::ReadNone, Attribute::ReadOnly, Attribute::WriteOnly,
Attribute::NoAlias, Attribute::NoFree}

Definition at line 1367 of file RewriteStatepointsForGC.cpp.

Referenced by RemoveNonValidAttrAtIndex().

◆ PrintBasePointers

cl::opt<bool> PrintBasePointers("spp-print-base-pointers", cl::Hidden, cl::init(false))
static

◆ PrintLiveSet

cl::opt<bool> PrintLiveSet("spp-print-liveset", cl::Hidden, cl::init(false))
static

◆ PrintLiveSetSize

cl::opt<bool> PrintLiveSetSize("spp-print-liveset-size", cl::Hidden, cl::init(false))
static

◆ RematerializationThreshold

cl::opt<unsigned> RematerializationThreshold("spp-rematerialization-threshold", cl::Hidden, cl::init(6))
static

Referenced by rematerializeLiveValues().

◆ statepoints

rewrite statepoints for Make relocations at statepoints
explicit

Definition at line 229 of file RewriteStatepointsForGC.cpp.

llvm::orc::ReadOnly
static constexpr sys::Memory::ProtectionFlags ReadOnly
Definition: DebugObjectManagerPlugin.cpp:111