LLVM 20.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/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/TargetTransformInfo.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 78 of file CoroSplit.cpp.
|
static |
Definition at line 904 of file CoroSplit.cpp.
References llvm::AttrBuilder::addAttribute().
|
static |
Definition at line 889 of file CoroSplit.cpp.
References llvm::AttrBuilder::addAlignmentAttr(), llvm::AttrBuilder::addAttribute(), llvm::AttrBuilder::addDereferenceableAttr(), and Size.
|
static |
Definition at line 2068 of file CoroSplit.cpp.
References Name, and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by llvm::CoroSplitPass::run().
|
static |
Definition at line 911 of file CoroSplit.cpp.
References llvm::AttrBuilder::addAttribute().
|
static |
Definition at line 1641 of file CoroSplit.cpp.
References assert(), llvm::IRBuilderBase::CreateBitOrPointerCast(), getType(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::ArrayRef< T >::size().
Referenced by llvm::coro::createMustTailCall().
|
static |
Returns all DbgVariableIntrinsic in F.
Definition at line 714 of file CoroSplit.cpp.
References F, llvm::filterDbgVars(), I, instructions, and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by splitCoroutine().
|
static |
Definition at line 540 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, llvm::Function::Create(), getFunctionTypeFromAsyncSuspend(), llvm::Value::getName(), llvm::GlobalValue::getParent(), and llvm::coro::Shape::getResumeFunctionType().
Referenced by splitAsyncCoroutine(), and splitRetconCoroutine().
|
static |
Definition at line 532 of file CoroSplit.cpp.
References llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), and llvm::Type::getVoidTy().
Referenced by createCloneDeclaration().
|
static |
Definition at line 1220 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, llvm::coro::Shape::CoroBegin, llvm::IRBuilderBase::CreateAlloca(), llvm::coro::Shape::FrameAlign, llvm::coro::Shape::FrameTy, llvm::UndefValue::get(), llvm::AnyCoroIdInst::getCoroAlloc(), llvm::IRBuilderBase::getFalse(), llvm::CoroBeginInst::getId(), llvm::coro::replaceCoroFree(), and llvm::AllocaInst::setAlignment().
Referenced by splitCoroutine().
|
static |
Definition at line 1296 of file CoroSplit.cpp.
References llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getNextNode(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), hasCallsInBlockBetween(), and hasCallsInBlocksBetween().
Referenced by simplifySuspendPoint().
|
static |
Definition at line 1255 of file CoroSplit.cpp.
Referenced by hasCallsBetween(), and hasCallsInBlocksBetween().
|
static |
Definition at line 1267 of file CoroSplit.cpp.
References llvm::SmallVectorBase< Size_T >::empty(), llvm::BasicBlock::getFirstNonPHI(), hasCallsInBlockBetween(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::predecessors(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by hasCallsBetween().
|
static |
Definition at line 177 of file CoroSplit.cpp.
References llvm::IRBuilderBase::CreateCall(), llvm::IRBuilderBase::CreateInvoke(), llvm::Instruction::eraseFromParent(), llvm::CallingConv::Fast, FramePtr, llvm::CallBase::getAttributes(), llvm::CoroAwaitSuspendInst::getAwaiter(), llvm::CallBase::getCalledFunction(), llvm::IRBuilderBase::getContext(), llvm::Value::getContext(), llvm::CoroAwaitSuspendInst::getFrame(), llvm::IRBuilderBase::GetInsertPoint(), llvm::Function::getIntrinsicID(), llvm::Type::getVoidTy(), llvm::CoroAwaitSuspendInst::getWrapperFunction(), llvm_unreachable, llvm::coro::LowererBase::makeSubFnCall(), llvm::AttributeList::removeParamAttributes(), llvm::Value::replaceAllUsesWith(), llvm::CoroSubFnInst::ResumeIndex, llvm::CallBase::setAttributes(), llvm::CallBase::setCallingConv(), llvm::IRBuilderBase::SetInsertPoint(), llvm::coro::Shape::SymmetricTransfers, and Wrapper.
Referenced by lowerAwaitSuspends().
|
static |
Definition at line 243 of file CoroSplit.cpp.
References llvm::coro::Shape::CoroAwaitSuspends, F, and lowerAwaitSuspend().
Referenced by splitCoroutine().
|
static |
Definition at line 404 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), llvm::coro::Shape::CoroSuspends, llvm::IRBuilderBase::CreateStore(), llvm::IRBuilderBase::CreateStructGEP(), FramePtr, llvm::coro::Shape::FrameTy, llvm::ConstantPointerNull::get(), llvm::coro::Shape::getIndex(), llvm::coro::Shape::getSwitchIndexField(), llvm::StructType::getTypeAtIndex(), llvm::coro::Shape::SwitchLoweringStorage::HasFinalSuspend, llvm::coro::Shape::SwitchLoweringStorage::HasUnwindCoroEnd, llvm::coro::Shape::SwitchFieldIndex::Resume, and llvm::coro::Shape::SwitchLowering.
Referenced by replaceUnwindCoroEnd().
|
static |
Definition at line 249 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), llvm::coro::Shape::emitDealloc(), FramePtr, llvm::coro::Shape::RetconLoweringStorage::IsFrameInlineInStorage, and llvm::coro::Shape::RetconLowering.
Referenced by replaceFallthroughCoroEnd(), and replaceUnwindCoroEnd().
|
static |
Definition at line 1206 of file CoroSplit.cpp.
References llvm::errs(), F, llvm::removeUnreachableBlocks(), llvm::report_fatal_error(), and llvm::verifyFunction().
Referenced by updateCallGraphAfterCoroutineSplit().
|
static |
Definition at line 1970 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, llvm::coro::Shape::CoroEnds, End, llvm::coro::Shape::FramePtr, llvm::ConstantInt::getFalse(), and replaceCoroEnd().
Referenced by llvm::CoroSplitPass::run().
|
static |
Definition at line 2055 of file CoroSplit.cpp.
References llvm::CallingConv::C, llvm::make_early_inc_range(), P, replacePrepare(), and llvm::Value::uses().
Referenced by llvm::CoroSplitPass::run().
|
static |
Definition at line 1626 of file CoroSplit.cpp.
References llvm::IRBuilderBase::CreateBitOrPointerCast(), llvm::UndefValue::get(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::CoroSuspendAsyncInst::getResumeFunction(), llvm::Value::replaceAllUsesWith(), llvm::CoroSuspendAsyncInst::ResumeFunctionArg, and llvm::User::setOperand().
Referenced by splitAsyncCoroutine().
|
static |
Definition at line 476 of file CoroSplit.cpp.
References End, FramePtr, llvm::ConstantInt::getFalse(), llvm::ConstantInt::getTrue(), replaceFallthroughCoroEnd(), and replaceUnwindCoroEnd().
Referenced by removeCoroEndsFromRampFunction().
|
static |
Replace an llvm.coro.end.async.
Will inline the must tail call function call if there is one.
Definition at line 262 of file CoroSplit.cpp.
References assert(), llvm::IRBuilderBase::CreateRetVoid(), End, llvm::InlineFunction(), and llvm::IRBuilderBase::SetInsertPoint().
Referenced by replaceFallthroughCoroEnd().
|
static |
Replace a non-unwind call to llvm.coro.end.
Definition at line 305 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), llvm::IRBuilderBase::CreateInsertValue(), llvm::IRBuilderBase::CreateRet(), llvm::IRBuilderBase::CreateRetVoid(), End, FramePtr, llvm::ConstantTokenNone::get(), llvm::ConstantPointerNull::get(), llvm::UndefValue::get(), llvm::coro::Shape::getResumeFunctionType(), llvm::FunctionType::getReturnType(), Idx, maybeFreeRetconStorage(), llvm::Value::replaceAllUsesWith(), replaceCoroEndAsync(), and RetTy.
Referenced by replaceCoroEnd().
|
static |
Definition at line 1180 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, llvm::coro::Shape::CoroAligns, llvm::coro::Shape::CoroSizes, DL, llvm::Instruction::eraseFromParent(), llvm::coro::Shape::FrameAlign, llvm::coro::Shape::FrameTy, llvm::Value::getType(), llvm::Value::replaceAllUsesWith(), Size, updateAsyncFuncPointerContextSize(), and llvm::Align::value().
Referenced by splitCoroutine().
|
static |
Definition at line 2019 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 656 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), llvm::coro::Shape::CoroSuspends, llvm::IRBuilderBase::CreateAlloca(), llvm::IRBuilderBase::CreateLoad(), llvm::IRBuilderBase::CreateStore(), F, llvm::Value::getType(), llvm::AllocaInst::setSwiftError(), and llvm::coro::Shape::SwiftErrorOps.
Referenced by splitCoroutine().
|
static |
Replace an unwind call to llvm.coro.end.
Definition at line 438 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, llvm::IRBuilderBase::CreateCleanupRet(), End, FramePtr, markCoroutineAsDone(), maybeFreeRetconStorage(), and llvm::LLVMContext::OB_funclet.
Referenced by replaceCoroEnd().
|
static |
Definition at line 1321 of file CoroSplit.cpp.
References llvm::BranchInst::Create(), llvm::Instruction::eraseFromParent(), llvm::CallBase::getCalledOperand(), llvm::CoroSuspendInst::getCoroSave(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getPrevNode(), hasCallsBetween(), I, llvm::Value::replaceAllUsesWith(), and llvm::Value::stripPointerCasts().
Referenced by simplifySuspendPoints().
|
static |
Definition at line 1381 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), llvm::coro::Shape::CoroBegin, llvm::coro::Shape::CoroSuspends, llvm::coro::Shape::SwitchLoweringStorage::HasFinalSuspend, I, N, simplifySuspendPoint(), std::swap(), and llvm::coro::Shape::SwitchLowering.
Referenced by splitCoroutine().
|
static |
Definition at line 1676 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), llvm::coro::Shape::AsyncLowering, llvm::coro::Shape::CoroBegin, llvm::coro::Shape::CoroSuspends, llvm::BasicBlock::Create(), llvm::IRBuilderBase::CreateBitOrPointerCast(), createCloneDeclaration(), llvm::IRBuilderBase::CreateConstInBoundsGEP1_32(), llvm::coro::createMustTailCall(), llvm::IRBuilderBase::CreateRetVoid(), llvm::ArrayRef< T >::drop_front(), llvm::SmallVectorBase< Size_T >::empty(), End, F, llvm::coro::Shape::AsyncLoweringStorage::FrameOffset, FramePtr, llvm::coro::Shape::FramePtr, llvm::CoroBeginInst::getId(), llvm::Type::getInt8Ty(), llvm::TrackingVH< ValueTy >::getValPtr(), Idx, llvm::InlineFunction(), llvm::CoroSuspendAsyncInst::MustTailCallFuncArg, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::Value::replaceAllUsesWith(), replaceAsyncResumeFunction(), llvm::SmallVectorImpl< T >::reserve(), and llvm::SmallVectorBase< Size_T >::size().
Referenced by splitCoroutine().
|
static |
Definition at line 1915 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, collectDbgVariableIntrinsics(), llvm::coro::Shape::CoroBegin, llvm::coro::Shape::CoroSuspends, F, handleNoSuspendCoroutine(), lowerAwaitSuspends(), llvm::removeUnreachableBlocks(), replaceFrameSizeAndAlignment(), replaceSwiftErrorOps(), llvm::coro::salvageDebugInfo(), simplifySuspendPoints(), splitAsyncCoroutine(), and splitRetconCoroutine().
Referenced by llvm::CoroSplitPass::run().
|
static |
Definition at line 1771 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), llvm::coro::Shape::CoroBegin, llvm::coro::Shape::CoroSuspends, llvm::BasicBlock::Create(), llvm::IRBuilderBase::CreateBitCast(), createCloneDeclaration(), llvm::IRBuilderBase::CreateInsertValue(), llvm::IRBuilderBase::CreatePHI(), llvm::IRBuilderBase::CreateRet(), llvm::IRBuilderBase::CreateStore(), DL, llvm::coro::Shape::emitAlloc(), llvm::SmallVectorBase< Size_T >::empty(), F, llvm::coro::Shape::FramePtr, llvm::coro::Shape::FrameTy, llvm::PoisonValue::get(), llvm::CoroBeginInst::getId(), llvm::IRBuilderBase::getInt64(), llvm::coro::Shape::getRetconResultTypes(), llvm::Value::getType(), llvm::TrackingVH< ValueTy >::getValPtr(), I, llvm::coro::Shape::RetconLoweringStorage::IsFrameInlineInStorage, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::Value::replaceAllUsesWith(), llvm::SmallVectorImpl< T >::reserve(), llvm::coro::Shape::RetconLowering, RetTy, llvm::coro::Shape::RetconLoweringStorage::ReturnBlock, llvm::SmallVectorBase< Size_T >::size(), and Size.
Referenced by splitCoroutine().
|
static |
Definition at line 1165 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, assert(), llvm::coro::Shape::AsyncLoweringStorage::AsyncFuncPointer, llvm::coro::Shape::AsyncLowering, llvm::coro::Shape::AsyncLoweringStorage::ContextSize, llvm::ConstantStruct::get(), llvm::GlobalVariable::getInitializer(), and llvm::GlobalVariable::setInitializer().
Referenced by replaceFrameSizeAndAlignment().
|
static |
Definition at line 1984 of file CoroSplit.cpp.
References llvm::coro::Shape::ABI, llvm::LazyCallGraph::addSplitFunction(), llvm::LazyCallGraph::addSplitRefRecursiveFunctions(), llvm::CallingConv::C, llvm::SmallVectorBase< Size_T >::empty(), FAM, N, postSplitCleanup(), llvm::updateCGAndAnalysisManagerForCGSCCPass(), and llvm::updateCGAndAnalysisManagerForFunctionPass().
Referenced by llvm::CoroSplitPass::run().