std::pair<Value*, BB*> BBTransform::forInline(BB* inlinee, BB* splice) { Value* found = nullptr; Return* ret; Visitor::run(inlinee, [&](BB* bb) { if (bb->next0 != nullptr) return; assert(bb->next1 == nullptr); if (Deopt::Cast(bb->last())) return; ret = Return::Cast(bb->last()); assert(ret); // This transformation assumes that we have just one reachable return. // Assert that we do not find a second one. assert(!found); found = ret->arg<0>().val(); bb->next0 = splice; bb->remove(bb->end() - 1); }); assert(found); return {found, ret->bb()}; }