17 #ifndef LLVM_IR_STATEPOINT_H
18 #define LLVM_IR_STATEPOINT_H
76 template <
typename FunTy,
typename InstructionTy,
typename ValueTy,
79 CallSiteTy StatepointCS;
84 StatepointCS = CallSiteTy(I);
85 assert(StatepointCS &&
"isStatepoint implies CallSite");
107 void *
operator new(
size_t s) =
delete;
109 explicit operator bool()
const {
111 return (
bool)StatepointCS;
116 assert(*
this &&
"check validity first!");
128 return cast<ConstantInt>(IDVal)->getZExtValue();
134 uint64_t NumPatchBytes =
135 cast<ConstantInt>(NumPatchBytesVal)->getZExtValue();
137 return NumPatchBytes;
167 auto *FTy = cast<FunctionType>(
168 cast<PointerType>(
getCalledValue()->getType())->getElementType());
169 return FTy->getReturnType();
175 return cast<ConstantInt>(NumCallArgsVal)->getZExtValue();
183 typename CallSiteTy::arg_iterator
arg_end()
const {
209 return cast<ConstantInt>(NumGCTransitionArgs)->getZExtValue();
231 return cast<ConstantInt>(NumVMSArgs)->getZExtValue();
270 std::vector<const GCRelocateInst *>
getRelocates()
const;
277 if (
auto *GRI = dyn_cast<GCResultInst>(U))
288 "number of arguments to actually callee can't be negative");
306 :
public StatepointBase<const Function, const Instruction, const Value,
333 return I->
getIntrinsicID() == Intrinsic::experimental_gc_relocate ||
338 return isa<IntrinsicInst>(V) &&
classof(cast<IntrinsicInst>(V));
346 return isa<LandingPadInst>(Token) || isa<InvokeInst>(Token);
355 if (!isa<LandingPadInst>(Token)) {
357 return cast<Instruction>(Token);
364 assert(InvokeBB &&
"safepoints should have unique landingpads");
366 "safepoint block should be well formed");
377 return I->
getIntrinsicID() == Intrinsic::experimental_gc_relocate;
381 return isa<IntrinsicInst>(V) &&
classof(cast<IntrinsicInst>(V));
416 return isa<IntrinsicInst>(V) &&
classof(cast<IntrinsicInst>(V));
420 template <
typename FunTy,
typename InstructionTy,
typename ValueTy,
422 std::vector<const GCRelocateInst *>
426 std::vector<const GCRelocateInst *> Result;
428 CallSiteTy StatepointCS = getCallSite();
433 for (
const User *U : getInstruction()->
users())
434 if (
auto *Relocate = dyn_cast<GCRelocateInst>(U))
435 Result.push_back(Relocate);
437 if (!StatepointCS.isInvoke())
442 cast<InvokeInst>(getInstruction())->getLandingPadInst();
445 for (
const User *LandingPadUser : LandingPad->
users()) {
446 if (
auto *Relocate = dyn_cast<GCRelocateInst>(LandingPadUser))
447 Result.push_back(Relocate);
474 #endif // LLVM_IR_STATEPOINT_H
ImmutableStatepoint(const Instruction *I)
CallSiteTy::arg_iterator deopt_end() const
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.
Statepoint(Instruction *I)
StatepointFlags
The statepoint intrinsic accepts a set of flags as its third argument.
iterator_range< arg_iterator > deopt_operands() const
range adapter for vm state arguments
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
StatepointDirectives parseStatepointDirectivesFromAttrs(AttributeList AS)
Parse out statepoint directives from the function attributes present in AS.
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
Common base class for representing values projected from a statepoint.
bool isGCRelocate(ImmutableCallSite CS)
AttributeList getAttributes() const
Return the attribute list for this Function.
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
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
LLVM Basic Block Representation.
CallSiteTy::arg_iterator deopt_begin() const
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.
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)
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.
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
A range adaptor for a pair of iterators.
bool isStatepointDirectiveAttr(Attribute Attr)
Return true if the the Attr is an attribute that is a statepoint directive.
Optional< uint64_t > StatepointID
typename CallSite::arg_iterator arg_iterator
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)
Establish a view to a call site for examination.
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.
const BasicBlock * getUniquePredecessor() const
Return the predecessor of this block if it has a unique predecessor block.
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.
const TerminatorInst * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
uint64_t getFlags() const
A bitmask that includes all valid flags.
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...