33 enum { FrameArg, IndexArg };
42 IndexFirst = RestartTrigger
47 int64_t Index = getRawIndex()->getValue().getSExtValue();
48 assert(Index >= IndexFirst && Index < IndexLast &&
49 "unexpected CoroSubFnInst index argument");
54 return cast<ConstantInt>(getArgOperand(IndexArg));
62 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
74 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
80 enum { AlignArg, PromiseArg, CoroutineArg, InfoArg };
85 if (
auto *CA = dyn_cast<CoroAllocInst>(U))
92 if (
auto *II = dyn_cast<IntrinsicInst>(U))
93 if (II->getIntrinsicID() == Intrinsic::coro_begin)
99 Value *Arg = getArgOperand(PromiseArg);
100 return isa<ConstantPointerNull>(Arg)
106 Value *Arg = getArgOperand(PromiseArg);
107 setArgOperand(PromiseArg,
109 if (isa<AllocaInst>(Arg))
111 assert((isa<BitCastInst>(Arg) || isa<GetElementPtrInst>(Arg)) &&
112 "unexpected instruction designating the promise");
115 auto *Inst = cast<Instruction>(Arg);
116 if (Inst->use_empty()) {
117 Inst->eraseFromParent();
120 Inst->moveBefore(getCoroBegin()->getNextNode());
149 assert(GV->isConstant() && GV->hasDefinitiveInitializer());
150 Constant *Initializer = GV->getInitializer();
151 if ((Result.
OutlinedParts = dyn_cast<ConstantStruct>(Initializer)))
154 Result.
Resumers = cast<ConstantArray>(Initializer);
158 return cast<Constant>(getArgOperand(InfoArg)->stripPointerCasts());
164 return cast<Function>(getArgOperand(CoroutineArg)->stripPointerCasts());
167 assert(isa<ConstantPointerNull>(getArgOperand(CoroutineArg)) &&
168 "Coroutine argument is already assigned");
170 setArgOperand(CoroutineArg,
179 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
191 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
197 enum { IdArg, FrameArg };
207 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
213 enum { IdArg, MemArg };
225 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
237 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
243 enum { FrameArg, AlignArg, FromArg };
247 return cast<Constant>(getArgOperand(FromArg))->isOneValue();
250 return cast<ConstantInt>(getArgOperand(AlignArg))->getZExtValue();
258 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
264 enum { SaveArg, FinalArg };
268 Value *Arg = getArgOperand(SaveArg);
269 if (
auto *
SI = dyn_cast<CoroSaveInst>(Arg))
271 assert(isa<ConstantTokenNone>(Arg));
275 return cast<Constant>(getArgOperand(FinalArg))->isOneValue();
283 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
295 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
301 enum { FrameArg, UnwindArg };
306 return cast<Constant>(getArgOperand(UnwindArg))->isOneValue();
314 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
This represents the llvm.coro.promise instruction.
This represents the llvm.coro.alloc instruction.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
static bool classof(const IntrinsicInst *I)
ConstantInt * getRawIndex() const
IntrinsicInst * getCoroBegin()
static bool classof(const IntrinsicInst *I)
unsigned getAlignment() const
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
ResumeKind getIndex() const
This represents the llvm.coro.suspend instruction.
static bool classof(const IntrinsicInst *I)
CoroIdInst * getId() const
This class represents the llvm.coro.subfn.addr instruction.
ConstantStruct * OutlinedParts
static bool classof(const IntrinsicInst *I)
This represents the llvm.coro.alloc instruction.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
CoroSaveInst * getCoroSave() const
Constant * getRawInfo() const
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
This represents the llvm.coro.size instruction.
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
This is an important base class in LLVM.
Function * getCoroutine() const
static bool classof(const Value *V)
This represents the llvm.coro.end instruction.
This represents the llvm.coro.save instruction.
#define LLVM_LIBRARY_VISIBILITY
LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked into a shared library...
static bool classof(const Value *V)
static bool classof(const Value *V)
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
This represents the llvm.coro.free instruction.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
This is the shared class of boolean and integer constants.
Value * stripPointerCasts()
Strip off pointer casts, all-zero GEPs, and aliases.
static bool classof(const Value *V)
bool isFromPromise() const
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
bool hasOutlinedParts() const
This class represents the llvm.coro.begin instruction.
ConstantArray - Constant Array Declarations.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *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)
bool isFallthrough() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This represents the llvm.coro.frame instruction.
LLVM Value Representation.
void setInfo(Constant *C)
AllocaInst * getPromise() const
CoroAllocInst * getCoroAlloc()
static bool classof(const Value *V)
A wrapper class for inspecting calls to intrinsic functions.
an instruction to allocate memory on the stack