Skip to content

Commit e5aa998

Browse files
authored
Remove indicatif dependency from bugpoint (#12048)
This has fallen pretty far behind the development of upstream, it now has unmaintained dependencies, and AFAIK it's not a load-bearing dependency at this time. Remove it in favor of simple prints for now. Closes #12045
1 parent 7fb8b55 commit e5aa998

File tree

3 files changed

+4
-96
lines changed

3 files changed

+4
-96
lines changed

Cargo.lock

Lines changed: 0 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cranelift/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ capstone = { workspace = true, optional = true }
4040
target-lexicon = { workspace = true, features = ["std"] }
4141
env_logger = { workspace = true }
4242
rayon = { version = "1", optional = true }
43-
indicatif = "0.13.0"
4443
thiserror = { workspace = true }
4544
walkdir = { workspace = true }
4645
anyhow = { workspace = true }

cranelift/src/bugpoint.rs

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use cranelift_codegen::ir::{
1515
use cranelift_codegen::isa::TargetIsa;
1616
use cranelift_entity::PrimaryMap;
1717
use cranelift_reader::{ParseOptions, parse_sets_and_triple, parse_test};
18-
use indicatif::{ProgressBar, ProgressDrawTarget, ProgressStyle};
1918
use std::collections::HashMap;
2019
use std::path::PathBuf;
2120

@@ -96,7 +95,6 @@ enum ProgressStatus {
9695

9796
trait Mutator {
9897
fn name(&self) -> &'static str;
99-
fn mutation_count(&self, func: &Function) -> usize;
10098
fn mutate(&mut self, func: Function) -> Option<(Function, String, ProgressStatus)>;
10199

102100
/// Gets called when the returned mutated function kept on causing the crash. This can be used
@@ -126,10 +124,6 @@ impl Mutator for RemoveInst {
126124
"remove inst"
127125
}
128126

129-
fn mutation_count(&self, func: &Function) -> usize {
130-
inst_count(func)
131-
}
132-
133127
fn mutate(&mut self, mut func: Function) -> Option<(Function, String, ProgressStatus)> {
134128
next_inst_ret_prev(&func, &mut self.block, &mut self.inst).map(|(prev_block, prev_inst)| {
135129
func.layout.remove_inst(prev_inst);
@@ -167,10 +161,6 @@ impl Mutator for ReplaceInstWithConst {
167161
"replace inst with const"
168162
}
169163

170-
fn mutation_count(&self, func: &Function) -> usize {
171-
inst_count(func)
172-
}
173-
174164
fn mutate(&mut self, mut func: Function) -> Option<(Function, String, ProgressStatus)> {
175165
next_inst_ret_prev(&func, &mut self.block, &mut self.inst).map(
176166
|(_prev_block, prev_inst)| {
@@ -261,10 +251,6 @@ impl Mutator for ReplaceInstWithTrap {
261251
"replace inst with trap"
262252
}
263253

264-
fn mutation_count(&self, func: &Function) -> usize {
265-
inst_count(func)
266-
}
267-
268254
fn mutate(&mut self, mut func: Function) -> Option<(Function, String, ProgressStatus)> {
269255
next_inst_ret_prev(&func, &mut self.block, &mut self.inst).map(
270256
|(_prev_block, prev_inst)| {
@@ -302,10 +288,6 @@ impl Mutator for MoveInstToEntryBlock {
302288
"move inst to entry block"
303289
}
304290

305-
fn mutation_count(&self, func: &Function) -> usize {
306-
inst_count(func)
307-
}
308-
309291
fn mutate(&mut self, mut func: Function) -> Option<(Function, String, ProgressStatus)> {
310292
next_inst_ret_prev(&func, &mut self.block, &mut self.inst).map(|(prev_block, prev_inst)| {
311293
// Don't move instructions that are already in entry block
@@ -350,10 +332,6 @@ impl Mutator for RemoveBlock {
350332
"remove block"
351333
}
352334

353-
fn mutation_count(&self, func: &Function) -> usize {
354-
block_count(func)
355-
}
356-
357335
fn mutate(&mut self, mut func: Function) -> Option<(Function, String, ProgressStatus)> {
358336
func.layout.next_block(self.block).map(|next_block| {
359337
self.block = next_block;
@@ -391,13 +369,6 @@ impl Mutator for ReplaceBlockParamWithConst {
391369
"replace block parameter with const"
392370
}
393371

394-
fn mutation_count(&self, func: &Function) -> usize {
395-
func.layout
396-
.blocks()
397-
.map(|block| func.dfg.num_block_params(block))
398-
.sum()
399-
}
400-
401372
fn mutate(&mut self, mut func: Function) -> Option<(Function, String, ProgressStatus)> {
402373
while self.params_remaining == 0 {
403374
self.block = func.layout.next_block(self.block)?;
@@ -461,10 +432,6 @@ impl Mutator for RemoveUnusedEntities {
461432
"remove unused entities"
462433
}
463434

464-
fn mutation_count(&self, _func: &Function) -> usize {
465-
4
466-
}
467-
468435
fn mutate(&mut self, mut func: Function) -> Option<(Function, String, ProgressStatus)> {
469436
let name = match self.kind {
470437
0 => {
@@ -682,11 +649,6 @@ impl Mutator for MergeBlocks {
682649
"merge blocks"
683650
}
684651

685-
fn mutation_count(&self, func: &Function) -> usize {
686-
// N blocks may result in at most N-1 merges.
687-
block_count(func) - 1
688-
}
689-
690652
fn mutate(&mut self, mut func: Function) -> Option<(Function, String, ProgressStatus)> {
691653
let block = match func.layout.next_block(self.block) {
692654
Some(block) => block,
@@ -852,11 +814,6 @@ fn reduce(isa: &dyn TargetIsa, mut func: Function, verbose: bool) -> Result<(Fun
852814
try_resolve_aliases(&mut context, &mut func);
853815
try_remove_srclocs(&mut context, &mut func);
854816

855-
let progress_bar = ProgressBar::with_draw_target(0, ProgressDrawTarget::stdout());
856-
progress_bar.set_style(
857-
ProgressStyle::default_bar().template("{bar:60} {prefix:40} {pos:>4}/{len:>4} {msg}"),
858-
);
859-
860817
for pass_idx in 0..100 {
861818
let mut should_keep_reducing = false;
862819
let mut phase = 0;
@@ -874,16 +831,9 @@ fn reduce(isa: &dyn TargetIsa, mut func: Function, verbose: bool) -> Result<(Fun
874831
_ => break,
875832
};
876833

877-
progress_bar.set_prefix(&format!("pass {} phase {}", pass_idx, mutator.name()));
878-
progress_bar.set_length(mutator.mutation_count(&func) as u64);
879-
880-
// Reset progress bar.
881-
progress_bar.set_position(0);
882-
progress_bar.set_draw_delta(0);
834+
println!("pass {} phase {}", pass_idx, mutator.name());
883835

884836
for _ in 0..10000 {
885-
progress_bar.inc(1);
886-
887837
let (mutated_func, msg, mutation_kind) = match mutator.mutate(func.clone()) {
888838
Some(res) => res,
889839
None => {
@@ -897,8 +847,6 @@ fn reduce(isa: &dyn TargetIsa, mut func: Function, verbose: bool) -> Result<(Fun
897847
continue;
898848
}
899849

900-
progress_bar.set_message(&msg);
901-
902850
match context.check_for_crash(&mutated_func) {
903851
CheckResult::Succeed => {
904852
// Mutating didn't hit the problem anymore, discard changes.
@@ -920,7 +868,7 @@ fn reduce(isa: &dyn TargetIsa, mut func: Function, verbose: bool) -> Result<(Fun
920868
ProgressStatus::Skip => unreachable!(),
921869
};
922870
if verbose {
923-
progress_bar.println(format!("{msg}: {verb}"));
871+
println!("{msg}: {verb}");
924872
}
925873
}
926874
}
@@ -929,7 +877,7 @@ fn reduce(isa: &dyn TargetIsa, mut func: Function, verbose: bool) -> Result<(Fun
929877
phase += 1;
930878
}
931879

932-
progress_bar.println(format!(
880+
println!(
933881
"After pass {}, remaining insts/blocks: {}/{} ({})",
934882
pass_idx,
935883
inst_count(&func),
@@ -939,7 +887,7 @@ fn reduce(isa: &dyn TargetIsa, mut func: Function, verbose: bool) -> Result<(Fun
939887
} else {
940888
"stop reducing"
941889
}
942-
));
890+
);
943891

944892
if !should_keep_reducing {
945893
// No new shrinking opportunities have been found this pass. This means none will ever
@@ -949,7 +897,6 @@ fn reduce(isa: &dyn TargetIsa, mut func: Function, verbose: bool) -> Result<(Fun
949897
}
950898

951899
try_resolve_aliases(&mut context, &mut func);
952-
progress_bar.finish();
953900

954901
let crash_msg = match context.check_for_crash(&func) {
955902
CheckResult::Succeed => unreachable!("Used to crash, but doesn't anymore???"),

0 commit comments

Comments
 (0)