19#define DEBUG_TYPE "coro-suspend-crossing"
22#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
36 dbgs() << Label <<
":";
38 if (BV[BB->getNumber()]) {
57 dump(
" Consumes", Block[BB->getNumber()].Consumes, RPOT, MST);
58 dump(
" Kills", Block[BB->getNumber()].Kills, RPOT, MST);
68 <<
" crosses suspend point\n");
75 (From == To && Block[To->
getNumber()].KillLoop);
77 <<
" crosses suspend point (path or loop)\n");
81template <
bool Initialize>
82bool SuspendCrossingInfo::computeBlockData(
87 auto &
B =
Block[BB->getNumber()];
90 if constexpr (!Initialize)
102 auto SavedConsumes =
B.Consumes;
103 auto SavedKills =
B.Kills;
106 auto &
P = Block[PI->getNumber()];
109 B.Consumes |=
P.Consumes;
112 if (
P.isAlwaysKill())
113 B.Kills |=
P.Consumes;
116 if (
B.isAlwaysKill()) {
117 B.Kills |=
B.Consumes;
118 }
else if (
B.isNeverKill()) {
127 if constexpr (!Initialize) {
128 B.Changed = (
B.Kills != SavedKills) || (
B.Consumes != SavedConsumes);
138 const size_t N = F.getMaxBlockNumber();
142 for (
size_t I = 0;
I <
N; ++
I) {
144 B.Consumes.resize(
N);
155 assert(CE->getParent()->getFirstInsertionPt() == CE->getIterator() &&
156 CE->getParent()->size() <= 2 &&
"CoroEnd must be in its own BB");
158 Block[CE->getParent()->getNumber()].setNeverKill();
162 for (
auto *U : InRamp->users())
164 auto *TrueBB = Br->getSuccessor(0);
165 if (TrueBB->getSinglePredecessor())
166 Block[TrueBB->getNumber()].setNeverKill();
177 B.Kills |=
B.Consumes;
181 assert(CSI->getParent()->getFirstInsertionPt() == CSI->getIterator() &&
182 CSI->getParent()->size() <= 2 &&
183 "CoroSuspend must be in its own BB");
185 markSuspendBlock(CSI);
186 if (auto *Save = CSI->getCoroSave())
187 markSuspendBlock(Save);
193 computeBlockData<
true>(RPOT);
194 while (computeBlockData</*Initialize*/ false>(RPOT))
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
LLVM Basic Block Representation.
unsigned getNumber() const
const Function * getParent() const
Return the enclosing method, or null if none.
A wrapper class for inspecting calls to intrinsic functions.
Manage lifetime of a slot tracker for printing IR.
int getLocalSlot(const Value *V)
Return the slot number of the specified local value.
void incorporateFunction(const Function &F)
Incorporate the given function.
Represent a constant reference to a string, i.e.
LLVM_ABI bool hasPathCrossingSuspendPoint(BasicBlock *From, BasicBlock *To) const
Returns true if there is a path from From to To crossing a suspend point without crossing From a 2nd ...
LLVM_ABI bool hasPathOrLoopCrossingSuspendPoint(BasicBlock *From, BasicBlock *To) const
Returns true if there is a path from From to To crossing a suspend point without crossing From a 2nd ...
LLVM_ABI SuspendCrossingInfo(Function &F, const coro::Shape &Shape)
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
static void dumpBasicBlockLabel(const BasicBlock *BB, ModuleSlotTracker &MST)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
auto predecessors(const MachineBasicBlock *BB)
SmallVector< AnyCoroSuspendInst *, 4 > CoroSuspends
SmallVector< CoroIsInRampInst *, 2 > CoroIsInRampInsts
SmallVector< AnyCoroEndInst *, 4 > CoroEnds