MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / ComputePostOrderTraversal

Method ComputePostOrderTraversal

source/opt/cfg.cpp:168–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166}
167
168void CFG::ComputePostOrderTraversal(BasicBlock* bb,
169 std::vector<BasicBlock*>* order,
170 std::unordered_set<BasicBlock*>* seen) {
171 std::vector<BasicBlock*> stack;
172 stack.push_back(bb);
173 while (!stack.empty()) {
174 bb = stack.back();
175 seen->insert(bb);
176 static_cast<const BasicBlock*>(bb)->WhileEachSuccessorLabel(
177 [&seen, &stack, this](const uint32_t sbid) {
178 BasicBlock* succ_bb = id2block_[sbid];
179 if (!seen->count(succ_bb)) {
180 stack.push_back(succ_bb);
181 return false;
182 }
183 return true;
184 });
185 if (stack.back() == bb) {
186 order->push_back(bb);
187 stack.pop_back();
188 }
189 }
190}
191
192BasicBlock* CFG::SplitLoopHeader(BasicBlock* bb) {
193 assert(bb->GetLoopMergeInst() && "Expecting bb to be the header of a loop.");

Callers

nothing calls this directly

Calls 7

backMethod · 0.80
pop_backMethod · 0.80
push_backMethod · 0.45
emptyMethod · 0.45
insertMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected