LLVM 18.0.0git
CoroInstr.h
Go to the documentation of this file.
1//===-- CoroInstr.h - Coroutine Intrinsics Instruction Wrappers -*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8// This file defines classes that make it really easy to deal with intrinsic
9// functions with the isa/dyncast family of functions. In particular, this
10// allows you to do things like:
11//
12// if (auto *SF = dyn_cast<CoroSubFnInst>(Inst))
13// ... SF->getFrame() ...
14//
15// All intrinsic function calls are instances of the call instruction, so these
16// are all subclasses of the CallInst class. Note that none of these classes
17// has state or virtual methods, which is an important part of this gross/neat
18// hack working.
19//
20// The helpful comment above is borrowed from llvm/IntrinsicInst.h, we keep
21// coroutine intrinsic wrappers here since they are only used by the passes in
22// the Coroutine library.
23//===----------------------------------------------------------------------===//
24
25#ifndef LLVM_LIB_TRANSFORMS_COROUTINES_COROINSTR_H
26#define LLVM_LIB_TRANSFORMS_COROUTINES_COROINSTR_H
27
31
32namespace llvm {
33
34/// This class represents the llvm.coro.subfn.addr instruction.
36 enum { FrameArg, IndexArg };
37
38public:
40 RestartTrigger = -1,
45 IndexFirst = RestartTrigger
46 };
47
48 Value *getFrame() const { return getArgOperand(FrameArg); }
50 int64_t Index = getRawIndex()->getValue().getSExtValue();
51 assert(Index >= IndexFirst && Index < IndexLast &&
52 "unexpected CoroSubFnInst index argument");
53 return static_cast<ResumeKind>(Index);
54 }
55
57 return cast<ConstantInt>(getArgOperand(IndexArg));
58 }
59
60 // Methods to support type inquiry through isa, cast, and dyn_cast:
61 static bool classof(const IntrinsicInst *I) {
62 return I->getIntrinsicID() == Intrinsic::coro_subfn_addr;
63 }
64 static bool classof(const Value *V) {
65 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
66 }
67};
68
69/// This represents the llvm.coro.alloc instruction.
71public:
72 // Methods to support type inquiry through isa, cast, and dyn_cast:
73 static bool classof(const IntrinsicInst *I) {
74 return I->getIntrinsicID() == Intrinsic::coro_alloc;
75 }
76 static bool classof(const Value *V) {
77 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
78 }
79};
80
81/// This represents a common base class for llvm.coro.id instructions.
83public:
85 for (User *U : users())
86 if (auto *CA = dyn_cast<CoroAllocInst>(U))
87 return CA;
88 return nullptr;
89 }
90
92 for (User *U : users())
93 if (auto *II = dyn_cast<IntrinsicInst>(U))
94 if (II->getIntrinsicID() == Intrinsic::coro_begin)
95 return II;
96 llvm_unreachable("no coro.begin associated with coro.id");
97 }
98
99 // Methods to support type inquiry through isa, cast, and dyn_cast:
100 static bool classof(const IntrinsicInst *I) {
101 auto ID = I->getIntrinsicID();
102 return ID == Intrinsic::coro_id || ID == Intrinsic::coro_id_retcon ||
103 ID == Intrinsic::coro_id_retcon_once ||
104 ID == Intrinsic::coro_id_async;
105 }
106
107 static bool classof(const Value *V) {
108 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
109 }
110};
111
112/// This represents the llvm.coro.id instruction.
114 enum { AlignArg, PromiseArg, CoroutineArg, InfoArg };
115
116public:
118 Value *Arg = getArgOperand(PromiseArg);
119 return isa<ConstantPointerNull>(Arg)
120 ? nullptr
121 : cast<AllocaInst>(Arg->stripPointerCasts());
122 }
123
125 Value *Arg = getArgOperand(PromiseArg);
126 setArgOperand(PromiseArg, ConstantPointerNull::get(
127 PointerType::getUnqual(getContext())));
128 if (isa<AllocaInst>(Arg))
129 return;
130 assert((isa<BitCastInst>(Arg) || isa<GetElementPtrInst>(Arg)) &&
131 "unexpected instruction designating the promise");
132 // TODO: Add a check that any remaining users of Inst are after coro.begin
133 // or add code to move the users after coro.begin.
134 auto *Inst = cast<Instruction>(Arg);
135 if (Inst->use_empty()) {
136 Inst->eraseFromParent();
137 return;
138 }
139 Inst->moveBefore(getCoroBegin()->getNextNode());
140 }
141
142 // Info argument of coro.id is
143 // fresh out of the frontend: null ;
144 // outlined : {Init, Return, Susp1, Susp2, ...} ;
145 // postsplit : [resume, destroy, cleanup] ;
146 //
147 // If parts of the coroutine were outlined to protect against undesirable
148 // code motion, these functions will be stored in a struct literal referred to
149 // by the Info parameter. Note: this is only needed before coroutine is split.
150 //
151 // After coroutine is split, resume functions are stored in an array
152 // referred to by this parameter.
153
154 struct Info {
155 ConstantStruct *OutlinedParts = nullptr;
156 ConstantArray *Resumers = nullptr;
157
158 bool hasOutlinedParts() const { return OutlinedParts != nullptr; }
159 bool isPostSplit() const { return Resumers != nullptr; }
160 bool isPreSplit() const { return !isPostSplit(); }
161 };
162 Info getInfo() const {
163 Info Result;
164 auto *GV = dyn_cast<GlobalVariable>(getRawInfo());
165 if (!GV)
166 return Result;
167
168 assert(GV->isConstant() && GV->hasDefinitiveInitializer());
169 Constant *Initializer = GV->getInitializer();
170 if ((Result.OutlinedParts = dyn_cast<ConstantStruct>(Initializer)))
171 return Result;
172
173 Result.Resumers = cast<ConstantArray>(Initializer);
174 return Result;
175 }
177 return cast<Constant>(getArgOperand(InfoArg)->stripPointerCasts());
178 }
179
180 void setInfo(Constant *C) { setArgOperand(InfoArg, C); }
181
183 return cast<Function>(getArgOperand(CoroutineArg)->stripPointerCasts());
184 }
186 assert(isa<ConstantPointerNull>(getArgOperand(CoroutineArg)) &&
187 "Coroutine argument is already assigned");
188 setArgOperand(CoroutineArg, getFunction());
189 }
190
191 // Methods to support type inquiry through isa, cast, and dyn_cast:
192 static bool classof(const IntrinsicInst *I) {
193 return I->getIntrinsicID() == Intrinsic::coro_id;
194 }
195 static bool classof(const Value *V) {
196 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
197 }
198};
199
200/// This represents either the llvm.coro.id.retcon or
201/// llvm.coro.id.retcon.once instruction.
203 enum { SizeArg, AlignArg, StorageArg, PrototypeArg, AllocArg, DeallocArg };
204
205public:
206 void checkWellFormed() const;
207
209 return cast<ConstantInt>(getArgOperand(SizeArg))->getZExtValue();
210 }
211
213 return cast<ConstantInt>(getArgOperand(AlignArg))->getAlignValue();
214 }
215
216 Value *getStorage() const {
217 return getArgOperand(StorageArg);
218 }
219
220 /// Return the prototype for the continuation function. The type,
221 /// attributes, and calling convention of the continuation function(s)
222 /// are taken from this declaration.
224 return cast<Function>(getArgOperand(PrototypeArg)->stripPointerCasts());
225 }
226
227 /// Return the function to use for allocating memory.
229 return cast<Function>(getArgOperand(AllocArg)->stripPointerCasts());
230 }
231
232 /// Return the function to use for deallocating memory.
234 return cast<Function>(getArgOperand(DeallocArg)->stripPointerCasts());
235 }
236
237 // Methods to support type inquiry through isa, cast, and dyn_cast:
238 static bool classof(const IntrinsicInst *I) {
239 auto ID = I->getIntrinsicID();
240 return ID == Intrinsic::coro_id_retcon
241 || ID == Intrinsic::coro_id_retcon_once;
242 }
243 static bool classof(const Value *V) {
244 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
245 }
246};
247
248/// This represents the llvm.coro.id.retcon instruction.
250 : public AnyCoroIdRetconInst {
251public:
252 // Methods to support type inquiry through isa, cast, and dyn_cast:
253 static bool classof(const IntrinsicInst *I) {
254 return I->getIntrinsicID() == Intrinsic::coro_id_retcon;
255 }
256 static bool classof(const Value *V) {
257 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
258 }
259};
260
261/// This represents the llvm.coro.id.retcon.once instruction.
263 : public AnyCoroIdRetconInst {
264public:
265 // Methods to support type inquiry through isa, cast, and dyn_cast:
266 static bool classof(const IntrinsicInst *I) {
267 return I->getIntrinsicID() == Intrinsic::coro_id_retcon_once;
268 }
269 static bool classof(const Value *V) {
270 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
271 }
272};
273
274/// This represents the llvm.coro.id.async instruction.
276 enum { SizeArg, AlignArg, StorageArg, AsyncFuncPtrArg };
277
278public:
279 void checkWellFormed() const;
280
281 /// The initial async function context size. The fields of which are reserved
282 /// for use by the frontend. The frame will be allocated as a tail of this
283 /// context.
285 return cast<ConstantInt>(getArgOperand(SizeArg))->getZExtValue();
286 }
287
288 /// The alignment of the initial async function context.
290 return cast<ConstantInt>(getArgOperand(AlignArg))->getAlignValue();
291 }
292
293 /// The async context parameter.
294 Value *getStorage() const {
295 return getParent()->getParent()->getArg(getStorageArgumentIndex());
296 }
297
298 unsigned getStorageArgumentIndex() const {
299 auto *Arg = cast<ConstantInt>(getArgOperand(StorageArg));
300 return Arg->getZExtValue();
301 }
302
303 /// Return the async function pointer address. This should be the address of
304 /// a async function pointer struct for the current async function.
305 /// struct async_function_pointer {
306 /// uint32_t context_size;
307 /// uint32_t relative_async_function_pointer;
308 /// };
310 return cast<GlobalVariable>(
311 getArgOperand(AsyncFuncPtrArg)->stripPointerCasts());
312 }
313
314 // Methods to support type inquiry through isa, cast, and dyn_cast:
315 static bool classof(const IntrinsicInst *I) {
316 auto ID = I->getIntrinsicID();
317 return ID == Intrinsic::coro_id_async;
318 }
319
320 static bool classof(const Value *V) {
321 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
322 }
323};
324
325/// This represents the llvm.coro.context.alloc instruction.
327 enum { AsyncFuncPtrArg };
328
329public:
331 return cast<GlobalVariable>(
332 getArgOperand(AsyncFuncPtrArg)->stripPointerCasts());
333 }
334
335 // Methods to support type inquiry through isa, cast, and dyn_cast:
336 static bool classof(const IntrinsicInst *I) {
337 return I->getIntrinsicID() == Intrinsic::coro_async_context_alloc;
338 }
339 static bool classof(const Value *V) {
340 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
341 }
342};
343
344/// This represents the llvm.coro.context.dealloc instruction.
346 : public IntrinsicInst {
347 enum { AsyncContextArg };
348
349public:
351 return getArgOperand(AsyncContextArg)->stripPointerCasts();
352 }
353
354 // Methods to support type inquiry through isa, cast, and dyn_cast:
355 static bool classof(const IntrinsicInst *I) {
356 return I->getIntrinsicID() == Intrinsic::coro_async_context_dealloc;
357 }
358 static bool classof(const Value *V) {
359 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
360 }
361};
362
363/// This represents the llvm.coro.async.resume instruction.
364/// During lowering this is replaced by the resume function of a suspend point
365/// (the continuation function).
367public:
368 // Methods to support type inquiry through isa, cast, and dyn_cast:
369 static bool classof(const IntrinsicInst *I) {
370 return I->getIntrinsicID() == Intrinsic::coro_async_resume;
371 }
372 static bool classof(const Value *V) {
373 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
374 }
375};
376
377/// This represents the llvm.coro.async.size.replace instruction.
379public:
380 // Methods to support type inquiry through isa, cast, and dyn_cast:
381 static bool classof(const IntrinsicInst *I) {
382 return I->getIntrinsicID() == Intrinsic::coro_async_size_replace;
383 }
384 static bool classof(const Value *V) {
385 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
386 }
387};
388
389/// This represents the llvm.coro.frame instruction.
391public:
392 // Methods to support type inquiry through isa, cast, and dyn_cast:
393 static bool classof(const IntrinsicInst *I) {
394 return I->getIntrinsicID() == Intrinsic::coro_frame;
395 }
396 static bool classof(const Value *V) {
397 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
398 }
399};
400
401/// This represents the llvm.coro.free instruction.
403 enum { IdArg, FrameArg };
404
405public:
406 Value *getFrame() const { return getArgOperand(FrameArg); }
407
408 // Methods to support type inquiry through isa, cast, and dyn_cast:
409 static bool classof(const IntrinsicInst *I) {
410 return I->getIntrinsicID() == Intrinsic::coro_free;
411 }
412 static bool classof(const Value *V) {
413 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
414 }
415};
416
417/// This class represents the llvm.coro.begin instruction.
419 enum { IdArg, MemArg };
420
421public:
423 return cast<AnyCoroIdInst>(getArgOperand(IdArg));
424 }
425
426 Value *getMem() const { return getArgOperand(MemArg); }
427
428 // Methods for support type inquiry through isa, cast, and dyn_cast:
429 static bool classof(const IntrinsicInst *I) {
430 return I->getIntrinsicID() == Intrinsic::coro_begin;
431 }
432 static bool classof(const Value *V) {
433 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
434 }
435};
436
437/// This represents the llvm.coro.save instruction.
439public:
440 // Methods to support type inquiry through isa, cast, and dyn_cast:
441 static bool classof(const IntrinsicInst *I) {
442 return I->getIntrinsicID() == Intrinsic::coro_save;
443 }
444 static bool classof(const Value *V) {
445 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
446 }
447};
448
449/// This represents the llvm.coro.promise instruction.
451 enum { FrameArg, AlignArg, FromArg };
452
453public:
454 /// Are we translating from the frame to the promise (false) or from
455 /// the promise to the frame (true)?
456 bool isFromPromise() const {
457 return cast<Constant>(getArgOperand(FromArg))->isOneValue();
458 }
459
460 /// The required alignment of the promise. This must match the
461 /// alignment of the promise alloca in the coroutine.
463 return cast<ConstantInt>(getArgOperand(AlignArg))->getAlignValue();
464 }
465
466 // Methods to support type inquiry through isa, cast, and dyn_cast:
467 static bool classof(const IntrinsicInst *I) {
468 return I->getIntrinsicID() == Intrinsic::coro_promise;
469 }
470 static bool classof(const Value *V) {
471 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
472 }
473};
474
476public:
477 CoroSaveInst *getCoroSave() const;
478
479 // Methods to support type inquiry through isa, cast, and dyn_cast:
480 static bool classof(const IntrinsicInst *I) {
481 return I->getIntrinsicID() == Intrinsic::coro_suspend ||
482 I->getIntrinsicID() == Intrinsic::coro_suspend_async ||
483 I->getIntrinsicID() == Intrinsic::coro_suspend_retcon;
484 }
485 static bool classof(const Value *V) {
486 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
487 }
488};
489
490/// This represents the llvm.coro.suspend instruction.
492 enum { SaveArg, FinalArg };
493
494public:
496 Value *Arg = getArgOperand(SaveArg);
497 if (auto *SI = dyn_cast<CoroSaveInst>(Arg))
498 return SI;
499 assert(isa<ConstantTokenNone>(Arg));
500 return nullptr;
501 }
502
503 bool isFinal() const {
504 return cast<Constant>(getArgOperand(FinalArg))->isOneValue();
505 }
506
507 // Methods to support type inquiry through isa, cast, and dyn_cast:
508 static bool classof(const IntrinsicInst *I) {
509 return I->getIntrinsicID() == Intrinsic::coro_suspend;
510 }
511 static bool classof(const Value *V) {
512 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
513 }
514};
515
517 if (auto Suspend = dyn_cast<CoroSuspendInst>(this))
518 return Suspend->getCoroSave();
519 return nullptr;
520}
521
522/// This represents the llvm.coro.suspend.async instruction.
524public:
525 enum {
529 MustTailCallFuncArg
530 };
531
532 void checkWellFormed() const;
533
534 unsigned getStorageArgumentIndex() const {
535 auto *Arg = cast<ConstantInt>(getArgOperand(StorageArgNoArg));
536 return Arg->getZExtValue();
537 }
538
540 return cast<Function>(
541 getArgOperand(AsyncContextProjectionArg)->stripPointerCasts());
542 }
543
545 return cast<CoroAsyncResumeInst>(
546 getArgOperand(ResumeFunctionArg)->stripPointerCasts());
547 }
548
550 return cast<Function>(
551 getArgOperand(MustTailCallFuncArg)->stripPointerCasts());
552 }
553
554 // Methods to support type inquiry through isa, cast, and dyn_cast:
555 static bool classof(const IntrinsicInst *I) {
556 return I->getIntrinsicID() == Intrinsic::coro_suspend_async;
557 }
558 static bool classof(const Value *V) {
559 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
560 }
561};
562
563/// This represents the llvm.coro.suspend.retcon instruction.
565public:
566 op_iterator value_begin() { return arg_begin(); }
567 const_op_iterator value_begin() const { return arg_begin(); }
568
569 op_iterator value_end() { return arg_end(); }
570 const_op_iterator value_end() const { return arg_end(); }
571
573 return make_range(value_begin(), value_end());
574 }
576 return make_range(value_begin(), value_end());
577 }
578
579 // Methods to support type inquiry through isa, cast, and dyn_cast:
580 static bool classof(const IntrinsicInst *I) {
581 return I->getIntrinsicID() == Intrinsic::coro_suspend_retcon;
582 }
583 static bool classof(const Value *V) {
584 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
585 }
586};
587
588/// This represents the llvm.coro.size instruction.
590public:
591 // Methods to support type inquiry through isa, cast, and dyn_cast:
592 static bool classof(const IntrinsicInst *I) {
593 return I->getIntrinsicID() == Intrinsic::coro_size;
594 }
595 static bool classof(const Value *V) {
596 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
597 }
598};
599
600/// This represents the llvm.coro.align instruction.
602public:
603 // Methods to support type inquiry through isa, cast, and dyn_cast:
604 static bool classof(const IntrinsicInst *I) {
605 return I->getIntrinsicID() == Intrinsic::coro_align;
606 }
607 static bool classof(const Value *V) {
608 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
609 }
610};
611
612/// This represents the llvm.end.results instruction.
614public:
615 op_iterator retval_begin() { return arg_begin(); }
616 const_op_iterator retval_begin() const { return arg_begin(); }
617
618 op_iterator retval_end() { return arg_end(); }
619 const_op_iterator retval_end() const { return arg_end(); }
620
622 return make_range(retval_begin(), retval_end());
623 }
625 return make_range(retval_begin(), retval_end());
626 }
627
628 unsigned numReturns() const {
629 return std::distance(retval_begin(), retval_end());
630 }
631
632 // Methods to support type inquiry through isa, cast, and dyn_cast:
633 static bool classof(const IntrinsicInst *I) {
634 return I->getIntrinsicID() == Intrinsic::coro_end_results;
635 }
636 static bool classof(const Value *V) {
637 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
638 }
639};
640
642 enum { FrameArg, UnwindArg, TokenArg };
643
644public:
645 bool isFallthrough() const { return !isUnwind(); }
646 bool isUnwind() const {
647 return cast<Constant>(getArgOperand(UnwindArg))->isOneValue();
648 }
649
650 bool hasResults() const {
651 return !isa<ConstantTokenNone>(getArgOperand(TokenArg));
652 }
653
655 assert(hasResults());
656 return cast<CoroEndResults>(getArgOperand(TokenArg));
657 }
658
659 // Methods to support type inquiry through isa, cast, and dyn_cast:
660 static bool classof(const IntrinsicInst *I) {
661 auto ID = I->getIntrinsicID();
662 return ID == Intrinsic::coro_end || ID == Intrinsic::coro_end_async;
663 }
664 static bool classof(const Value *V) {
665 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
666 }
667};
668
669/// This represents the llvm.coro.end instruction.
671public:
672 // Methods to support type inquiry through isa, cast, and dyn_cast:
673 static bool classof(const IntrinsicInst *I) {
674 return I->getIntrinsicID() == Intrinsic::coro_end;
675 }
676 static bool classof(const Value *V) {
677 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
678 }
679};
680
681/// This represents the llvm.coro.end instruction.
683 enum { FrameArg, UnwindArg, MustTailCallFuncArg };
684
685public:
686 void checkWellFormed() const;
687
689 if (arg_size() < 3)
690 return nullptr;
691
692 return cast<Function>(
693 getArgOperand(MustTailCallFuncArg)->stripPointerCasts());
694 }
695
696 // Methods to support type inquiry through isa, cast, and dyn_cast:
697 static bool classof(const IntrinsicInst *I) {
698 return I->getIntrinsicID() == Intrinsic::coro_end_async;
699 }
700 static bool classof(const Value *V) {
701 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
702 }
703};
704
705/// This represents the llvm.coro.alloca.alloc instruction.
707 enum { SizeArg, AlignArg };
708public:
709 Value *getSize() const {
710 return getArgOperand(SizeArg);
711 }
713 return cast<ConstantInt>(getArgOperand(AlignArg))->getAlignValue();
714 }
715
716 // Methods to support type inquiry through isa, cast, and dyn_cast:
717 static bool classof(const IntrinsicInst *I) {
718 return I->getIntrinsicID() == Intrinsic::coro_alloca_alloc;
719 }
720 static bool classof(const Value *V) {
721 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
722 }
723};
724
725/// This represents the llvm.coro.alloca.get instruction.
727 enum { AllocArg };
728public:
730 return cast<CoroAllocaAllocInst>(getArgOperand(AllocArg));
731 }
732
733 // Methods to support type inquiry through isa, cast, and dyn_cast:
734 static bool classof(const IntrinsicInst *I) {
735 return I->getIntrinsicID() == Intrinsic::coro_alloca_get;
736 }
737 static bool classof(const Value *V) {
738 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
739 }
740};
741
742/// This represents the llvm.coro.alloca.free instruction.
744 enum { AllocArg };
745public:
747 return cast<CoroAllocaAllocInst>(getArgOperand(AllocArg));
748 }
749
750 // Methods to support type inquiry through isa, cast, and dyn_cast:
751 static bool classof(const IntrinsicInst *I) {
752 return I->getIntrinsicID() == Intrinsic::coro_alloca_free;
753 }
754 static bool classof(const Value *V) {
755 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
756 }
757};
758
759} // End namespace llvm.
760
761#endif
static const Function * getParent(const Value *V)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define LLVM_LIBRARY_VISIBILITY
Definition: Compiler.h:131
uint32_t Index
static Function * getFunction(Constant *C)
Definition: Evaluator.cpp:236
iv users
Definition: IVUsers.cpp:48
#define I(x, y, z)
Definition: MD5.cpp:58
StandardInstrumentations SI(Mod->getContext(), Debug, VerifyEach)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
an instruction to allocate memory on the stack
Definition: Instructions.h:58
bool isFallthrough() const
Definition: CoroInstr.h:645
static bool classof(const Value *V)
Definition: CoroInstr.h:664
bool hasResults() const
Definition: CoroInstr.h:650
bool isUnwind() const
Definition: CoroInstr.h:646
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:660
CoroEndResults * getResults() const
Definition: CoroInstr.h:654
This represents a common base class for llvm.coro.id instructions.
Definition: CoroInstr.h:82
IntrinsicInst * getCoroBegin()
Definition: CoroInstr.h:91
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:100
static bool classof(const Value *V)
Definition: CoroInstr.h:107
CoroAllocInst * getCoroAlloc()
Definition: CoroInstr.h:84
This represents either the llvm.coro.id.retcon or llvm.coro.id.retcon.once instruction.
Definition: CoroInstr.h:202
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:238
Value * getStorage() const
Definition: CoroInstr.h:216
Align getStorageAlignment() const
Definition: CoroInstr.h:212
Function * getPrototype() const
Return the prototype for the continuation function.
Definition: CoroInstr.h:223
uint64_t getStorageSize() const
Definition: CoroInstr.h:208
Function * getAllocFunction() const
Return the function to use for allocating memory.
Definition: CoroInstr.h:228
static bool classof(const Value *V)
Definition: CoroInstr.h:243
Function * getDeallocFunction() const
Return the function to use for deallocating memory.
Definition: CoroInstr.h:233
static bool classof(const Value *V)
Definition: CoroInstr.h:485
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:480
CoroSaveInst * getCoroSave() const
Definition: CoroInstr.h:516
ConstantArray - Constant Array Declarations.
Definition: Constants.h:408
This is the shared class of boolean and integer constants.
Definition: Constants.h:78
This is an important base class in LLVM.
Definition: Constant.h:41
This represents the llvm.coro.align instruction.
Definition: CoroInstr.h:601
static bool classof(const Value *V)
Definition: CoroInstr.h:607
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:604
This represents the llvm.coro.alloc instruction.
Definition: CoroInstr.h:70
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:73
static bool classof(const Value *V)
Definition: CoroInstr.h:76
This represents the llvm.coro.alloca.alloc instruction.
Definition: CoroInstr.h:706
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:717
Align getAlignment() const
Definition: CoroInstr.h:712
static bool classof(const Value *V)
Definition: CoroInstr.h:720
Value * getSize() const
Definition: CoroInstr.h:709
This represents the llvm.coro.alloca.free instruction.
Definition: CoroInstr.h:743
static bool classof(const Value *V)
Definition: CoroInstr.h:754
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:751
CoroAllocaAllocInst * getAlloc() const
Definition: CoroInstr.h:746
This represents the llvm.coro.alloca.get instruction.
Definition: CoroInstr.h:726
static bool classof(const Value *V)
Definition: CoroInstr.h:737
CoroAllocaAllocInst * getAlloc() const
Definition: CoroInstr.h:729
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:734
This represents the llvm.coro.context.alloc instruction.
Definition: CoroInstr.h:326
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:336
static bool classof(const Value *V)
Definition: CoroInstr.h:339
GlobalVariable * getAsyncFunctionPointer() const
Definition: CoroInstr.h:330
This represents the llvm.coro.context.dealloc instruction.
Definition: CoroInstr.h:346
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:355
static bool classof(const Value *V)
Definition: CoroInstr.h:358
This represents the llvm.coro.end instruction.
Definition: CoroInstr.h:682
Function * getMustTailCallFunction() const
Definition: CoroInstr.h:688
static bool classof(const Value *V)
Definition: CoroInstr.h:700
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:697
This represents the llvm.coro.async.resume instruction.
Definition: CoroInstr.h:366
static bool classof(const Value *V)
Definition: CoroInstr.h:372
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:369
This represents the llvm.coro.async.size.replace instruction.
Definition: CoroInstr.h:378
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:381
static bool classof(const Value *V)
Definition: CoroInstr.h:384
This class represents the llvm.coro.begin instruction.
Definition: CoroInstr.h:418
AnyCoroIdInst * getId() const
Definition: CoroInstr.h:422
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:429
static bool classof(const Value *V)
Definition: CoroInstr.h:432
Value * getMem() const
Definition: CoroInstr.h:426
This represents the llvm.coro.end instruction.
Definition: CoroInstr.h:670
static bool classof(const Value *V)
Definition: CoroInstr.h:676
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:673
This represents the llvm.end.results instruction.
Definition: CoroInstr.h:613
op_iterator retval_begin()
Definition: CoroInstr.h:615
const_op_iterator retval_begin() const
Definition: CoroInstr.h:616
iterator_range< const_op_iterator > return_values() const
Definition: CoroInstr.h:624
iterator_range< op_iterator > return_values()
Definition: CoroInstr.h:621
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:633
const_op_iterator retval_end() const
Definition: CoroInstr.h:619
static bool classof(const Value *V)
Definition: CoroInstr.h:636
op_iterator retval_end()
Definition: CoroInstr.h:618
unsigned numReturns() const
Definition: CoroInstr.h:628
This represents the llvm.coro.frame instruction.
Definition: CoroInstr.h:390
static bool classof(const Value *V)
Definition: CoroInstr.h:396
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:393
This represents the llvm.coro.free instruction.
Definition: CoroInstr.h:402
Value * getFrame() const
Definition: CoroInstr.h:406
static bool classof(const Value *V)
Definition: CoroInstr.h:412
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:409
This represents the llvm.coro.id.async instruction.
Definition: CoroInstr.h:275
Align getStorageAlignment() const
The alignment of the initial async function context.
Definition: CoroInstr.h:289
uint64_t getStorageSize() const
The initial async function context size.
Definition: CoroInstr.h:284
GlobalVariable * getAsyncFunctionPointer() const
Return the async function pointer address.
Definition: CoroInstr.h:309
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:315
Value * getStorage() const
The async context parameter.
Definition: CoroInstr.h:294
unsigned getStorageArgumentIndex() const
Definition: CoroInstr.h:298
static bool classof(const Value *V)
Definition: CoroInstr.h:320
This represents the llvm.coro.id instruction.
Definition: CoroInstr.h:113
static bool classof(const Value *V)
Definition: CoroInstr.h:195
void setInfo(Constant *C)
Definition: CoroInstr.h:180
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:192
Info getInfo() const
Definition: CoroInstr.h:162
Function * getCoroutine() const
Definition: CoroInstr.h:182
Constant * getRawInfo() const
Definition: CoroInstr.h:176
AllocaInst * getPromise() const
Definition: CoroInstr.h:117
void setCoroutineSelf()
Definition: CoroInstr.h:185
void clearPromise()
Definition: CoroInstr.h:124
This represents the llvm.coro.id.retcon instruction.
Definition: CoroInstr.h:250
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:253
static bool classof(const Value *V)
Definition: CoroInstr.h:256
This represents the llvm.coro.id.retcon.once instruction.
Definition: CoroInstr.h:263
static bool classof(const Value *V)
Definition: CoroInstr.h:269
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:266
This represents the llvm.coro.promise instruction.
Definition: CoroInstr.h:450
static bool classof(const Value *V)
Definition: CoroInstr.h:470
Align getAlignment() const
The required alignment of the promise.
Definition: CoroInstr.h:462
bool isFromPromise() const
Are we translating from the frame to the promise (false) or from the promise to the frame (true)?
Definition: CoroInstr.h:456
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:467
This represents the llvm.coro.save instruction.
Definition: CoroInstr.h:438
static bool classof(const Value *V)
Definition: CoroInstr.h:444
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:441
This represents the llvm.coro.size instruction.
Definition: CoroInstr.h:589
static bool classof(const Value *V)
Definition: CoroInstr.h:595
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:592
This class represents the llvm.coro.subfn.addr instruction.
Definition: CoroInstr.h:35
static bool classof(const Value *V)
Definition: CoroInstr.h:64
Value * getFrame() const
Definition: CoroInstr.h:48
ResumeKind getIndex() const
Definition: CoroInstr.h:49
ConstantInt * getRawIndex() const
Definition: CoroInstr.h:56
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:61
This represents the llvm.coro.suspend.async instruction.
Definition: CoroInstr.h:523
Function * getAsyncContextProjectionFunction() const
Definition: CoroInstr.h:539
static bool classof(const Value *V)
Definition: CoroInstr.h:558
unsigned getStorageArgumentIndex() const
Definition: CoroInstr.h:534
CoroAsyncResumeInst * getResumeFunction() const
Definition: CoroInstr.h:544
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:555
Function * getMustTailCallFunction() const
Definition: CoroInstr.h:549
This represents the llvm.coro.suspend instruction.
Definition: CoroInstr.h:491
bool isFinal() const
Definition: CoroInstr.h:503
CoroSaveInst * getCoroSave() const
Definition: CoroInstr.h:495
static bool classof(const Value *V)
Definition: CoroInstr.h:511
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:508
This represents the llvm.coro.suspend.retcon instruction.
Definition: CoroInstr.h:564
op_iterator value_begin()
Definition: CoroInstr.h:566
static bool classof(const Value *V)
Definition: CoroInstr.h:583
const_op_iterator value_begin() const
Definition: CoroInstr.h:567
const_op_iterator value_end() const
Definition: CoroInstr.h:570
iterator_range< const_op_iterator > value_operands() const
Definition: CoroInstr.h:575
iterator_range< op_iterator > value_operands()
Definition: CoroInstr.h:572
static bool classof(const IntrinsicInst *I)
Definition: CoroInstr.h:580
A wrapper class for inspecting calls to intrinsic functions.
Definition: IntrinsicInst.h:47
A Use represents the edge between a Value definition and its users.
Definition: Use.h:43
LLVM Value Representation.
Definition: Value.h:74
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
Definition: Value.cpp:693
A range adaptor for a pair of iterators.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
bool hasOutlinedParts() const
Definition: CoroInstr.h:158
bool isPostSplit() const
Definition: CoroInstr.h:159
bool isPreSplit() const
Definition: CoroInstr.h:160