LLVM
15.0.0git
|
#include "llvm/Transforms/Coroutines/CoroSplit.h"
#include "CoroInstr.h"
#include "CoroInternal.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/PriorityWorklist.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Analysis/CFG.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/LazyCallGraph.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Dominators.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/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/Verifier.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/CallGraphUpdater.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" |
#define DEBUG_TYPE "coro-split" |
Definition at line 76 of file CoroSplit.cpp.
|
static |
Definition at line 847 of file CoroSplit.cpp.
References llvm::AttrBuilder::addAttribute(), Attrs, and Context.
|
static |
Definition at line 836 of file CoroSplit.cpp.
References llvm::AttrBuilder::addAlignmentAttr(), llvm::AttrBuilder::addAttribute(), llvm::AttrBuilder::addDereferenceableAttr(), Attrs, and Context.
|
static |
Definition at line 1358 of file CoroSplit.cpp.
References F, I, llvm::instructions(), llvm::removeUnreachableBlocks(), shouldBeMustTail(), simplifyTerminatorLeadingToRet(), and llvm::CallInst::TCK_MustTail.
Referenced by splitSwitchCoroutine().
|
static |
Definition at line 2041 of file CoroSplit.cpp.
References M.
Referenced by llvm::CoroSplitPass::run().
|
static |
Definition at line 854 of file CoroSplit.cpp.
References llvm::AttrBuilder::addAttribute(), Attrs, and Context.
|
static |
Coerce the arguments in FnArgs
according to FnTy
in CallArgs
.
Definition at line 1614 of file CoroSplit.cpp.
References assert(), Builder, llvm::Intrinsic::getType(), llvm::FunctionType::params(), and llvm::ArrayRef< T >::size().
Referenced by llvm::coro::createMustTailCall().
|
static |
|
static |
Definition at line 492 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, llvm::Function::addParamAttr(), llvm::coro::Async, llvm::Function::Create(), getFunctionTypeFromAsyncSuspend(), llvm::Value::getName(), llvm::GlobalValue::getParent(), llvm::coro::Shape::getResumeFunctionType(), and M.
Referenced by splitRetconCoroutine().
|
static |
Definition at line 357 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), Builder, llvm::coro::Shape::CoroSuspends, llvm::BasicBlock::Create(), llvm::PHINode::Create(), F, llvm::coro::Shape::FramePtr, llvm::coro::Shape::FrameTy, llvm::ConstantTokenNone::get(), llvm::coro::Shape::getIndex(), llvm::coro::Shape::getIndexType(), llvm::coro::Shape::getSwitchIndexField(), markCoroutineAsDone(), llvm::coro::Shape::SwitchLoweringStorage::ResumeEntryBlock, llvm::coro::Shape::SwitchLoweringStorage::ResumeSwitch, S, llvm::coro::Switch, and llvm::coro::Shape::SwitchLowering.
Referenced by splitSwitchCoroutine().
|
static |
Definition at line 484 of file CoroSplit.cpp.
References Context, llvm::FunctionType::get(), llvm::Function::getContext(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), and llvm::Type::getVoidTy().
Referenced by createCloneDeclaration().
|
static |
Definition at line 1381 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, llvm::coro::Async, Builder, llvm::coro::Shape::CoroBegin, llvm::coro::Shape::FrameAlign, llvm::coro::Shape::FrameTy, llvm::UndefValue::get(), llvm::AnyCoroIdInst::getCoroAlloc(), llvm::CoroBeginInst::getId(), llvm::coro::replaceCoroFree(), llvm::coro::Retcon, llvm::coro::RetconOnce, and llvm::coro::Switch.
Referenced by splitCoroutine().
|
static |
Definition at line 1457 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 1416 of file CoroSplit.cpp.
Referenced by hasCallsBetween(), and hasCallsInBlocksBetween().
|
static |
Definition at line 1428 of file CoroSplit.cpp.
References BB, llvm::SmallPtrSetImpl< PtrType >::contains(), llvm::SmallPtrSetImpl< PtrType >::erase(), hasCallsInBlockBetween(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::SmallVectorImpl< T >::pop_back_val(), and llvm::predecessors().
Referenced by hasCallsBetween().
|
static |
Definition at line 290 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), Builder, llvm::coro::Shape::FrameTy, llvm::ConstantPointerNull::get(), llvm::StructType::getTypeAtIndex(), llvm::coro::Shape::SwitchFieldIndex::Resume, and llvm::coro::Switch.
Referenced by createResumeEntryBlock().
|
static |
Definition at line 168 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), Builder, llvm::coro::Shape::emitDealloc(), llvm::coro::Shape::RetconLoweringStorage::IsFrameInlineInStorage, llvm::coro::Retcon, llvm::coro::Shape::RetconLowering, and llvm::coro::RetconOnce.
|
static |
Definition at line 1180 of file CoroSplit.cpp.
References llvm::errs(), F, llvm::removeUnreachableBlocks(), llvm::report_fatal_error(), and llvm::verifyFunction().
Referenced by splitSwitchCoroutine().
|
static |
Definition at line 2028 of file CoroSplit.cpp.
References llvm::make_early_inc_range(), P, replacePrepare(), and llvm::Value::uses().
Referenced by llvm::CoroSplitPass::run().
|
static |
Definition at line 1599 of file CoroSplit.cpp.
References Builder, Context, llvm::UndefValue::get(), llvm::Function::getContext(), llvm::Type::getInt8PtrTy(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::CoroSuspendAsyncInst::getResumeFunction(), llvm::CoroSuspendAsyncInst::ResumeFunctionArg, and llvm::User::setOperand().
|
static |
Definition at line 342 of file CoroSplit.cpp.
|
static |
Replace an llvm.coro.end.async.
Will inline the must tail call function call if there is one.
Definition at line 182 of file CoroSplit.cpp.
|
static |
Replace a non-unwind call to llvm.coro.end.
Definition at line 225 of file CoroSplit.cpp.
|
static |
Definition at line 1093 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, llvm::coro::Async, llvm::coro::Shape::CoroAligns, llvm::coro::Shape::CoroSizes, DL, llvm::Instruction::eraseFromParent(), llvm::coro::Shape::FrameAlign, llvm::coro::Shape::FrameTy, llvm::ConstantInt::get(), llvm::Value::getType(), M, llvm::Value::replaceAllUsesWith(), updateAsyncFuncPointerContextSize(), and llvm::Align::value().
Referenced by splitCoroutine().
|
static |
Replace a call to llvm.coro.prepare.retcon.
Definition at line 1992 of file CoroSplit.cpp.
References llvm::Instruction::eraseFromParent(), llvm::CallBase::getArgOperand(), llvm::make_early_inc_range(), llvm::Value::replaceAllUsesWith(), llvm::Value::stripPointerCasts(), and llvm::Value::uses().
Referenced by replaceAllPrepares().
|
static |
Definition at line 612 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, Arg, assert(), llvm::coro::Async, Builder, llvm::coro::Shape::CoroSuspends, F, llvm::Value::getType(), and llvm::coro::Shape::SwiftErrorOps.
Referenced by splitCoroutine().
|
static |
Replace an unwind call to llvm.coro.end.
Definition at line 304 of file CoroSplit.cpp.
|
static |
Definition at line 1195 of file CoroSplit.cpp.
References llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::end(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::find(), llvm::Instruction::getParent(), llvm::BasicBlock::phis(), and VI.
Referenced by simplifyTerminatorLeadingToRet().
|
static |
Definition at line 1130 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, llvm::AMDGPU::HSAMD::Kernel::Key::Args, assert(), llvm::ArrayRef< T >::begin(), llvm::ArrayRef< T >::end(), F, llvm::ArrayType::get(), llvm::ConstantArray::get(), llvm::Type::getInt8PtrTy(), llvm::GlobalValue::getParent(), llvm::ConstantExpr::getPointerCast(), llvm::coro::Shape::getSwitchCoroId(), llvm::GlobalValue::getType(), M, llvm::GlobalValue::PrivateLinkage, llvm::CoroIdInst::setInfo(), and llvm::coro::Switch.
Referenced by splitSwitchCoroutine().
Definition at line 1323 of file CoroSplit.cpp.
References Attrs, F, llvm::CallBase::getAttributes(), llvm::CallBase::getCallingConv(), llvm::CallBase::getFunctionType(), llvm::FunctionType::getNumParams(), llvm::FunctionType::getParamType(), llvm::Type::getPointerAddressSpace(), llvm::FunctionType::getReturnType(), llvm::CallBase::isInlineAsm(), llvm::Type::isPointerTy(), and llvm::Type::isVoidTy().
Referenced by addMustTailToCoroResumes().
|
static |
Definition at line 1482 of file CoroSplit.cpp.
References Callee, llvm::BranchInst::Create(), llvm::Instruction::eraseFromParent(), llvm::CallBase::getCalledOperand(), 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 1542 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, llvm::coro::Shape::CoroBegin, llvm::coro::Shape::CoroSuspends, I, N, S, SI, simplifySuspendPoint(), std::swap(), and llvm::coro::Switch.
Referenced by splitCoroutine().
|
static |
Definition at line 1212 of file CoroSplit.cpp.
References assert(), BB, llvm::ISD::BR, Cond, llvm::ConstantFoldCompareInstOperands(), llvm::ConstantFoldTerminator(), DL, llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::end(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::find(), llvm::Module::getDataLayout(), llvm::BasicBlock::getFirstNonPHIOrDbgOrLifetime(), llvm::Instruction::getModule(), llvm::Instruction::getParent(), I, llvm::isInstructionTriviallyDead(), llvm::BasicBlock::removePredecessor(), llvm::ReplaceInstWithInst(), scanPHIsAndUpdateValueMap(), and SI.
Referenced by addMustTailToCoroResumes().
|
static |
Definition at line 1645 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), llvm::coro::Async, llvm::coro::Shape::AsyncLowering, Builder, Context, llvm::coro::Shape::CoroBegin, llvm::coro::Shape::CoroSuspends, F, llvm::coro::Shape::AsyncLoweringStorage::FrameOffset, llvm::coro::Shape::FramePtr, llvm::CoroBeginInst::getId(), llvm::Type::getInt8PtrTy(), llvm::Type::getInt8Ty(), llvm::TrackingVH< ValueTy >::getValPtr(), llvm::Value::replaceAllUsesWith(), and llvm::SmallVectorImpl< T >::reserve().
Referenced by splitCoroutine().
|
static |
Definition at line 1886 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, llvm::coro::Async, BB, llvm::coro::buildCoroutineFrame(), llvm::coro::Shape::CoroBegin, llvm::coro::Shape::CoroSuspends, F, handleNoSuspendCoroutine(), I, llvm::coro::Shape::OptimizeFrame, llvm::removeUnreachableBlocks(), replaceFrameSizeAndAlignment(), replaceSwiftErrorOps(), llvm::coro::Retcon, llvm::coro::RetconOnce, llvm::coro::salvageDebugInfo(), simplifySuspendPoints(), splitAsyncCoroutine(), splitRetconCoroutine(), splitSwitchCoroutine(), and llvm::coro::Switch.
Referenced by llvm::CoroSplitPass::run().
|
static |
Definition at line 1742 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), llvm::MCID::Branch, Builder, llvm::coro::Shape::CoroBegin, llvm::coro::Shape::CoroSuspends, llvm::BasicBlock::Create(), createCloneDeclaration(), DL, llvm::numbers::e, E, llvm::coro::Shape::emitAlloc(), F, llvm::coro::Shape::FramePtr, llvm::coro::Shape::FrameTy, llvm::UndefValue::get(), llvm::CoroBeginInst::getId(), llvm::Type::getPointerTo(), llvm::coro::Shape::getRetconResultTypes(), llvm::Value::getType(), llvm::TrackingVH< ValueTy >::getValPtr(), i, I, llvm::coro::Shape::RetconLoweringStorage::IsFrameInlineInStorage, llvm::Value::replaceAllUsesWith(), llvm::SmallVectorImpl< T >::reserve(), llvm::coro::Retcon, llvm::coro::Shape::RetconLowering, llvm::coro::RetconOnce, and llvm::coro::Shape::RetconLoweringStorage::ReturnBlock.
Referenced by splitCoroutine().
|
static |
Definition at line 1567 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, addMustTailToCoroResumes(), assert(), createClone(), createResumeEntryBlock(), F, postSplitCleanup(), setCoroInfo(), llvm::coro::Switch, and updateCoroFrame().
Referenced by splitCoroutine().
|
static |
Definition at line 1078 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), llvm::coro::Async, llvm::coro::Shape::AsyncLoweringStorage::AsyncFuncPointer, llvm::coro::Shape::AsyncLowering, llvm::coro::Shape::AsyncLoweringStorage::ContextSize, llvm::ConstantInt::get(), llvm::ConstantStruct::get(), llvm::GlobalVariable::getInitializer(), and llvm::GlobalVariable::setInitializer().
Referenced by replaceFrameSizeAndAlignment().
|
static |
Definition at line 1949 of file CoroSplit.cpp.
References llvm::coro::Shape::CoroBegin.
Referenced by llvm::CoroSplitPass::run().
|
static |
Definition at line 1154 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), Builder, llvm::coro::Shape::SwitchFieldIndex::Destroy, llvm::coro::Shape::FramePtr, llvm::coro::Shape::FrameTy, llvm::AnyCoroIdInst::getCoroAlloc(), llvm::coro::Shape::getInsertPtAfterFramePtr(), llvm::coro::Shape::getSwitchCoroId(), llvm::coro::Shape::SwitchFieldIndex::Resume, and llvm::coro::Switch.
Referenced by splitSwitchCoroutine().