18#define DEBUG_TYPE "coro-early"
32 : LowererBase(M), Builder(Context),
42void Lowerer::lowerResumeOrDestroy(
CallBase &CB,
55void Lowerer::lowerCoroPromise(CoroPromiseInst *Intrin) {
62 const DataLayout &
DL = TheModule.getDataLayout();
64 DL.getStructLayout(SampleStruct)->getElementOffset(2), Alignment);
80void Lowerer::lowerCoroDone(IntrinsicInst *
II) {
81 Value *Operand =
II->getArgOperand(0);
84 auto *FrameTy = Int8Ptr;
90 II->replaceAllUsesWith(
Cond);
91 II->eraseFromParent();
104void Lowerer::lowerEarlyIntrinsics(
Function &
F) {
105 CoroIdInst *CoroId =
nullptr;
106 CoroBeginInst *CoroBegin =
nullptr;
108 bool HasCoroSuspend =
false;
117 case Intrinsic::coro_begin:
118 case Intrinsic::coro_begin_custom_abi:
121 "coroutine should have exactly one defining @llvm.coro.begin");
124 case Intrinsic::coro_free:
127 case Intrinsic::coro_suspend:
132 HasCoroSuspend =
true;
134 case Intrinsic::coro_end_async:
135 case Intrinsic::coro_end:
141 case Intrinsic::coro_id:
143 if (CII->getInfo().isPreSplit()) {
144 assert(
F.isPresplitCoroutine() &&
145 "The frontend uses Switch-Resumed ABI should emit "
146 "\"presplitcoroutine\" attribute for the coroutine.");
148 CII->setCoroutineSelf();
153 case Intrinsic::coro_id_retcon:
154 case Intrinsic::coro_id_retcon_once:
155 case Intrinsic::coro_id_async:
156 F.setPresplitCoroutine();
158 case Intrinsic::coro_resume:
161 case Intrinsic::coro_destroy:
164 case Intrinsic::coro_promise:
167 case Intrinsic::coro_done:
177 for (CoroFreeInst *CF : CoroFrees)
178 CF->setArgOperand(0, CoroId);
185 for (Argument &
A :
F.args())
186 if (
A.hasNoAliasAttr())
187 A.removeAttr(Attribute::NoAlias);
193 M, {Intrinsic::coro_id, Intrinsic::coro_id_retcon,
194 Intrinsic::coro_id_retcon_once, Intrinsic::coro_id_async,
195 Intrinsic::coro_destroy, Intrinsic::coro_done, Intrinsic::coro_end,
196 Intrinsic::coro_end_async, Intrinsic::coro_free,
197 Intrinsic::coro_promise, Intrinsic::coro_resume});
206 L.lowerEarlyIntrinsics(
F);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Expand Atomic instructions
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static void setCannotDuplicate(CoroIdInst *CoroId)
static bool declaresCoroEarlyIntrinsics(const Module &M)
Module.h This file contains the declarations for the Module class.
uint64_t IntrinsicInst * II
const SmallVectorImpl< MachineOperand > & Cond
Represents analyses that only rely on functions' control flow.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Value * getArgOperand(unsigned i) const
void setCannotDuplicate()
LLVM_ABI Intrinsic::ID getIntrinsicID() const
Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...
void setCalledOperand(Value *V)
This represents the llvm.coro.id instruction.
This represents the llvm.coro.promise instruction.
Align getAlignment() const
The required alignment of the promise.
bool isFromPromise() const
Are we translating from the frame to the promise (false) or from the promise to the frame (true)?
Value * CreateConstInBoundsGEP1_32(Type *Ty, Value *Ptr, unsigned Idx0, const Twine &Name="")
Value * CreateICmpEQ(Value *LHS, Value *RHS, const Twine &Name="")
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of converting the string to 'bool...
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
IntegerType * getInt8Ty()
Fetch the type representing an 8-bit integer.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
A wrapper class for inspecting calls to intrinsic functions.
A Module instance is used to store all the information related to an LLVM module.
static PointerType * getUnqual(LLVMContext &C)
This constructs an opaque pointer to an object in the default address space (address space zero).
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
void push_back(const T &Elt)
static LLVM_ABI StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
iterator_range< user_iterator > users()
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
bool declaresIntrinsics(const Module &M, ArrayRef< Intrinsic::ID > List)
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
@ Load
The value being inserted comes from a load (InsertElement only).
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)