Go to the documentation of this file.
19 #define DEBUG_TYPE "coro-cleanup"
36 SubFn->
getContext(), {Builder.getInt8PtrTy(), Builder.getInt8PtrTy()});
40 auto *FramePtr =
Builder.CreateBitCast(FrameRaw, FramePtrTy);
41 auto *Gep =
Builder.CreateConstInBoundsGEP2_32(FrameTy, FramePtr, 0, Index);
42 auto *
Load =
Builder.CreateLoad(FrameTy->getElementType(Index), Gep);
48 bool IsPrivateAndUnprocessed =
53 if (
auto *II = dyn_cast<IntrinsicInst>(&
I)) {
54 switch (II->getIntrinsicID()) {
57 case Intrinsic::coro_begin:
58 II->replaceAllUsesWith(II->getArgOperand(1));
60 case Intrinsic::coro_free:
61 II->replaceAllUsesWith(II->getArgOperand(1));
63 case Intrinsic::coro_alloc:
66 case Intrinsic::coro_async_resume:
67 II->replaceAllUsesWith(
70 case Intrinsic::coro_id:
71 case Intrinsic::coro_id_retcon:
72 case Intrinsic::coro_id_retcon_once:
73 case Intrinsic::coro_id_async:
76 case Intrinsic::coro_subfn_addr:
79 case Intrinsic::coro_end:
80 case Intrinsic::coro_suspend_retcon:
81 if (IsPrivateAndUnprocessed) {
86 case Intrinsic::coro_async_size_replace:
87 auto *
Target = cast<ConstantStruct>(
88 cast<GlobalVariable>(II->getArgOperand(0)->stripPointerCasts())
90 auto *
Source = cast<ConstantStruct>(
91 cast<GlobalVariable>(II->getArgOperand(1)->stripPointerCasts())
93 auto *TargetSize =
Target->getOperand(1);
94 auto *SourceSize =
Source->getOperand(1);
95 if (TargetSize->isElementWiseEqual(SourceSize)) {
98 auto *TargetRelativeFunOffset =
Target->getOperand(0);
100 Target->getType(), TargetRelativeFunOffset, SourceSize);
101 Target->replaceAllUsesWith(NewFuncPtrStruct);
104 II->eraseFromParent();
114 M, {
"llvm.coro.alloc",
"llvm.coro.begin",
"llvm.coro.subfn.addr",
115 "llvm.coro.free",
"llvm.coro.id",
"llvm.coro.id.retcon",
116 "llvm.coro.id.retcon.once",
"llvm.coro.async.size.replace",
117 "llvm.coro.async.resume"});
A set of analyses that are preserved following a run of a transformation pass.
This is an optimization pass for GlobalISel generic memory operations.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!std::is_same< PassT, PassManager >::value > addPass(PassT &&Pass)
static Constant * get(StructType *T, ArrayRef< Constant * > V)
Target - Wrapper for Target specific information.
FunctionAnalysisManager FAM
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
bool declaresIntrinsics(const Module &M, const std::initializer_list< StringRef >)
ModuleAnalysisManager MAM
This class represents the llvm.coro.subfn.addr instruction.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
inst_range instructions(Function *F)
ResumeKind getIndex() const
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
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...
Class to represent pointers.
A Module instance is used to store all the information related to an LLVM module.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
LLVMContext & getContext() const
All values hold a context through their type.
#define CORO_PRESPLIT_ATTR
static ConstantInt * getTrue(LLVMContext &Context)
static void lowerSubFn(IRBuilder<> &Builder, CoroSubFnInst *SubFn)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
static ConstantTokenNone * get(LLVMContext &Context)
Return the ConstantTokenNone.
static bool declaresCoroCleanupIntrinsics(const Module &M)
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
PreservedAnalyses run(IRUnitT &IR, AnalysisManagerT &AM, ExtraArgTs... ExtraArgs)
Run all of the passes in this manager over the given unit of IR.
A container for analyses that lazily runs them and caches their results.
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
LLVM Value Representation.
A pass to simplify and canonicalize the CFG of a function.