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()) {
68 II->replaceAllUsesWith(II->getArgOperand(1));
71 II->replaceAllUsesWith(II->getArgOperand(1));
83 II->eraseFromParent();
108 std::unique_ptr<Lowerer> L;
112 bool doInitialization(
Module &M)
override {
114 "llvm.coro.subfn.addr",
"llvm.coro.free",
116 L = llvm::make_unique<Lowerer>(M);
122 return L->lowerRemainingCoroIntrinsics(F);
129 StringRef getPassName()
const override {
return "Coroutine Cleanup"; }
135 "Lower all coroutine related intrinsics",
false,
false)
Pass interface - Implemented by all 'passes'.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This class represents lattice values for constants.
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of converting the string to 'bool...
A Module instance is used to store all the information related to an LLVM module. ...
LLVMContext & getContext() const
All values hold a context through their type.
INITIALIZE_PASS(CoroCleanup, "coro-cleanup", "Lower all coroutine related intrinsics", false, false) Pass *llvm
FunctionPass * createCFGSimplificationPass(unsigned Threshold=1, bool ForwardSwitchCond=false, bool ConvertSwitch=false, bool KeepLoops=true, bool SinkCommon=false, std::function< bool(const Function &)> Ftor=nullptr)
inst_iterator inst_begin(Function *F)
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
static StructType * get(LLVMContext &Context, ArrayRef< Type *> Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
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 bool runOnFunction(Function &F, bool PostInlining)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Pass * createCoroCleanupPass()
Lower all remaining coroutine intrinsics.
ResumeKind getIndex() const
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
PointerType * getInt8PtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer to an 8-bit integer value.
static ConstantInt * getTrue(LLVMContext &Context)
void setPreservesAll()
Set by analyses that do not transform their input at all.
void initializeCoroCleanupPass(PassRegistry &)
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)
bool declaresIntrinsics(Module &M, std::initializer_list< StringRef >)
StringRef - Represent a constant reference to a string, i.e.
inst_iterator inst_end(Function *F)
bool simplifyCFG(BasicBlock *BB, const TargetTransformInfo &TTI, const SimplifyCFGOptions &Options={}, SmallPtrSetImpl< BasicBlock *> *LoopHeaders=nullptr)
This function is used to do simplification of a CFG.