17 #ifndef LLVM_IR_STATEPOINT_H
18 #define LLVM_IR_STATEPOINT_H
71 template <
typename FunTy,
typename InstructionTy,
typename ValueTy,
74 CallSiteTy StatepointCS;
79 StatepointCS = CallSiteTy(I);
80 assert(StatepointCS &&
"isStatepoint implies CallSite");
101 void *
operator new(size_t,
unsigned) =
delete;
102 void *
operator new(
size_t s) =
delete;
104 explicit operator bool()
const {
106 return (
bool)StatepointCS;
111 assert(*
this &&
"check validity first!");
123 return cast<ConstantInt>(IDVal)->getZExtValue();
129 uint64_t NumPatchBytes =
130 cast<ConstantInt>(NumPatchBytesVal)->getZExtValue();
132 return NumPatchBytes;
162 auto *FTy = cast<FunctionType>(
163 cast<PointerType>(
getCalledValue()->getType())->getElementType());
164 return FTy->getReturnType();
170 return cast<ConstantInt>(NumCallArgsVal)->getZExtValue();
178 typename CallSiteTy::arg_iterator
arg_end()
const {
204 return cast<ConstantInt>(NumGCTransitionArgs)->getZExtValue();
226 return cast<ConstantInt>(NumVMSArgs)->getZExtValue();
265 std::vector<const GCRelocateInst *>
getRelocates()
const;
272 if (
auto *GRI = dyn_cast<GCResultInst>(U))
283 "number of arguments to actually callee can't be negative");
301 :
public StatepointBase<const Function, const Instruction, const Value,
327 return I->
getIntrinsicID() == Intrinsic::experimental_gc_relocate ||
331 return isa<IntrinsicInst>(V) &&
classof(cast<IntrinsicInst>(V));
339 return isa<LandingPadInst>(
Token) || isa<InvokeInst>(Token);
348 if (!isa<LandingPadInst>(Token)) {
350 return cast<Instruction>(
Token);
357 assert(InvokeBB &&
"safepoints should have unique landingpads");
359 "safepoint block should be well formed");
370 return I->
getIntrinsicID() == Intrinsic::experimental_gc_relocate;
373 return isa<IntrinsicInst>(V) &&
classof(cast<IntrinsicInst>(V));
407 return isa<IntrinsicInst>(V) &&
classof(cast<IntrinsicInst>(V));
411 template <
typename FunTy,
typename InstructionTy,
typename ValueTy,
413 std::vector<const GCRelocateInst *>
417 std::vector<const GCRelocateInst *> Result;
419 CallSiteTy StatepointCS = getCallSite();
424 for (
const User *U : getInstruction()->
users())
425 if (
auto *Relocate = dyn_cast<GCRelocateInst>(U))
426 Result.push_back(Relocate);
428 if (!StatepointCS.isInvoke())
433 cast<InvokeInst>(getInstruction())->getLandingPadInst();
436 for (
const User *LandingPadUser : LandingPad->
users()) {
437 if (
auto *Relocate = dyn_cast<GCRelocateInst>(LandingPadUser))
438 Result.push_back(Relocate);
465 #endif // LLVM_IR_STATEPOINT_H
ImmutableStatepoint(const Instruction *I)
const Instruction * getStatepoint() const
The statepoint with which this gc.relocate is associated.
Represents calls to the gc.result intrinsic.
static bool classof(const Value *V)
ValueTy * getCalledValue() const
Return the value actually being called or invoked.
BasicBlock * getUniquePredecessor()
Return the predecessor of this block if it has a unique predecessor block.
Statepoint(Instruction *I)
StatepointFlags
The statepoint intrinsic accepts a set of flags as its third argument.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
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
unsigned gcArgsStartIdx() 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.
Common base class for representing values projected from a statepoint.
bool isGCRelocate(ImmutableCallSite CS)
iterator_range< arg_iterator > gc_transition_args() const
range adapter for GC transition arguments
Value * getDerivedPtr() const
bool doesNotThrow() const
Determine if the function cannot unwind.
This file contains the simple types necessary to represent the attributes associated with functions a...
CallSiteTy getCallSite() const
Return the underlying CallSite.
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...
InstructionTy * getInstruction() const
static bool classof(const IntrinsicInst *I)
Value * getBasePtr() const
unsigned getDerivedPtrIndex() const
The index into the associate statepoint's argument list which contains the pointer whose relocation t...
static const uint64_t DeoptBundleStatepointID
const GCResultInst * getGCResult() const
Get the experimental_gc_result call tied to this statepoint.
CallSiteTy::arg_iterator gc_args_begin() const
iterator_range< arg_iterator > vm_state_args() const
range adapter for vm state arguments
The landingpad instruction holds all of the information necessary to generate correct exception handl...
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
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)
std::vector< const GCRelocateInst * > getRelocates() const
Get list of all gc reloactes linked to this statepoint May contain several relocations for the same b...
Optional< uint32_t > NumPatchBytes
void verify()
Asserts if this statepoint is malformed.
bool isGCResult(ImmutableCallSite CS)
A specialization of it's base class for read-write access to a gc.statepoint.
StatepointDirectives parseStatepointDirectivesFromAttrs(AttributeSet AS)
Parse out statepoint directives from the function attributes present in AS.
int getNumTotalGCTransitionArgs() const
Number of GC transition args.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
static bool classof(const IntrinsicInst *I)
unsigned getBasePtrIndex() const
The index into the associate statepoint's argument list which contains the base pointer of the pointe...
static bool classof(const Value *V)
constexpr bool isInt< 32 >(int64_t x)
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...
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.
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
A range adaptor for a pair of iterators.
CallSiteTy::arg_iterator arg_iterator
bool isStatepointDirectiveAttr(Attribute Attr)
Return true if the the Attr is an attribute that is a statepoint directive.
Optional< uint64_t > StatepointID
iterator_range< user_iterator > users()
CallSiteTy::arg_iterator arg_begin() const
static const uint64_t DefaultStatepointID
Call sites that get wrapped by a gc.statepoint (currently only in RewriteStatepointsForGC and potenti...
FunTy * getCaller() const
Return the caller function for this statepoint.
static bool classof(const IntrinsicInst *I)
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...
static bool classof(const Value *V)
int getNumTotalVMSArgs() const
Number of additional arguments excluding those intended for garbage collection.
StatepointBase(InstructionTy *I)
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
CallSiteTy::arg_iterator gc_transition_args_begin() const
ImmutableStatepoint(ImmutableCallSite CS)
bool isStatepoint(ImmutableCallSite CS)
bool isTiedToInvoke() const
Return true if this relocate is tied to the invoke statepoint.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
iterator_range< arg_iterator > call_args() const
range adapter for call arguments
bool doesNotThrow() const
Determine if the statepoint cannot unwind.
Represents calls to the gc.relocate intrinsic.
Mark the deopt arguments associated with the statepoint as only being "live-in".
LLVM Value Representation.
Analogous to CallSiteBase, this provides most of the actual functionality for Statepoint and Immutabl...
uint32_t getNumPatchBytes() const
Return the number of patchable bytes associated with this statepoint.
uint64_t getFlags() const
A bitmask that includes all valid flags.
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
const BasicBlock * getParent() const
A wrapper class for inspecting calls to intrinsic functions.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...