21 #define DEBUG_TYPE "coro-cleanup"
28 bool lowerRemainingCoroIntrinsics(
Function &
F);
36 FPM.doInitialization();
58 bool Lowerer::lowerRemainingCoroIntrinsics(
Function &
F) {
63 if (
auto *II = dyn_cast<IntrinsicInst>(&I)) {
64 switch (II->getIntrinsicID()) {
67 case Intrinsic::coro_begin:
68 II->replaceAllUsesWith(II->getArgOperand(1));
70 case Intrinsic::coro_free:
71 II->replaceAllUsesWith(II->getArgOperand(1));
73 case Intrinsic::coro_alloc:
76 case Intrinsic::coro_id:
79 case Intrinsic::coro_subfn_addr:
83 II->eraseFromParent();
106 std::unique_ptr<Lowerer>
L;
110 bool doInitialization(
Module &M)
override {
112 "llvm.coro.subfn.addr",
"llvm.coro.free",
114 L = llvm::make_unique<Lowerer>(M);
118 bool runOnFunction(
Function &F)
override {
120 return L->lowerRemainingCoroIntrinsics(F);
132 "Lower all coroutine related intrinsics",
false,
false)
Pass interface - Implemented by all 'passes'.
A Module instance is used to store all the information related to an LLVM module. ...
INITIALIZE_PASS(CoroCleanup,"coro-cleanup","Lower all coroutine related intrinsics", false, false) Pass *llvm
inst_iterator inst_begin(Function *F)
ResumeKind getIndex() const
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
This class represents the llvm.coro.subfn.addr instruction.
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
void add(Pass *P) override
Add a pass to the queue of passes to run.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block...
Class to represent pointers.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
LoadInst * CreateLoad(Value *Ptr, const char *Name)
Pass * createCoroCleanupPass()
Lower all remaining coroutine intrinsics.
FunctionPass * createCFGSimplificationPass(int Threshold=-1, std::function< bool(const Function &)> Ftor=nullptr)
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
LLVMContext & getContext() const
All values hold a context through their type.
PointerType * getInt8PtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer to an 8-bit integer value.
static void simplifyCFG(Function &F)
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
static ConstantInt * getTrue(LLVMContext &Context)
void setPreservesAll()
Set by analyses that do not transform their input at all.
Value * CreateConstInBoundsGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0, unsigned Idx1, const Twine &Name="")
static ConstantTokenNone * get(LLVMContext &Context)
Return the ConstantTokenNone.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
static void lowerSubFn(IRBuilder<> &Builder, CoroSubFnInst *SubFn)
static const unsigned FramePtr
bool declaresIntrinsics(Module &M, std::initializer_list< StringRef >)
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
inst_iterator inst_end(Function *F)