| 1720 | } |
| 1721 | |
| 1722 | void Differ::MatchFunctionParamIds(const opt::Function* src_func, |
| 1723 | const opt::Function* dst_func) { |
| 1724 | IdGroup src_params; |
| 1725 | IdGroup dst_params; |
| 1726 | src_func->ForEachParam( |
| 1727 | [&src_params](const opt::Instruction* param) { |
| 1728 | src_params.push_back(param->result_id()); |
| 1729 | }, |
| 1730 | false); |
| 1731 | dst_func->ForEachParam( |
| 1732 | [&dst_params](const opt::Instruction* param) { |
| 1733 | dst_params.push_back(param->result_id()); |
| 1734 | }, |
| 1735 | false); |
| 1736 | |
| 1737 | GroupIdsAndMatch<std::string>( |
| 1738 | src_params, dst_params, "", &Differ::GetSanitizedName, |
| 1739 | [this](const IdGroup& src_group, const IdGroup& dst_group) { |
| 1740 | // There shouldn't be two parameters with the same name, so the ids |
| 1741 | // should match. There is nothing restricting the SPIR-V however to have |
| 1742 | // two parameters with the same name, so be resilient against that. |
| 1743 | if (src_group.size() == 1 && dst_group.size() == 1) { |
| 1744 | id_map_.MapIds(src_group[0], dst_group[0]); |
| 1745 | } |
| 1746 | }); |
| 1747 | |
| 1748 | // Then match the parameters by their type. If there are multiple of them, |
| 1749 | // match them by their order. |
| 1750 | GroupIdsAndMatchByMappedId( |
| 1751 | src_params, dst_params, &Differ::GroupIdsHelperGetTypeId, |
| 1752 | [this](const IdGroup& src_group_by_type_id, |
| 1753 | const IdGroup& dst_group_by_type_id) { |
| 1754 | const size_t shared_param_count = |
| 1755 | std::min(src_group_by_type_id.size(), dst_group_by_type_id.size()); |
| 1756 | |
| 1757 | for (size_t param_index = 0; param_index < shared_param_count; |
| 1758 | ++param_index) { |
| 1759 | id_map_.MapIds(src_group_by_type_id[param_index], |
| 1760 | dst_group_by_type_id[param_index]); |
| 1761 | } |
| 1762 | }); |
| 1763 | } |
| 1764 | |
| 1765 | float Differ::MatchFunctionBodies(const InstructionList& src_body, |
| 1766 | const InstructionList& dst_body, |
nothing calls this directly
no test coverage detected