LLVM 22.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 | replaceCoroIsInRamp () |
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 ActiveSuspend, assert(), llvm::coro::Async, Builder, llvm::coro::Continuation, FKind, NewF, OrigF, llvm::coro::Retcon, llvm::coro::RetconOnce, Shape, Suffix, and TTI.
Referenced by createClone(), and llvm::coro::SwitchCloner::SwitchCloner().
|
inline |
|
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 876 of file CoroSplit.cpp.
References A(), ActiveSuspend, addAsyncContextAttrs(), addFramePointerAttrs(), addSwiftSelfAttrs(), assert(), llvm::coro::Async, llvm::SmallVectorTemplateCommon< T, typename >::back(), Builder, llvm::cast(), llvm::changeToUnreachable(), llvm::CloneFunctionInto(), deriveNewFramePointer(), llvm::Instruction::eraseFromParent(), llvm::GlobalValue::ExternalLinkage, llvm::MDString::get(), llvm::PoisonValue::get(), llvm::BasicBlock::getParent(), llvm::BasicBlock::getTerminator(), llvm::PointerType::getUnqual(), handleFinalSuspend(), llvm::LocalChangesOnly, NewF, NewFramePtr, OrigF, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::Value::replaceAllUsesWith(), replaceCoroEnds(), replaceCoroIsInRamp(), replaceCoroSuspends(), replaceEntryBlock(), replaceRetconOrAsyncSuspendUses(), replaceSwiftErrorOps(), llvm::MDNode::replaceWithUniqued(), llvm::coro::Retcon, llvm::coro::RetconOnce, llvm::coro::salvageDebugInfo(), Shape, llvm::BasicBlock::splitBasicBlock(), llvm::coro::Switch, llvm::CallInst::TCK_MustTail, TTI, updateScopeLine(), and VMap.
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 ActiveSuspend, assert(), llvm::coro::Async, BaseCloner(), create(), getFunction(), NewF, OrigF, llvm::coro::Retcon, llvm::coro::RetconOnce, Shape, Suffix, and TTI.
Referenced by llvm::coro::AnyRetconABI::splitCoroutine(), and llvm::coro::AsyncABI::splitCoroutine().
|
protected |
Derive the value of the new frame pointer.
Definition at line 742 of file CoroSplit.cpp.
References ActiveSuspend, assert(), llvm::coro::Async, Builder, llvm::cast(), llvm::Type::getInt8Ty(), llvm::PointerType::getUnqual(), llvm::InlineFunction(), InlineInfo, llvm_unreachable, NewF, llvm::coro::Retcon, llvm::coro::RetconOnce, Shape, llvm::coro::Switch, and VMap.
Referenced by create().
|
inline |
Definition at line 97 of file CoroCloner.h.
References assert(), and NewF.
Referenced by createClone(), and llvm::coro::SwitchCloner::createClone().
|
protected |
Definition at line 402 of file CoroSplit.cpp.
References assert(), Builder, llvm::cast(), Cond, llvm::Instruction::eraseFromParent(), llvm::BasicBlock::getTerminator(), isSwitchDestroyFunction(), NewF, NewFramePtr, llvm::coro::Shape::SwitchFieldIndex::Resume, Shape, llvm::BasicBlock::splitBasicBlock(), llvm::coro::Switch, and VMap.
Referenced by create().
|
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(), and replaceCoroSuspends().
|
protected |
Definition at line 551 of file CoroSplit.cpp.
References llvm::cast(), NewFramePtr, replaceCoroEnd(), Shape, and VMap.
Referenced by create().
|
protected |
Definition at line 560 of file CoroSplit.cpp.
References llvm::cast(), llvm::ConstantInt::getFalse(), II, OrigF, Shape, and VMap.
Referenced by create().
|
protected |
Definition at line 514 of file CoroSplit.cpp.
References ActiveSuspend, llvm::coro::Async, Builder, llvm::cast(), isSwitchDestroyFunction(), llvm::coro::Retcon, llvm::coro::RetconOnce, Shape, llvm::coro::Switch, and VMap.
Referenced by create().
|
protected |
Definition at line 673 of file CoroSplit.cpp.
References ActiveSuspend, assert(), llvm::coro::Async, Builder, llvm::cast(), llvm::dyn_cast(), F, I, instructions, llvm::isa(), llvm::DominatorTree::isReachableFromEntry(), llvm::make_early_inc_range(), NewF, llvm::coro::Retcon, llvm::coro::RetconOnce, Shape, Suffix, llvm::coro::Switch, and VMap.
Referenced by create().
|
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 466 of file CoroSplit.cpp.
References ActiveSuspend, assert(), llvm::coro::Async, Builder, llvm::dyn_cast(), llvm::enumerate(), llvm::PoisonValue::get(), I, llvm::isa(), llvm::make_early_inc_range(), NewF, llvm::coro::Retcon, llvm::coro::RetconOnce, Shape, and VMap.
Referenced by create().
|
protected |
Definition at line 636 of file CoroSplit.cpp.
References NewF, replaceSwiftErrorOps(), Shape, and VMap.
|
protected |
Definition at line 640 of file CoroSplit.cpp.
References collectDbgVariableRecords(), llvm::dyn_cast(), llvm::for_each(), I, llvm::isa(), llvm::isa_and_nonnull(), llvm::isPotentiallyReachable(), NewF, OrigF, 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(), create(), llvm::coro::SwitchCloner::create(), createClone(), deriveNewFramePointer(), replaceCoroSuspends(), replaceEntryBlock(), and replaceRetconOrAsyncSuspendUses().
|
protected |
Definition at line 49 of file CoroCloner.h.
Referenced by BaseCloner(), BaseCloner(), create(), deriveNewFramePointer(), handleFinalSuspend(), replaceCoroSuspends(), replaceEntryBlock(), and replaceRetconOrAsyncSuspendUses().
|
protected |
Definition at line 48 of file CoroCloner.h.
Referenced by BaseCloner(), BaseCloner(), llvm::coro::SwitchCloner::create(), llvm::coro::SwitchCloner::createClone(), isSwitchDestroyFunction(), and llvm::coro::SwitchCloner::SwitchCloner().
|
protected |
Definition at line 53 of file CoroCloner.h.
Referenced by BaseCloner(), create(), llvm::coro::SwitchCloner::create(), createClone(), deriveNewFramePointer(), getFunction(), handleFinalSuspend(), replaceEntryBlock(), replaceRetconOrAsyncSuspendUses(), replaceSwiftErrorOps(), and salvageDebugInfo().
|
protected |
Definition at line 54 of file CoroCloner.h.
Referenced by create(), handleFinalSuspend(), and replaceCoroEnds().
|
protected |
Definition at line 45 of file CoroCloner.h.
Referenced by BaseCloner(), BaseCloner(), create(), llvm::coro::SwitchCloner::create(), createClone(), llvm::coro::SwitchCloner::createClone(), replaceCoroIsInRamp(), salvageDebugInfo(), and llvm::coro::SwitchCloner::SwitchCloner().
|
protected |
Definition at line 47 of file CoroCloner.h.
Referenced by BaseCloner(), BaseCloner(), create(), llvm::coro::SwitchCloner::create(), createClone(), llvm::coro::SwitchCloner::createClone(), deriveNewFramePointer(), handleFinalSuspend(), replaceCoroEnds(), replaceCoroIsInRamp(), replaceCoroSuspends(), replaceEntryBlock(), replaceRetconOrAsyncSuspendUses(), replaceSwiftErrorOps(), and llvm::coro::SwitchCloner::SwitchCloner().
Definition at line 46 of file CoroCloner.h.
Referenced by BaseCloner(), BaseCloner(), llvm::coro::SwitchCloner::create(), createClone(), llvm::coro::SwitchCloner::createClone(), replaceEntryBlock(), and llvm::coro::SwitchCloner::SwitchCloner().
|
protected |
Definition at line 50 of file CoroCloner.h.
Referenced by BaseCloner(), BaseCloner(), create(), createClone(), llvm::coro::SwitchCloner::createClone(), and llvm::coro::SwitchCloner::SwitchCloner().
|
protected |
Definition at line 52 of file CoroCloner.h.
Referenced by create(), llvm::coro::SwitchCloner::create(), deriveNewFramePointer(), handleFinalSuspend(), replaceCoroEnds(), replaceCoroIsInRamp(), replaceCoroSuspends(), replaceEntryBlock(), replaceRetconOrAsyncSuspendUses(), and replaceSwiftErrorOps().