| 215 | } |
| 216 | |
| 217 | std::unordered_set<uint32_t> |
| 218 | StructuredCFGAnalysis::FindFuncsCalledFromContinue() { |
| 219 | std::unordered_set<uint32_t> called_from_continue; |
| 220 | std::queue<uint32_t> funcs_to_process; |
| 221 | |
| 222 | // First collect the functions that are called directly from a continue |
| 223 | // construct. |
| 224 | for (Function& func : *context_->module()) { |
| 225 | for (auto& bb : func) { |
| 226 | if (IsInContainingLoopsContinueConstruct(bb.id())) { |
| 227 | for (const Instruction& inst : bb) { |
| 228 | if (inst.opcode() == spv::Op::OpFunctionCall) { |
| 229 | funcs_to_process.push(inst.GetSingleWordInOperand(0)); |
| 230 | } |
| 231 | } |
| 232 | } |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | // Now collect all of the functions that are indirectly called as well. |
| 237 | while (!funcs_to_process.empty()) { |
| 238 | uint32_t func_id = funcs_to_process.front(); |
| 239 | funcs_to_process.pop(); |
| 240 | Function* func = context_->GetFunction(func_id); |
| 241 | if (called_from_continue.insert(func_id).second) { |
| 242 | context_->AddCalls(func, &funcs_to_process); |
| 243 | } |
| 244 | } |
| 245 | return called_from_continue; |
| 246 | } |
| 247 | |
| 248 | } // namespace opt |
| 249 | } // namespace spvtools |