LLVM 20.0.0git
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::coro::BaseCloner Class Reference

#include "Transforms/Coroutines/CoroCloner.h"

Inheritance diagram for llvm::coro::BaseCloner:
Inheritance graph
[legend]

Public Member Functions

 BaseCloner (Function &OrigF, const Twine &Suffix, coro::Shape &Shape, CloneKind FKind, TargetTransformInfo &TTI)
 
virtual ~BaseCloner ()
 
FunctiongetFunction () const
 
virtual void create ()
 Clone the body of the original function into a resume function of some sort.
 

Static Public Member Functions

static FunctioncreateClone (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 ()
 
ValuederiveNewFramePointer ()
 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

FunctionOrigF
 
const TwineSuffix
 
coro::ShapeShape
 
CloneKind FKind
 
IRBuilder Builder
 
TargetTransformInfoTTI
 
ValueToValueMapTy VMap
 
FunctionNewF = nullptr
 
ValueNewFramePtr = nullptr
 
AnyCoroSuspendInstActiveSuspend = nullptr
 The active suspend instruction; meaningful only for continuation and async ABIs.
 

Detailed Description

Definition at line 43 of file CoroCloner.h.

Constructor & Destructor Documentation

◆ BaseCloner() [1/2]

llvm::coro::BaseCloner::BaseCloner ( Function OrigF,
const Twine Suffix,
coro::Shape Shape,
Function NewF,
AnyCoroSuspendInst ActiveSuspend,
TargetTransformInfo TTI 
)
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.

◆ BaseCloner() [2/2]

llvm::coro::BaseCloner::BaseCloner ( Function OrigF,
const Twine Suffix,
coro::Shape Shape,
CloneKind  FKind,
TargetTransformInfo TTI 
)
inline

Definition at line 76 of file CoroCloner.h.

◆ ~BaseCloner()

virtual llvm::coro::BaseCloner::~BaseCloner ( )
inlinevirtual

Definition at line 81 of file CoroCloner.h.

Member Function Documentation

◆ create()

void coro::BaseCloner::create ( )
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().

◆ createClone()

static Function * llvm::coro::BaseCloner::createClone ( Function OrigF,
const Twine Suffix,
coro::Shape Shape,
Function NewF,
AnyCoroSuspendInst ActiveSuspend,
TargetTransformInfo TTI 
)
inlinestatic

◆ deriveNewFramePointer()

Value * coro::BaseCloner::deriveNewFramePointer ( )
protected

◆ getFunction()

Function * llvm::coro::BaseCloner::getFunction ( ) const
inline

Definition at line 97 of file CoroCloner.h.

References assert(), and NewF.

Referenced by llvm::coro::SwitchCloner::createClone(), and createClone().

◆ handleFinalSuspend()

void coro::BaseCloner::handleFinalSuspend ( )
protected

◆ isSwitchDestroyFunction()

bool llvm::coro::BaseCloner::isSwitchDestroyFunction ( )
inlineprotected

◆ replaceCoroEnds()

void coro::BaseCloner::replaceCoroEnds ( )
protected

Definition at line 554 of file CoroSplit.cpp.

References llvm::coro::Shape::CoroEnds, and replaceCoroEnd().

◆ replaceCoroSuspends()

void coro::BaseCloner::replaceCoroSuspends ( )
protected

◆ replaceEntryBlock()

void coro::BaseCloner::replaceEntryBlock ( )
protected

◆ replaceRetconOrAsyncSuspendUses()

void coro::BaseCloner::replaceRetconOrAsyncSuspendUses ( )
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.

◆ replaceSwiftErrorOps()

void coro::BaseCloner::replaceSwiftErrorOps ( )
protected

Definition at line 633 of file CoroSplit.cpp.

References replaceSwiftErrorOps().

◆ salvageDebugInfo()

void coro::BaseCloner::salvageDebugInfo ( )
protected

Member Data Documentation

◆ ActiveSuspend

AnyCoroSuspendInst* llvm::coro::BaseCloner::ActiveSuspend = nullptr
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().

◆ Builder

IRBuilder llvm::coro::BaseCloner::Builder
protected

Definition at line 49 of file CoroCloner.h.

Referenced by handleFinalSuspend().

◆ FKind

CloneKind llvm::coro::BaseCloner::FKind
protected

Definition at line 48 of file CoroCloner.h.

Referenced by llvm::coro::SwitchCloner::createClone(), and isSwitchDestroyFunction().

◆ NewF

Function* llvm::coro::BaseCloner::NewF = nullptr
protected

Definition at line 53 of file CoroCloner.h.

Referenced by BaseCloner(), createClone(), getFunction(), and handleFinalSuspend().

◆ NewFramePtr

Value* llvm::coro::BaseCloner::NewFramePtr = nullptr
protected

Definition at line 54 of file CoroCloner.h.

Referenced by handleFinalSuspend().

◆ OrigF

Function& llvm::coro::BaseCloner::OrigF
protected

Definition at line 45 of file CoroCloner.h.

Referenced by llvm::coro::SwitchCloner::createClone(), and createClone().

◆ Shape

coro::Shape& llvm::coro::BaseCloner::Shape
protected

Definition at line 47 of file CoroCloner.h.

◆ Suffix

const Twine& llvm::coro::BaseCloner::Suffix
protected

Definition at line 46 of file CoroCloner.h.

Referenced by llvm::coro::SwitchCloner::createClone(), and createClone().

◆ TTI

TargetTransformInfo& llvm::coro::BaseCloner::TTI
protected

Definition at line 50 of file CoroCloner.h.

◆ VMap

ValueToValueMapTy llvm::coro::BaseCloner::VMap
protected

Definition at line 52 of file CoroCloner.h.

Referenced by handleFinalSuspend().


The documentation for this class was generated from the following files: