33 auto [it, inserted] =
cache.try_emplace(op);
43 FModuleOp owner =
nullptr;
49 auto combine = [](FModuleOp current, FModuleOp parent,
bool first) {
52 else if (current != parent)
58 SmallVector<StackElement> stack;
60 stack.emplace_back(node);
62 auto returning =
false;
63 FModuleOp result =
nullptr;
64 while (!stack.empty()) {
66 auto &elt = stack.back();
71 elt.owner = combine(elt.owner, result, elt.first);
83 cache[elt.current] = elt.owner;
88 auto *parentNode = (*it)->getParent();
89 auto parent = parentNode->getModule();
94 if (
auto parentModule = dyn_cast<FModuleOp>(parent.getOperation())) {
95 elt.owner = combine(elt.owner, parentModule, elt.first);
99 auto [pIt, pInserted] =
cache.try_emplace(parent);
101 elt.owner = combine(elt.owner, pIt->second, elt.first);
107 stack.emplace_back(parentNode);
114 assert(returning &&
"must be returning a result");