LLVM 20.0.0git
|
#include "Transforms/Coroutines/CoroCloner.h"
Public Member Functions | |
BaseCloner (Function &OrigF, const Twine &Suffix, coro::Shape &Shape, CloneKind FKind, TargetTransformInfo &TTI) | |
virtual | ~BaseCloner () |
Function * | getFunction () const |
virtual void | create () |
Clone the body of the original function into a resume function of some sort. | |
Static Public Member Functions | |
static Function * | createClone (Function &OrigF, const Twine &Suffix, coro::Shape &Shape, Function *NewF, AnyCoroSuspendInst *ActiveSuspend, TargetTransformInfo &TTI) |
Create a clone for a continuation lowering. | |
Protected Member Functions | |
BaseCloner (Function &OrigF, const Twine &Suffix, coro::Shape &Shape, Function *NewF, AnyCoroSuspendInst *ActiveSuspend, TargetTransformInfo &TTI) | |
Create a cloner for a continuation lowering. | |
bool | isSwitchDestroyFunction () |
void | replaceEntryBlock () |
Value * | deriveNewFramePointer () |
Derive the value of the new frame pointer. | |
void | replaceRetconOrAsyncSuspendUses () |
Replace uses of the active llvm.coro.suspend.retcon/async call with the arguments to the continuation function. | |
void | replaceCoroSuspends () |
void | replaceCoroEnds () |
void | replaceSwiftErrorOps () |
void | salvageDebugInfo () |
void | handleFinalSuspend () |
Protected Attributes | |
Function & | OrigF |
const Twine & | Suffix |
coro::Shape & | Shape |
CloneKind | FKind |
IRBuilder | Builder |
TargetTransformInfo & | TTI |
ValueToValueMapTy | VMap |
Function * | NewF = nullptr |
Value * | NewFramePtr = nullptr |
AnyCoroSuspendInst * | ActiveSuspend = nullptr |
The active suspend instruction; meaningful only for continuation and async ABIs. | |
Definition at line 43 of file CoroCloner.h.
|
inlineprotected |
Create a cloner for a continuation lowering.
Definition at line 61 of file CoroCloner.h.
References llvm::coro::Shape::ABI, ActiveSuspend, assert(), llvm::coro::Async, NewF, llvm::coro::Retcon, and llvm::coro::RetconOnce.
|
inline |
Definition at line 76 of file CoroCloner.h.
|
inlinevirtual |
Definition at line 81 of file CoroCloner.h.
|
virtual |
Clone the body of the original function into a resume function of some sort.
FIXME: Is it really good to add the NoAlias attribute?
Reimplemented in llvm::coro::SwitchCloner.
Definition at line 866 of file CoroSplit.cpp.
References A, llvm::coro::Shape::ABI, addAsyncContextAttrs(), addFramePointerAttrs(), addSwiftSelfAttrs(), assert(), llvm::coro::Async, llvm::coro::Shape::AsyncLowering, llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::changeToUnreachable(), llvm::CloneFunctionInto(), llvm::coro::Shape::AsyncLoweringStorage::ContextArgNo, llvm::coro::Shape::CoroBegin, llvm::Instruction::eraseFromParent(), llvm::GlobalValue::ExternalLinkage, llvm::coro::Shape::FrameAlign, llvm::coro::Shape::FramePtr, llvm::coro::Shape::FrameSize, llvm::MDNode::get(), llvm::MDString::get(), llvm::PoisonValue::get(), llvm::Function::getAttributes(), llvm::BasicBlock::getParent(), llvm::coro::Shape::getResumeFunctionCC(), llvm::coro::Shape::getRetconCoroId(), llvm::AnyCoroIdRetconInst::getStorageAlignment(), llvm::AnyCoroIdRetconInst::getStorageSize(), llvm::DILocalScope::getSubprogram(), llvm::BasicBlock::getTerminator(), llvm::PointerType::getUnqual(), llvm::coro::Shape::SwitchLoweringStorage::HasFinalSuspend, llvm::LocalChangesOnly, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::Value::replaceAllUsesWith(), replaceSwiftErrorOps(), llvm::coro::Shape::RetconLoweringStorage::ResumePrototype, llvm::coro::Retcon, llvm::coro::Shape::RetconLowering, llvm::coro::RetconOnce, llvm::coro::salvageDebugInfo(), llvm::BasicBlock::splitBasicBlock(), llvm::TargetTransformInfo::supportsTailCallFor(), llvm::coro::Switch, llvm::coro::Shape::SwitchLowering, llvm::coro::Shape::SymmetricTransfers, llvm::Value::takeName(), llvm::CallInst::TCK_MustTail, and updateScopeLine().
Referenced by llvm::coro::SwitchCloner::create(), and createClone().
|
inlinestatic |
Create a clone for a continuation lowering.
Definition at line 84 of file CoroCloner.h.
References llvm::coro::Shape::ABI, ActiveSuspend, assert(), llvm::coro::Async, create(), getFunction(), NewF, OrigF, llvm::coro::Retcon, llvm::coro::RetconOnce, and Suffix.
Referenced by llvm::coro::AsyncABI::splitCoroutine(), and llvm::coro::AnyRetconABI::splitCoroutine().
|
protected |
Derive the value of the new frame pointer.
Definition at line 742 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), llvm::coro::Async, llvm::coro::Shape::AsyncLowering, llvm::coro::Shape::AsyncLoweringStorage::FrameOffset, llvm::coro::Shape::FrameTy, llvm::Type::getContext(), llvm::Type::getInt8Ty(), llvm::PointerType::getUnqual(), llvm::InlineFunction(), InlineInfo, llvm::coro::Shape::RetconLoweringStorage::IsFrameInlineInStorage, llvm_unreachable, llvm::coro::Retcon, llvm::coro::Shape::RetconLowering, llvm::coro::RetconOnce, and llvm::coro::Switch.
|
inline |
Definition at line 97 of file CoroCloner.h.
References assert(), and NewF.
Referenced by llvm::coro::SwitchCloner::createClone(), and createClone().
|
protected |
Definition at line 405 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), Builder, Cond, llvm::IRBuilderBase::CreateBr(), llvm::IRBuilderBase::CreateCondBr(), llvm::IRBuilderBase::CreateIsNull(), llvm::IRBuilderBase::CreateLoad(), llvm::IRBuilderBase::CreateStructGEP(), llvm::Instruction::eraseFromParent(), llvm::coro::Shape::FrameTy, llvm::coro::Shape::getSwitchResumePointerType(), llvm::BasicBlock::getTerminator(), llvm::coro::Shape::SwitchLoweringStorage::HasFinalSuspend, llvm::coro::Shape::SwitchLoweringStorage::HasUnwindCoroEnd, llvm::Function::isCoroOnlyDestroyWhenComplete(), isSwitchDestroyFunction(), NewF, NewFramePtr, llvm::coro::Shape::SwitchFieldIndex::Resume, llvm::coro::Shape::SwitchLoweringStorage::ResumeSwitch, llvm::IRBuilderBase::SetInsertPoint(), llvm::BasicBlock::splitBasicBlock(), llvm::coro::Switch, llvm::coro::Shape::SwitchLowering, and VMap.
|
inlineprotected |
Definition at line 105 of file CoroCloner.h.
References llvm::coro::Async, llvm::coro::Continuation, FKind, llvm_unreachable, llvm::coro::SwitchCleanup, llvm::coro::SwitchResume, and llvm::coro::SwitchUnwind.
Referenced by handleFinalSuspend().
|
protected |
Definition at line 554 of file CoroSplit.cpp.
References llvm::coro::Shape::CoroEnds, and replaceCoroEnd().
|
protected |
Definition at line 517 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, llvm::coro::Async, llvm::coro::Shape::CoroSuspends, llvm::coro::Retcon, llvm::coro::RetconOnce, and llvm::coro::Switch.
|
protected |
Definition at line 674 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, llvm::coro::Shape::AllocaSpillBlock, assert(), llvm::coro::Async, F, I, instructions, llvm::DominatorTree::isReachableFromEntry(), llvm::make_early_inc_range(), llvm::coro::Shape::SwitchLoweringStorage::ResumeEntryBlock, llvm::coro::Retcon, llvm::coro::RetconOnce, llvm::coro::Switch, and llvm::coro::Shape::SwitchLowering.
|
protected |
Replace uses of the active llvm.coro.suspend.retcon/async call with the arguments to the continuation function.
This assumes that the builder has a meaningful insertion point.
Definition at line 469 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), llvm::coro::Async, llvm::enumerate(), llvm::PoisonValue::get(), I, Idx, llvm::make_early_inc_range(), llvm::Value::replaceAllUsesWith(), llvm::coro::Retcon, and llvm::coro::RetconOnce.
|
protected |
Definition at line 633 of file CoroSplit.cpp.
References replaceSwiftErrorOps().
|
protected |
Definition at line 637 of file CoroSplit.cpp.
References collectDbgVariableIntrinsics(), llvm::for_each(), I, llvm::Triple::isArch64Bit(), llvm::isPotentiallyReachable(), llvm::coro::salvageDebugInfo(), llvm::Value::users(), and Uses.
|
protected |
The active suspend instruction; meaningful only for continuation and async ABIs.
Definition at line 58 of file CoroCloner.h.
Referenced by BaseCloner(), and createClone().
|
protected |
Definition at line 49 of file CoroCloner.h.
Referenced by handleFinalSuspend().
|
protected |
Definition at line 48 of file CoroCloner.h.
Referenced by llvm::coro::SwitchCloner::createClone(), and isSwitchDestroyFunction().
|
protected |
Definition at line 53 of file CoroCloner.h.
Referenced by BaseCloner(), createClone(), getFunction(), and handleFinalSuspend().
|
protected |
Definition at line 54 of file CoroCloner.h.
Referenced by handleFinalSuspend().
|
protected |
Definition at line 45 of file CoroCloner.h.
Referenced by llvm::coro::SwitchCloner::createClone(), and createClone().
|
protected |
Definition at line 47 of file CoroCloner.h.
Definition at line 46 of file CoroCloner.h.
Referenced by llvm::coro::SwitchCloner::createClone(), and createClone().
|
protected |
Definition at line 50 of file CoroCloner.h.
|
protected |
Definition at line 52 of file CoroCloner.h.
Referenced by handleFinalSuspend().