LLVM
8.0.1
|
#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/Transforms/Utils/Local.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/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.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/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" |
#define DEBUG_TYPE "coro-split" |
Definition at line 72 of file CoroSplit.cpp.
|
static |
Definition at line 497 of file CoroSplit.cpp.
References I, llvm::instructions(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::removeUnreachableBlocks(), simplifyTerminatorLeadingToRet(), and llvm::CallInst::TCK_MustTail.
Referenced by splitCoroutine().
|
static |
Definition at line 245 of file CoroSplit.cpp.
References llvm::Function::addParamAttr(), llvm::coro::Shape::AllocaSpillBlock, llvm::Function::args(), llvm::changeToUnreachable(), llvm::CloneFunctionInto(), llvm::coro::Shape::CoroBegin, llvm::coro::Shape::CoroEnds, llvm::coro::Shape::CoroSuspends, llvm::Function::Create(), llvm::BranchInst::Create(), llvm::CallingConv::Fast, llvm::coro::Shape::FramePtr, llvm::coro::Shape::FrameTy, llvm::UndefValue::get(), llvm::CoroBeginInst::getId(), llvm::Type::getInt8PtrTy(), llvm::Value::getName(), llvm::GlobalValue::getParent(), handleFinalSuspend(), llvm::coro::Shape::HasFinalSuspend, llvm::Attribute::NoAlias, llvm::Attribute::NonNull, llvm::Value::replaceAllUsesWith(), llvm::coro::replaceCoroFree(), replaceFallthroughCoroEnd(), replaceUnwindCoroEnds(), llvm::coro::Shape::ResumeSwitch, llvm::MCID::Return, llvm::AttributeList::ReturnIndex, and llvm::AttributeFuncs::typeIncompatible().
Referenced by splitCoroutine().
|
static |
Definition at line 857 of file CoroSplit.cpp.
References llvm::Function::addFnAttr(), llvm::Attribute::AlwaysInline, 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().
|
static |
Definition at line 76 of file CoroSplit.cpp.
References C, llvm::coro::Shape::CoroSuspends, llvm::BasicBlock::Create(), llvm::PHINode::Create(), llvm::IRBuilder< T, Inserter >::CreateConstInBoundsGEP2_32(), llvm::IRBuilder< T, Inserter >::CreateLoad(), llvm::IRBuilder< T, Inserter >::CreateStore(), 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::CoroSuspendInst::getCoroSave(), llvm::coro::Shape::getIndex(), llvm::IRBuilderBase::getInt8(), llvm::IRBuilderBase::getInt8Ty(), llvm::Value::getName(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getNextNode(), llvm::Instruction::getParent(), llvm::coro::Shape::IndexField, llvm::CoroSuspendInst::isFinal(), llvm::Value::replaceAllUsesWith(), llvm::coro::Shape::ResumeSwitch, llvm::IRBuilderBase::SetInsertPoint(), and llvm::BasicBlock::splitBasicBlock().
Referenced by splitCoroutine().
|
static |
Definition at line 690 of file CoroSplit.cpp.
References llvm::SmallPtrSetImpl< PtrType >::count(), llvm::SmallVectorBase::empty(), llvm::Instruction::getParent(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::predecessors(), and llvm::SmallVectorTemplateBase< T >::push_back().
Referenced by relocateInstructionBefore().
|
static |
Definition at line 708 of file CoroSplit.cpp.
References llvm::SmallPtrSetImpl< PtrType >::count(), llvm::dbgs(), llvm::dyn_cast(), llvm::SmallVectorBase::empty(), llvm::Instruction::getParent(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), LLVM_DEBUG, llvm::User::operands(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T >::push_back(), and SI.
Referenced by relocateInstructionBefore().
|
static |
Definition at line 220 of file CoroSplit.cpp.
References assert(), llvm::SwitchInst::case_end(), llvm::IRBuilder< T, Inserter >::CreateCondBr(), llvm::IRBuilder< T, Inserter >::CreateConstInBoundsGEP2_32(), llvm::IRBuilder< T, Inserter >::CreateICmpEQ(), llvm::IRBuilder< T, Inserter >::CreateLoad(), llvm::Instruction::eraseFromParent(), llvm::coro::Shape::FrameTy, llvm::ConstantPointerNull::get(), llvm::Instruction::getParent(), llvm::BasicBlock::getTerminator(), llvm::coro::Shape::HasFinalSuspend, llvm::SPII::Load, llvm::SwitchInst::removeCase(), llvm::IRBuilderBase::SetInsertPoint(), and llvm::BasicBlock::splitBasicBlock().
Referenced by createClone().
|
static |
Definition at line 523 of file CoroSplit.cpp.
References llvm::IRBuilder< T, Inserter >::CreateAlloca(), llvm::IRBuilder< T, Inserter >::CreateBitCast(), llvm::Instruction::eraseFromParent(), llvm::CoroIdInst::getCoroAlloc(), llvm::IRBuilderBase::getFalse(), llvm::CoroBeginInst::getId(), llvm::IRBuilderBase::getInt8PtrTy(), llvm::CoroBeginInst::getMem(), llvm::Value::replaceAllUsesWith(), and llvm::coro::replaceCoroFree().
Referenced by splitCoroutine().
|
static |
Definition at line 585 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 544 of file CoroSplit.cpp.
References I.
Referenced by hasCallsBetween(), and hasCallsInBlocksBetween().
|
static |
Definition at line 556 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 | ( | CoroSplit | , |
"coro-split" | , | ||
"Split coroutine into a set of functions driving its state machine" | , | ||
false | , | ||
false | |||
) |
Definition at line 944 of file CoroSplit.cpp.
|
static |
Definition at line 423 of file CoroSplit.cpp.
References llvm::legacy::FunctionPassManager::add(), llvm::createCFGSimplificationPass(), llvm::createEarlyCSEPass(), llvm::createSCCPPass(), llvm::createVerifierPass(), llvm::GlobalValue::getParent(), and llvm::removeUnreachableBlocks().
Referenced by splitCoroutine().
Definition at line 829 of file CoroSplit.cpp.
References llvm::Function::addFnAttr(), assert(), CORO_DEVIRT_TRIGGER_FN, CORO_PRESPLIT_ATTR, llvm::CallInst::Create(), F(), 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::coro::LowererBase::makeSubFnCall(), PREPARED_FOR_SPLIT, and llvm::CoroSubFnInst::RestartTrigger.
|
static |
Definition at line 756 of file CoroSplit.cpp.
References B, llvm::BasicBlock::begin(), E, llvm::BasicBlock::end(), getCoroBeginPredBlocks(), llvm::Function::getEntryBlock(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getNextNode(), getNotRelocatableInstructions(), I, and llvm::Instruction::moveBefore().
Referenced by splitCoroutine().
|
static |
Definition at line 339 of file CoroSplit.cpp.
References Context, llvm::coro::Shape::CoroEnds, llvm::Instruction::eraseFromParent(), llvm::ConstantInt::getFalse(), and llvm::Value::replaceAllUsesWith().
Referenced by splitCoroutine().
|
static |
Definition at line 173 of file CoroSplit.cpp.
Referenced by createClone().
|
static |
Definition at line 352 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().
|
static |
Definition at line 186 of file CoroSplit.cpp.
References Context, llvm::coro::Shape::CoroEnds, llvm::CleanupReturnInst::Create(), llvm::ConstantInt::getTrue(), llvm::CoroEndInst::isUnwind(), and llvm::LLVMContext::OB_funclet.
Referenced by createClone().
|
static |
Definition at line 441 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 380 of file CoroSplit.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Key::Args, assert(), llvm::Function::begin(), C, llvm::ArrayType::get(), llvm::ConstantArray::get(), llvm::Function::getContext(), llvm::CoroBeginInst::getId(), llvm::Type::getInt8PtrTy(), llvm::Value::getName(), llvm::ConstantExpr::getPointerCast(), llvm::GlobalValue::PrivateLinkage, and llvm::CoroIdInst::setInfo().
Referenced by splitCoroutine().
|
static |
Definition at line 610 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, llvm::Value::replaceAllUsesWith(), and llvm::Value::stripPointerCasts().
Referenced by simplifySuspendPoints().
|
static |
Definition at line 672 of file CoroSplit.cpp.
References llvm::coro::Shape::CoroBegin, llvm::coro::Shape::CoroSuspends, I, N, simplifySuspendPoint(), and std::swap().
Referenced by splitCoroutine().
|
static |
Definition at line 458 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(), I, if(), llvm::Instruction::isTerminator(), llvm::ReplaceInstWithInst(), scanPHIsAndUpdateValueMap(), and SI.
Referenced by addMustTailToCoroResumes().
|
static |
Definition at line 779 of file CoroSplit.cpp.
References addMustTailToCoroResumes(), llvm::coro::buildCoroutineFrame(), llvm::coro::Shape::CoroBegin, llvm::coro::Shape::CoroSuspends, createClone(), createResumeEntryBlock(), llvm::coro::Shape::FrameTy, handleNoSuspendCoroutine(), postSplitCleanup(), relocateInstructionBefore(), removeCoroEnds(), replaceFrameSize(), setCoroInfo(), simplifySuspendPoints(), llvm::coro::updateCallGraph(), and updateCoroFrame().
|
static |
Definition at line 400 of file CoroSplit.cpp.
References llvm::coro::Shape::CoroBegin, llvm::IRBuilder< T, Inserter >::CreateConstInBoundsGEP2_32(), llvm::coro::Shape::DestroyField, llvm::coro::Shape::FramePtr, llvm::coro::Shape::FrameTy, llvm::CoroIdInst::getCoroAlloc(), llvm::CoroBeginInst::getId(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getNextNode(), and llvm::coro::Shape::ResumeField.
Referenced by splitCoroutine().