Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:38

0001 //===- SpillUtils.h - Utilities for han dling for spills ------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #include "llvm/IR/Dominators.h"
0010 #include "llvm/Transforms/Coroutines/CoroShape.h"
0011 #include "llvm/Transforms/Coroutines/SuspendCrossingInfo.h"
0012 
0013 #ifndef LLVM_TRANSFORMS_COROUTINES_SPILLINGINFO_H
0014 #define LLVM_TRANSFORMS_COROUTINES_SPILLINGINFO_H
0015 
0016 namespace llvm {
0017 
0018 namespace coro {
0019 
0020 using SpillInfo = SmallMapVector<Value *, SmallVector<Instruction *, 2>, 8>;
0021 
0022 struct AllocaInfo {
0023   AllocaInst *Alloca;
0024   DenseMap<Instruction *, std::optional<APInt>> Aliases;
0025   bool MayWriteBeforeCoroBegin;
0026   AllocaInfo(AllocaInst *Alloca,
0027              DenseMap<Instruction *, std::optional<APInt>> Aliases,
0028              bool MayWriteBeforeCoroBegin)
0029       : Alloca(Alloca), Aliases(std::move(Aliases)),
0030         MayWriteBeforeCoroBegin(MayWriteBeforeCoroBegin) {}
0031 };
0032 
0033 void collectSpillsFromArgs(SpillInfo &Spills, Function &F,
0034                            const SuspendCrossingInfo &Checker);
0035 void collectSpillsAndAllocasFromInsts(
0036     SpillInfo &Spills, SmallVector<AllocaInfo, 8> &Allocas,
0037     SmallVector<Instruction *, 4> &DeadInstructions,
0038     SmallVector<CoroAllocaAllocInst *, 4> &LocalAllocas, Function &F,
0039     const SuspendCrossingInfo &Checker, const DominatorTree &DT,
0040     const coro::Shape &Shape);
0041 void collectSpillsFromDbgInfo(SpillInfo &Spills, Function &F,
0042                               const SuspendCrossingInfo &Checker);
0043 
0044 /// Async and Retcon{Once} conventions assume that all spill uses can be sunk
0045 /// after the coro.begin intrinsic.
0046 void sinkSpillUsesAfterCoroBegin(const DominatorTree &DT,
0047                                  CoroBeginInst *CoroBegin,
0048                                  coro::SpillInfo &Spills,
0049                                  SmallVectorImpl<coro::AllocaInfo> &Allocas);
0050 
0051 // Get the insertion point for a spill after a Def.
0052 BasicBlock::iterator getSpillInsertionPt(const coro::Shape &, Value *Def,
0053                                          const DominatorTree &DT);
0054 
0055 } // namespace coro
0056 
0057 } // namespace llvm
0058 
0059 #endif // LLVM_TRANSFORMS_COROUTINES_SPILLINGINFO_H