A helper function to strip OpName instructions from the given string of disassembly code and put those debug instructions to a set. Returns the string with all OpName instruction stripped and a set of OpName instructions.
| 77 | // string with all OpName instruction stripped and a set of OpName |
| 78 | // instructions. |
| 79 | std::tuple<std::string, std::unordered_set<std::string>> |
| 80 | StripOpNameInstructionsToSet(const std::string& str) { |
| 81 | std::stringstream ss(str); |
| 82 | std::ostringstream oss; |
| 83 | std::string inst_str; |
| 84 | std::unordered_set<std::string> opname_instructions; |
| 85 | while (std::getline(ss, inst_str, '\n')) { |
| 86 | if (inst_str.find("OpName %") == std::string::npos) { |
| 87 | oss << inst_str << '\n'; |
| 88 | } else { |
| 89 | opname_instructions.insert(inst_str); |
| 90 | } |
| 91 | } |
| 92 | return std::make_tuple(oss.str(), std::move(opname_instructions)); |
| 93 | } |
| 94 | |
| 95 | // The test fixture for all tests of UnifyConstantPass. This fixture defines |
| 96 | // the rule of checking: all the optimized code should be exactly the same as |