//===- SpillUtils.h - Utilities for han dling for spills ------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "llvm/IR/Dominators.h" #include "llvm/Transforms/Coroutines/CoroShape.h" #include "llvm/Transforms/Coroutines/SuspendCrossingInfo.h" #ifndef LLVM_TRANSFORMS_COROUTINES_SPILLINGINFO_H #define LLVM_TRANSFORMS_COROUTINES_SPILLINGINFO_H namespace llvm::coro { using SpillInfo = SmallMapVector, 8>; struct AllocaInfo { AllocaInst *Alloca; DenseMap> Aliases; bool MayWriteBeforeCoroBegin; AllocaInfo(AllocaInst *Alloca, DenseMap> Aliases, bool MayWriteBeforeCoroBegin) : Alloca(Alloca), Aliases(std::move(Aliases)), MayWriteBeforeCoroBegin(MayWriteBeforeCoroBegin) {} }; void collectSpillsFromArgs(SpillInfo &Spills, Function &F, const SuspendCrossingInfo &Checker); void collectSpillsAndAllocasFromInsts( SpillInfo &Spills, SmallVector &Allocas, SmallVector &DeadInstructions, SmallVector &LocalAllocas, Function &F, const SuspendCrossingInfo &Checker, const DominatorTree &DT, const coro::Shape &Shape); void collectSpillsFromDbgInfo(SpillInfo &Spills, Function &F, const SuspendCrossingInfo &Checker); /// Async and Retcon{Once} conventions assume that all spill uses can be sunk /// after the coro.begin intrinsic. void sinkSpillUsesAfterCoroBegin(const DominatorTree &DT, CoroBeginInst *CoroBegin, coro::SpillInfo &Spills, SmallVectorImpl &Allocas); // Get the insertion point for a spill after a Def. BasicBlock::iterator getSpillInsertionPt(const coro::Shape &, Value *Def, const DominatorTree &DT); } // namespace llvm::coro #endif // LLVM_TRANSFORMS_COROUTINES_SPILLINGINFO_H