void gvn(IRUnit& unit) { auto rpoBlocksWithIds = rpoSortCfgWithIds(unit); auto& rpoBlocks = rpoBlocksWithIds.blocks; auto dominators = findDominators(unit, rpoBlocksWithIds); ValueNumberTable vnTable(unit, ValueNumberMetadata { nullptr, nullptr }); // This is an implementation of the RPO version of the global value numbering // algorithm presented in the 1996 paper "SCC-based Value Numbering" by // Cooper and Simpson. runAnalysis(unit, rpoBlocks, vnTable); replaceRedundantComputations(unit, dominators, rpoBlocks, vnTable); }
void gvn(IRUnit& unit) { PassTracer tracer{&unit, Trace::hhir_gvn, "gvn"}; GVNState state; auto const rpoBlocks = rpoSortCfg(unit); auto const idoms = findDominators( unit, rpoBlocks, numberBlocks(unit, rpoBlocks) ); ValueNumberTable globalTable(unit, ValueNumberMetadata{}); state.globalTable = &globalTable; // This is an implementation of the RPO version of the global value numbering // algorithm presented in the 1996 paper "SCC-based Value Numbering" by // Cooper and Simpson. runAnalysis(state, unit, rpoBlocks); replaceRedundantComputations(unit, idoms, rpoBlocks, globalTable); state.globalTable = nullptr; }