Skip to content

Commit 69eab17

Browse files
committed
ZJIT: Clean up run_pass with macro identifier matching
Thanks, Alan.
1 parent 8003f48 commit 69eab17

1 file changed

Lines changed: 15 additions & 23 deletions

File tree

zjit/src/hir.rs

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5620,33 +5620,25 @@ impl Function {
56205620
let mut passes: Vec<Json> = Vec::new();
56215621
let should_dump = get_option!(dump_hir_iongraph);
56225622

5623-
macro_rules! ident_equal {
5624-
($a:ident, $b:ident) => { stringify!($a) == stringify!($b) };
5623+
macro_rules! counter_for {
5624+
// Bucket all strength reduction together
5625+
(type_specialize) => { Counter::compile_hir_strength_reduce_time_ns };
5626+
(inline) => { Counter::compile_hir_strength_reduce_time_ns };
5627+
(optimize_getivar) => { Counter::compile_hir_strength_reduce_time_ns };
5628+
(optimize_c_calls) => { Counter::compile_hir_strength_reduce_time_ns };
5629+
// End strength reduction bucket };
5630+
(optimize_load_store) => { Counter::compile_hir_optimize_load_store_time_ns };
5631+
(fold_constants) => { Counter::compile_hir_fold_constants_time_ns };
5632+
(clean_cfg) => { Counter::compile_hir_clean_cfg_time_ns };
5633+
(remove_redundant_patch_points) => { Counter::compile_hir_remove_redundant_patch_points_time_ns };
5634+
(remove_duplicate_check_interrupts) => { Counter::compile_hir_remove_duplicate_check_interrupts_time_ns };
5635+
(eliminate_dead_code) => { Counter::compile_hir_eliminate_dead_code_time_ns };
5636+
($name:ident) => { unimplemented!("Counter for pass {}", stringify!($name)) };
56255637
}
56265638

56275639
macro_rules! run_pass {
56285640
($name:ident) => {
5629-
// Bucket all strength reduction together
5630-
let counter = if ident_equal!($name, type_specialize)
5631-
|| ident_equal!($name, inline)
5632-
|| ident_equal!($name, optimize_getivar)
5633-
|| ident_equal!($name, optimize_c_calls) {
5634-
Counter::compile_hir_strength_reduce_time_ns
5635-
} else if ident_equal!($name, optimize_load_store) {
5636-
Counter::compile_hir_optimize_load_store_time_ns
5637-
} else if ident_equal!($name, fold_constants) {
5638-
Counter::compile_hir_fold_constants_time_ns
5639-
} else if ident_equal!($name, clean_cfg) {
5640-
Counter::compile_hir_clean_cfg_time_ns
5641-
} else if ident_equal!($name, remove_redundant_patch_points) {
5642-
Counter::compile_hir_remove_redundant_patch_points_time_ns
5643-
} else if ident_equal!($name, remove_duplicate_check_interrupts) {
5644-
Counter::compile_hir_remove_duplicate_check_interrupts_time_ns
5645-
} else if ident_equal!($name, eliminate_dead_code) {
5646-
Counter::compile_hir_eliminate_dead_code_time_ns
5647-
} else {
5648-
unimplemented!("Counter for pass {}", stringify!($name));
5649-
};
5641+
let counter = counter_for!($name);
56505642
crate::stats::with_time_stat(counter, || self.$name());
56515643
#[cfg(debug_assertions)] self.assert_validates();
56525644
if should_dump {

0 commit comments

Comments
 (0)