| 241 | } |
| 242 | |
| 243 | bool Function::IsRecursive() const { |
| 244 | IRContext* ctx = blocks_.front()->GetLabel()->context(); |
| 245 | IRContext::ProcessFunction mark_visited = [this](Function* fp) { |
| 246 | return fp == this; |
| 247 | }; |
| 248 | |
| 249 | // Process the call tree from all of the function called by |this|. If it get |
| 250 | // back to |this|, then we have a recursive function. |
| 251 | std::queue<uint32_t> roots; |
| 252 | ctx->AddCalls(this, &roots); |
| 253 | return ctx->ProcessCallTreeFromRoots(mark_visited, &roots); |
| 254 | } |
| 255 | |
| 256 | std::ostream& operator<<(std::ostream& str, const Function& func) { |
| 257 | str << func.PrettyPrint(); |