Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Summary: This pass got broken when it was upgraded to editable cfg, which wasn't noticed as it was generally disabled. This is being fixed here.

Reviewed By: beicy

Differential Revision: D51869435

fbshipit-source-id: 0e8de70c867f76be9e6621d3d9b7547c616a2beb
  • Loading branch information
Nikolai Tillmann authored and facebook-github-bot committed Dec 7, 2023
1 parent 24d6824 commit 43f23bd
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions opt/split_huge_switches/SplitHugeSwitchPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ using Stats = SplitHugeSwitchPass::Stats;

namespace {

bool has_switch(IRCode* code) {
for (const auto& mie : InstructionIterable(*code)) {
auto opcode = mie.insn->opcode();
if (opcode::is_switch(opcode)) {
return true;
bool has_switch(cfg::ControlFlowGraph& cfg) {
for (auto* block : cfg.blocks()) {
for (const auto& mie : InstructionIterable(block)) {
auto opcode = mie.insn->opcode();
if (opcode::is_switch(opcode)) {
return true;
}
}
}
return false;
Expand Down Expand Up @@ -529,15 +531,15 @@ AnalysisData analyze(DexMethod* m,
data.under_code_units_threshold = false;
// stats.large_methods_set.emplace(m);

if (!has_switch(code)) {
cfg::ScopedCFG scoped_cfg(code);

if (!has_switch(*scoped_cfg)) {
data.no_switch = true;
return data;
}
data.no_switch = false;
// stats.switch_methods_set.emplace(m);

cfg::ScopedCFG scoped_cfg(code);

auto switch_it = find_large_switch(*scoped_cfg, case_threshold);
if (switch_it.is_end()) {
data.no_large_switch = true;
Expand Down

0 comments on commit 43f23bd

Please sign in to comment.