当前位置: 首页>>代码示例>>C++>>正文


C++ PassManager::record_running_regalloc方法代码示例

本文整理汇总了C++中PassManager::record_running_regalloc方法的典型用法代码示例。如果您正苦于以下问题:C++ PassManager::record_running_regalloc方法的具体用法?C++ PassManager::record_running_regalloc怎么用?C++ PassManager::record_running_regalloc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PassManager的用法示例。


在下文中一共展示了PassManager::record_running_regalloc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: run_pass

void RegAllocPass::run_pass(DexStoresVector& stores,
                            ConfigFiles&,
                            PassManager& mgr) {
  using Output = graph_coloring::Allocator::Stats;
  auto scope = build_class_scope(stores);
  auto stats = walk::parallel::reduce_methods<Output>(
      scope,
      [this](DexMethod* m) { // mapper
        graph_coloring::Allocator::Stats stats;
        if (m->get_code() == nullptr) {
          return stats;
        }
        auto& code = *m->get_code();

        TRACE(REG, 3, "Handling %s:\n", SHOW(m));
        TRACE(REG,
              5,
              "regs:%d code:\n%s\n",
              code.get_registers_size(),
              SHOW(&code));
        try {
          live_range::renumber_registers(&code, /* width_aware */ true);
          // The transformations below all require a CFG. Build it once
          // here instead of requiring each transform to build it.
          code.build_cfg(/* editable */ false);
          graph_coloring::Allocator allocator(m_allocator_config);
          allocator.allocate(m);
          stats.accumulate(allocator.get_stats());

          TRACE(REG,
                5,
                "After alloc: regs:%d code:\n%s\n",
                code.get_registers_size(),
                SHOW(&code));
        } catch (std::exception&) {
          fprintf(stderr, "Failed to allocate %s\n", SHOW(m));
          fprintf(stderr, "%s\n", SHOW(code.cfg()));
          throw;
        }
        return stats;
      },
      [](Output a, Output b) { // reducer
        a.accumulate(b);
        return a;
      });

  TRACE(REG, 1, "Total reiteration count: %lu\n", stats.reiteration_count);
  TRACE(REG, 1, "Total Params spilled early: %lu\n", stats.params_spill_early);
  TRACE(REG, 1, "Total spill count: %lu\n", stats.moves_inserted());
  TRACE(REG, 1, "  Total param spills: %lu\n", stats.param_spill_moves);
  TRACE(REG, 1, "  Total range spills: %lu\n", stats.range_spill_moves);
  TRACE(REG, 1, "  Total global spills: %lu\n", stats.global_spill_moves);
  TRACE(REG, 1, "  Total splits: %lu\n", stats.split_moves);
  TRACE(REG, 1, "Total coalesce count: %lu\n", stats.moves_coalesced);
  TRACE(REG, 1, "Total net moves: %ld\n", stats.net_moves());

  mgr.incr_metric("param spilled too early", stats.params_spill_early);
  mgr.incr_metric("reiteration_count", stats.reiteration_count);
  mgr.incr_metric("spill_count", stats.moves_inserted());
  mgr.incr_metric("coalesce_count", stats.moves_coalesced);
  mgr.incr_metric("net_moves", stats.net_moves());

  mgr.record_running_regalloc();
}
开发者ID:facebook,项目名称:redex,代码行数:64,代码来源:RegAlloc.cpp


注:本文中的PassManager::record_running_regalloc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。