|
LLVM
10.0.0
|
#include "CoroInstr.h"#include "CoroInternal.h"#include "llvm/ADT/DenseMap.h"#include "llvm/ADT/SmallPtrSet.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/StringRef.h"#include "llvm/ADT/Twine.h"#include "llvm/Analysis/CallGraph.h"#include "llvm/Analysis/CallGraphSCCPass.h"#include "llvm/IR/Argument.h"#include "llvm/IR/Attributes.h"#include "llvm/IR/BasicBlock.h"#include "llvm/IR/CFG.h"#include "llvm/IR/CallSite.h"#include "llvm/IR/CallingConv.h"#include "llvm/IR/Constants.h"#include "llvm/IR/DataLayout.h"#include "llvm/IR/DerivedTypes.h"#include "llvm/IR/Function.h"#include "llvm/IR/GlobalValue.h"#include "llvm/IR/GlobalVariable.h"#include "llvm/IR/IRBuilder.h"#include "llvm/IR/InstIterator.h"#include "llvm/IR/InstrTypes.h"#include "llvm/IR/Instruction.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/LLVMContext.h"#include "llvm/IR/LegacyPassManager.h"#include "llvm/IR/Module.h"#include "llvm/IR/Type.h"#include "llvm/IR/Value.h"#include "llvm/IR/Verifier.h"#include "llvm/InitializePasses.h"#include "llvm/Pass.h"#include "llvm/Support/Casting.h"#include "llvm/Support/Debug.h"#include "llvm/Support/PrettyStackTrace.h"#include "llvm/Support/raw_ostream.h"#include "llvm/Transforms/Scalar.h"#include "llvm/Transforms/Utils/BasicBlockUtils.h"#include "llvm/Transforms/Utils/Cloning.h"#include "llvm/Transforms/Utils/Local.h"#include "llvm/Transforms/Utils/ValueMapper.h"#include <cassert>#include <cstddef>#include <cstdint>#include <initializer_list>#include <iterator>Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "coro-split" |
Variables | |
| coro | split |
| coro Split coroutine into a set of functions driving its state | machine |
| coro Split coroutine into a set of functions driving its state | false |
| #define DEBUG_TYPE "coro-split" |
Definition at line 73 of file CoroSplit.cpp.
|
static |
Definition at line 960 of file CoroSplit.cpp.
References I, llvm::instructions(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::removeUnreachableBlocks(), simplifyTerminatorLeadingToRet(), and llvm::CallInst::TCK_MustTail.
Referenced by splitSwitchCoroutine().
|
static |
Definition at line 778 of file CoroSplit.cpp.
Referenced by splitSwitchCoroutine().
|
static |
Definition at line 395 of file CoroSplit.cpp.
References llvm::Function::addParamAttr(), llvm::AMDGPU::HSAMD::Kernel::Key::Args, assert(), llvm::Function::Create(), llvm::dyn_cast(), E, llvm::SmallVectorTemplateCommon< T, typename >::front(), llvm::UndefValue::get(), llvm::Module::getFunctionList(), llvm::Value::getName(), llvm::GlobalValue::getParent(), llvm::coro::Shape::getResumeFunctionType(), I, llvm::iplist_impl< IntrusiveListT, TraitsT >::insert(), llvm::NoAlias, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::Value::replaceAllUsesWith(), replaceCoroEnd(), llvm::coro::Retcon, llvm::coro::RetconOnce, llvm::SmallVectorBase::size(), and llvm::coro::Switch.
Referenced by replaceSwiftErrorOps(), and splitRetconCoroutine().
|
static |
Definition at line 1428 of file CoroSplit.cpp.
References llvm::Function::addFnAttr(), C, CORO_DEVIRT_TRIGGER_FN, llvm::BasicBlock::Create(), llvm::Function::Create(), llvm::ReturnInst::Create(), llvm::FunctionType::get(), llvm::Module::getContext(), llvm::Module::getFunction(), llvm::Type::getInt8PtrTy(), llvm::CallGraph::getModule(), and llvm::Type::getVoidTy().
Referenced by replaceAllPrepares().
|
static |
Definition at line 265 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), C, llvm::coro::Shape::CoroSuspends, llvm::BasicBlock::Create(), llvm::PHINode::Create(), llvm::IRBuilder< T, Inserter >::CreateLoad(), llvm::IRBuilder< T, Inserter >::CreateStore(), llvm::IRBuilder< T, Inserter >::CreateStructGEP(), llvm::IRBuilder< T, Inserter >::CreateSwitch(), llvm::IRBuilder< T, Inserter >::CreateUnreachable(), llvm::coro::Shape::FramePtr, llvm::coro::Shape::FrameTy, llvm::ConstantPointerNull::get(), llvm::ConstantTokenNone::get(), llvm::Function::getContext(), llvm::coro::Shape::getIndex(), llvm::coro::Shape::getIndexType(), llvm::IRBuilderBase::getInt8(), llvm::IRBuilderBase::getInt8Ty(), llvm::BasicBlock::getTerminator(), llvm::coro::Shape::SwitchFieldIndex::Index, llvm::SPII::Load, llvm::Value::replaceAllUsesWith(), llvm::coro::Shape::SwitchFieldIndex::Resume, llvm::coro::Shape::SwitchLoweringStorage::ResumeEntryBlock, llvm::coro::Shape::SwitchLoweringStorage::ResumeSwitch, llvm::IRBuilderBase::SetInsertPoint(), llvm::BasicBlock::splitBasicBlock(), llvm::coro::Switch, and llvm::coro::Shape::SwitchLowering.
Referenced by splitSwitchCoroutine().
|
static |
Definition at line 986 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, llvm::coro::Shape::CoroBegin, llvm::IRBuilder< T, Inserter >::CreateAlloca(), llvm::IRBuilder< T, Inserter >::CreateBitCast(), llvm::coro::Shape::FrameTy, llvm::UndefValue::get(), llvm::AnyCoroIdInst::getCoroAlloc(), llvm::IRBuilderBase::getFalse(), llvm::CoroBeginInst::getId(), llvm::IRBuilderBase::getInt8PtrTy(), llvm::Value::replaceAllUsesWith(), llvm::coro::replaceCoroFree(), llvm::coro::Retcon, llvm::coro::RetconOnce, and llvm::coro::Switch.
Referenced by splitCoroutine().
|
static |
Definition at line 1061 of file CoroSplit.cpp.
References llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getNextNode(), llvm::Instruction::getParent(), hasCallsInBlockBetween(), and hasCallsInBlocksBetween().
Referenced by simplifySuspendPoint().
|
static |
Definition at line 1020 of file CoroSplit.cpp.
References I.
Referenced by hasCallsBetween(), and hasCallsInBlocksBetween().
|
static |
Definition at line 1032 of file CoroSplit.cpp.
References llvm::SmallPtrSetImpl< PtrType >::count(), llvm::SmallVectorBase::empty(), llvm::SmallPtrSetImpl< PtrType >::erase(), hasCallsInBlockBetween(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::predecessors(), and llvm::SmallVectorTemplateBase< T >::push_back().
Referenced by hasCallsBetween().
| INITIALIZE_PASS_BEGIN | ( | CoroSplitLegacy | , |
| "coro-split" | , | ||
| "Split coroutine into a set of functions driving its state machine" | , | ||
| false | , | ||
| false | |||
| ) |
Referenced by replaceAllPrepares().
|
static |
Definition at line 161 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), llvm::coro::Shape::emitDealloc(), llvm::coro::Shape::RetconLoweringStorage::IsFrameInlineInStorage, llvm::coro::Retcon, llvm::coro::Shape::RetconLowering, and llvm::coro::RetconOnce.
|
static |
Definition at line 869 of file CoroSplit.cpp.
References llvm::legacy::FunctionPassManager::add(), llvm::createCFGSimplificationPass(), llvm::createEarlyCSEPass(), llvm::createSCCPPass(), llvm::GlobalValue::getParent(), llvm::removeUnreachableBlocks(), and llvm::verifyFunction().
Referenced by splitCoroutine(), and splitSwitchCoroutine().
Definition at line 1396 of file CoroSplit.cpp.
References llvm::Function::addFnAttr(), assert(), Context, CORO_DEVIRT_TRIGGER_FN, CORO_PRESPLIT_ATTR, llvm::CallInst::Create(), F(), llvm::FunctionType::get(), llvm::ConstantPointerNull::get(), llvm::CallGraph::getCallsExternalNode(), llvm::Function::getContext(), llvm::Function::getEntryBlock(), llvm::Module::getFunction(), llvm::Type::getInt8PtrTy(), llvm::GlobalValue::getParent(), llvm::BasicBlock::getTerminator(), llvm::Type::getVoidTy(), llvm::coro::LowererBase::makeSubFnCall(), PREPARED_FOR_SPLIT, and llvm::CoroSubFnInst::RestartTrigger.
Referenced by replaceAllPrepares().
|
static |
Remove calls to llvm.coro.end in the original function.
Definition at line 786 of file CoroSplit.cpp.
Referenced by splitCoroutine().
Remove calls to llvm.coro.prepare.retcon, a barrier meant to prevent IPO from operating on calls to a retcon coroutine before it's been split.
This is only safe to do after we've split all retcon coroutines in the module. We can do that this in this pass because this pass does promise to split all retcon coroutines (as opposed to switch coroutines, which are lowered in multiple stages).
Definition at line 1511 of file CoroSplit.cpp.
References CORO_PRESPLIT_ATTR, createDevirtTriggerFunc(), llvm::dbgs(), llvm::coro::declaresIntrinsics(), llvm::CallGraphSCCPass::doInitialization(), llvm::SmallVectorBase::empty(), F(), llvm::CallGraphSCCPass::getAnalysisUsage(), llvm::CallGraphSCC::getCallGraph(), llvm::Module::getFunction(), llvm::CallGraph::getModule(), llvm::PassRegistry::getPassRegistry(), llvm::Attribute::getValueAsString(), INITIALIZE_PASS_BEGIN(), INITIALIZE_PASS_DEPENDENCY, INITIALIZE_PASS_END(), llvm::initializeCoroSplitLegacyPass(), LLVM_DEBUG, prepareForSplit(), llvm::SmallVectorTemplateBase< T >::push_back(), replacePrepare(), splitCoroutine(), UNPREPARED_FOR_SPLIT, llvm::Value::use_begin(), and llvm::Value::use_end().
|
static |
Definition at line 250 of file CoroSplit.cpp.
Referenced by createCloneDeclaration().
|
static |
Replace a non-unwind call to llvm.coro.end.
Definition at line 173 of file CoroSplit.cpp.
|
static |
Definition at line 792 of file CoroSplit.cpp.
References llvm::coro::Shape::CoroSizes, llvm::Instruction::eraseFromParent(), llvm::coro::Shape::FrameTy, llvm::ConstantInt::get(), llvm::Module::getDataLayout(), llvm::DataLayout::getTypeAllocSize(), llvm::Value::replaceAllUsesWith(), and Size.
Referenced by splitCoroutine().
Replace a call to llvm.coro.prepare.retcon.
Definition at line 1451 of file CoroSplit.cpp.
References llvm::CallGraphNode::addCalledFunction(), llvm::dyn_cast(), llvm::Instruction::eraseFromParent(), llvm::CallBase::getArgOperand(), llvm::Instruction::getFunction(), llvm::Use::getUser(), llvm::CallGraphNode::removeCallEdgeFor(), llvm::Value::replaceAllUsesWith(), llvm::Value::stripPointerCasts(), llvm::Value::use_begin(), llvm::Value::use_end(), and llvm::Value::uses().
Referenced by replaceAllPrepares().
|
static |
Definition at line 499 of file CoroSplit.cpp.
References Arg, llvm::Function::args(), assert(), llvm::MCID::Branch, llvm::changeToUnreachable(), llvm::CloneFunctionInto(), Context, llvm::IRBuilder< T, Inserter >::CreateAlloca(), createCloneDeclaration(), llvm::GlobalValue::ExternalLinkage, llvm::AttributeList::FunctionIndex, llvm::UndefValue::get(), llvm::Function::getEntryBlock(), llvm::BasicBlock::getFirstNonPHIOrDbg(), llvm::Type::getInt8PtrTy(), llvm::CallBase::getNumArgOperands(), llvm::Type::getPointerElementType(), llvm::Value::getType(), llvm_unreachable, llvm::NoAlias, llvm::Value::replaceAllUsesWith(), llvm::coro::replaceCoroFree(), llvm::coro::Retcon, llvm::coro::RetconOnce, llvm::MCID::Return, llvm::coro::Shape::SwiftErrorOps, llvm::coro::Switch, and llvm::Value::takeName().
Referenced by splitCoroutine().
|
static |
Replace an unwind call to llvm.coro.end.
Definition at line 223 of file CoroSplit.cpp.
|
static |
Definition at line 892 of file CoroSplit.cpp.
References llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::Instruction::getParent(), llvm::BasicBlock::phis(), and VI.
Referenced by simplifyTerminatorLeadingToRet().
|
static |
Definition at line 820 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, llvm::AMDGPU::HSAMD::Kernel::Key::Args, assert(), llvm::ArrayRef< T >::begin(), C, llvm::ArrayRef< T >::end(), llvm::ArrayType::get(), llvm::ConstantArray::get(), llvm::Function::getContext(), llvm::Type::getInt8PtrTy(), llvm::Value::getName(), llvm::ConstantExpr::getPointerCast(), llvm::coro::Shape::getSwitchCoroId(), llvm::GlobalValue::PrivateLinkage, llvm::CoroIdInst::setInfo(), and llvm::coro::Switch.
Referenced by splitSwitchCoroutine().
|
static |
Definition at line 1086 of file CoroSplit.cpp.
References Callee, llvm::BranchInst::Create(), llvm::dyn_cast(), llvm::Instruction::eraseFromParent(), llvm::CoroSuspendInst::getCoroSave(), llvm::Instruction::getParent(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getPrevNode(), llvm::BasicBlock::getSinglePredecessor(), hasCallsBetween(), I, and llvm::Value::replaceAllUsesWith().
Referenced by simplifySuspendPoints().
|
static |
Definition at line 1148 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, llvm::coro::Shape::CoroBegin, llvm::coro::Shape::CoroSuspends, I, N, simplifySuspendPoint(), std::swap(), and llvm::coro::Switch.
Referenced by splitCoroutine().
|
static |
Definition at line 909 of file CoroSplit.cpp.
References llvm::ISD::BR, llvm::Instruction::clone(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::BasicBlock::getFirstNonPHIOrDbgOrLifetime(), llvm::Instruction::getParent(), I, if(), llvm::Instruction::isTerminator(), llvm::BasicBlock::phis(), llvm::ReplaceInstWithInst(), scanPHIsAndUpdateValueMap(), and SI.
Referenced by addMustTailToCoroResumes().
|
static |
Definition at line 1345 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, llvm_unreachable, llvm::coro::Retcon, llvm::coro::RetconOnce, splitRetconCoroutine(), splitSwitchCoroutine(), and llvm::coro::Switch.
Referenced by replaceAllPrepares(), and splitCoroutine().
|
static |
Definition at line 1357 of file CoroSplit.cpp.
References llvm::coro::buildCoroutineFrame(), llvm::coro::Shape::CoroBegin, llvm::coro::Shape::CoroSuspends, handleNoSuspendCoroutine(), postSplitCleanup(), removeCoroEnds(), llvm::removeUnreachableBlocks(), replaceFrameSize(), replaceSwiftErrorOps(), simplifySuspendPoints(), splitCoroutine(), and llvm::coro::updateCallGraph().
|
static |
Definition at line 1202 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), llvm::MCID::Branch, llvm::coro::Shape::CoroBegin, llvm::coro::Shape::CoroSuspends, llvm::BasicBlock::Create(), llvm::IRBuilder< T, Inserter >::CreateBitCast(), createCloneDeclaration(), llvm::IRBuilder< T, Inserter >::CreateInsertValue(), llvm::IRBuilder< T, Inserter >::CreatePHI(), llvm::IRBuilder< T, Inserter >::CreateRet(), llvm::IRBuilder< T, Inserter >::CreateStore(), llvm::numbers::e, E, llvm::coro::Shape::emitAlloc(), llvm::SmallVectorBase::empty(), F(), llvm::coro::Shape::FramePtr, llvm::coro::Shape::FrameTy, llvm::UndefValue::get(), llvm::Function::getContext(), llvm::Module::getDataLayout(), llvm::CoroBeginInst::getId(), llvm::IRBuilderBase::getInt64(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::GlobalValue::getParent(), llvm::coro::Shape::getRetconResultTypes(), llvm::Function::getReturnType(), llvm::Value::getType(), llvm::DataLayout::getTypeAllocSize(), llvm::TrackingVH< ValueTy >::getValPtr(), I, llvm::coro::Shape::RetconLoweringStorage::IsFrameInlineInStorage, llvm::NoAlias, print(), llvm::Value::printAsOperand(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::Function::removeAttribute(), llvm::Function::removeFnAttr(), llvm::Value::replaceAllUsesWith(), llvm::SmallVectorImpl< T >::reserve(), llvm::coro::Retcon, llvm::coro::Shape::RetconLowering, llvm::coro::RetconOnce, llvm::coro::Shape::RetconLoweringStorage::ReturnBlock, llvm::AttributeList::ReturnIndex, Size, and llvm::SmallVectorBase::size().
Referenced by splitCoroutine().
|
static |
Definition at line 1170 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, addMustTailToCoroResumes(), assert(), createClone(), createResumeEntryBlock(), llvm::SmallVectorBase::empty(), postSplitCleanup(), llvm::SmallVectorTemplateBase< T >::push_back(), setCoroInfo(), llvm::coro::Switch, and updateCoroFrame().
Referenced by splitCoroutine().
|
static |
Definition at line 844 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), llvm::IRBuilder< T, Inserter >::CreateStructGEP(), llvm::coro::Shape::SwitchFieldIndex::Destroy, llvm::coro::Shape::FramePtr, llvm::coro::Shape::FrameTy, llvm::AnyCoroIdInst::getCoroAlloc(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getNextNode(), llvm::coro::Shape::getSwitchCoroId(), llvm::coro::Shape::SwitchFieldIndex::Resume, and llvm::coro::Switch.
Referenced by splitSwitchCoroutine().
| coro Split coroutine into a set of functions driving its state false |
Definition at line 1612 of file CoroSplit.cpp.
| coro Split coroutine into a set of functions driving its state machine |
Definition at line 1612 of file CoroSplit.cpp.
| coro split |
Definition at line 1612 of file CoroSplit.cpp.
Referenced by llvm::createControlHeightReductionLegacyPass().
1.8.13