16 #ifndef LLVM_IR_STATEPOINT_H
17 #define LLVM_IR_STATEPOINT_H
39 class GCRelocateOperands;
40 class ImmutableStatepoint;
58 template <
typename FunTy,
typename InstructionTy,
typename ValueTy,
61 CallSiteTy StatepointCS;
62 void *
operator new(size_t,
unsigned) =
delete;
63 void *
operator new(
size_t s) =
delete;
68 StatepointCS = CallSiteTy(I);
69 assert(StatepointCS &&
"isStatepoint implies CallSite");
89 explicit operator bool()
const {
91 return (
bool)StatepointCS;
96 assert(*
this &&
"check validity first!");
108 return cast<ConstantInt>(IDVal)->getZExtValue();
114 uint64_t NumPatchBytes =
115 cast<ConstantInt>(NumPatchBytesVal)->getZExtValue();
116 assert(
isInt<32>(NumPatchBytes) &&
"should fit in 32 bits!");
117 return NumPatchBytes;
147 auto *FTy = cast<FunctionType>(
148 cast<PointerType>(
getCalledValue()->getType())->getElementType());
149 return FTy->getReturnType();
155 return cast<ConstantInt>(NumCallArgsVal)->getZExtValue();
163 typename CallSiteTy::arg_iterator
arg_end()
const {
170 assert(Index <
arg_size() &&
"out of bounds!");
189 return cast<ConstantInt>(NumGCTransitionArgs)->getZExtValue();
212 return cast<ConstantInt>(NumVMSArgs)->getZExtValue();
255 return cast<CallInst>(U);
266 "number of arguments to actually callee can't be negative");
284 :
public StatepointBase<const Function, const Instruction, const Value,
323 return isa<ExtractValueInst>(Token) || isa<InvokeInst>(Token);
335 if (!isa<ExtractValueInst>(Token)) {
336 return cast<Instruction>(Token);
341 cast<Instruction>(Token)->
getParent()->getUniquePredecessor();
343 assert(InvokeBB &&
"safepoints should have unique landingpads");
345 "safepoint block should be well formed");
355 return cast<ConstantInt>(RelocateCS.
getArgument(1))->getZExtValue();
361 return cast<ConstantInt>(RelocateCS.
getArgument(2))->getZExtValue();
375 template <
typename FunTy,
typename InstructionTy,
typename ValueTy,
377 std::vector<GCRelocateOperands>
381 std::vector<GCRelocateOperands> Result;
383 CallSiteTy StatepointCS = getCallSite();
388 for (
const User *U : getInstruction()->
users())
392 if (!StatepointCS.isInvoke())
397 cast<InvokeInst>(getInstruction())->getLandingPadInst();
401 for (
const User *LandingPadUser : LandingPad->
users()) {
402 if (!isa<ExtractValueInst>(LandingPadUser))
406 for (
const User *U : LandingPadUser->
users())
bool isInt< 32 >(int64_t x)
ImmutableStatepoint(const Instruction *I)
GCRelocateOperands(CallSite CS)
ValueTy * getCalledValue() const
Return the value actually being called or invoked.
unsigned getBasePtrIndex()
The index into the associate statepoint's argument list which contains the base pointer of the pointe...
Statepoint(Instruction *I)
StatepointFlags
The statepoint intrinsic accepts a set of flags as its third argument.
ValTy * getArgument(unsigned ArgNo) const
A specialization of it's base class for read only access to a gc.statepoint.
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
CallSiteTy::arg_iterator gc_transition_args_end() const
CallSiteTy::arg_iterator vm_state_begin() const
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
iterator_range< arg_iterator > gc_transition_args() const
range adapter for GC transition arguments
bool doesNotThrow() const
Determine if the function cannot unwind.
GCRelocateOperands(const Instruction *inst)
CallSiteTy getCallSite() const
Return the underlying CallSite.
bool isStatepoint(const ImmutableCallSite &CS)
ValueTy * getArgument(unsigned Index)
FunTy * getCalledFunction() const
Return the function being called if this is a direct call, otherwise return null (if it's an indirect...
unsigned getDerivedPtrIndex()
The index into the associate statepoint's argument list which contains the pointer whose relocation t...
InstructionTy * getInstruction() const
CallSiteTy::arg_iterator gc_args_begin() const
iterator_range< arg_iterator > vm_state_args() const
range adapter for vm state arguments
LandingPadInst - The landingpad instruction holds all of the information necessary to generate correc...
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
CallSiteTy::arg_iterator gc_args_end() const
bool isGCRelocate(const Value *V)
This file contains the declarations for the subclasses of Constant, which represent the different fla...
iterator_range< arg_iterator > gc_args() const
range adapter for gc arguments
bool paramHasAttr(unsigned i, Attribute::AttrKind A) const
Return true if the call or the callee has the given attribute.
StatepointBase(CallSiteTy CS)
void verify()
Asserts if this statepoint is malformed.
A specialization of it's base class for read-write access to a gc.statepoint.
Wraps a call to a gc.relocate and provides access to it's operands.
GCRelocateOperands(const User *U)
int getNumTotalGCTransitionArgs() const
Number of GC transition args.
bool isTiedToInvoke() const
Return true if this relocate is tied to the invoke statepoint.
CallSiteTy::arg_iterator vm_state_end() const
uint64_t getID() const
Return the ID associated with this statepoint.
Indicates that this statepoint is a transition from GC-aware code to code that is not GC-aware...
ImmutableCallSite getUnderlyingCallSite()
Get enclosed relocate intrinsic.
CallSiteTy::arg_iterator arg_end() const
Type * getActualReturnType() const
Return the type of the value returned by the call underlying the statepoint.
int getNumCallArgs() const
Number of arguments to be passed to the actual callee.
AttributeSet getAttributes() const
Return the attribute list for this Function.
A range adaptor for a pair of iterators.
CallSiteTy::arg_iterator arg_iterator
iterator_range< user_iterator > users()
CallSiteTy::arg_iterator arg_begin() const
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
const Instruction * getStatepoint()
The statepoint with which this gc.relocate is associated.
InstructionTy * getGCResult() const
Get the experimental_gc_result call tied to this statepoint.
FunTy * getCaller() const
Return the caller function for this statepoint.
std::vector< GCRelocateOperands > getRelocates() const
Get list of all gc reloactes linked to this statepoint May contain several relocations for the same b...
ImmutableCallSite - establish a view to a call site for examination.
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
int getNumTotalVMSArgs() const
Number of additional arguments excluding those intended for garbage collection.
StatepointBase(InstructionTy *I)
CallSiteTy::arg_iterator gc_transition_args_begin() const
ImmutableStatepoint(ImmutableCallSite CS)
iterator_range< arg_iterator > call_args() const
range adapter for call arguments
bool doesNotThrow() const
Determine if the statepoint cannot unwind.
LLVM Value Representation.
Analogous to CallSiteBase, this provides most of the actual functionality for Statepoint and Immutabl...
static const Function * getParent(const Value *V)
IterTy arg_begin() const
arg_begin/arg_end - Return iterators corresponding to the actual argument list for a call site...
uint32_t getNumPatchBytes() const
Return the number of patchable bytes associated with this statepoint.
uint64_t getFlags() const
bool isGCResult(const Value *V)
A bitmask that includes all valid flags.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...