Computes an instruction count for each function in the module represented by |binary|.
| 561 | // Computes an instruction count for each function in the module represented by |
| 562 | // |binary|. |
| 563 | std::unordered_map<uint32_t, uint32_t> GetFunctionInstructionCount( |
| 564 | const std::vector<uint32_t>& binary) { |
| 565 | std::unique_ptr<opt::IRContext> context = |
| 566 | BuildModule(kEnv, kMessageConsumer, binary.data(), binary.size()); |
| 567 | assert(context != nullptr && "Failed to build module."); |
| 568 | std::unordered_map<uint32_t, uint32_t> result; |
| 569 | for (auto& function : *context->module()) { |
| 570 | uint32_t& count = result[function.result_id()] = 0; |
| 571 | function.ForEachInst([&count](opt::Instruction*) { count++; }); |
| 572 | } |
| 573 | return result; |
| 574 | } |
| 575 | |
| 576 | TEST(ReducerTest, SingleFunctionReduction) { |
| 577 | Reducer reducer(kEnv); |
no test coverage detected