Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
FractalFir committed Jan 6, 2025
1 parent 7c5d1e9 commit ff2138b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions cilly/src/v2/opt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ impl MethodDef {
self.implementation_mut().remove_duplicate_sfi(asm);
}
if let MethodImpl::MethodBody { blocks, .. } = self.implementation_mut() {
linearize_blocks(blocks,&asm);
linearize_blocks(blocks,&asm,fuel);
}

self.remove_useless_handlers(asm, fuel, cache);
Expand Down Expand Up @@ -610,12 +610,12 @@ impl MethodDef {
let curr = peekable.next().unwrap();
*curr = asm.alloc_root(CILRoot::Ret(tree));
}
(CILRoot::Branch(info), CILRoot::Branch(_))
/*(CILRoot::Branch(info), CILRoot::Branch(_))
if is_branch_unconditional(info) =>
{
let curr = peekable.next().unwrap();
*curr = nop;
}
}*/
(CILRoot::Branch(info), CILRoot::Branch(info2))
if is_branch_unconditional(info2) =>
{
Expand Down Expand Up @@ -1163,7 +1163,7 @@ fn remove_nops() {
assert_eq!(mimpl.blocks_mut().unwrap()[0].roots().len(), 2);
}
/// Replaces a sequence of blocks with unconditional jumps with a single block.
fn linearize_blocks(blocks: &mut Vec<BasicBlock>, asm: &Assembly) {
fn linearize_blocks(blocks: &mut Vec<BasicBlock>, asm: &Assembly,fuel: &mut OptFuel) {
// 1. This optimization *only* works if no handlers present.
if blocks.iter().any(|block| block.handler().is_some()) {
return;
Expand Down Expand Up @@ -1206,5 +1206,8 @@ fn linearize_blocks(blocks: &mut Vec<BasicBlock>, asm: &Assembly) {
}
}
}
*blocks = vec![BasicBlock::new(res, 0, None)];
if fuel.consume(1){
*blocks = vec![BasicBlock::new(res, 0, None)];
}

}
2 changes: 1 addition & 1 deletion test/bench/iter.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const BIG: i64 = 1000_000_000;
const BIG: i64 = 100_000_000;
fn bench_for_each_chain_fold() -> i64 {
let mut acc = 0;
let iter = (0i64..BIG).chain(0..BIG).map(std::hint::black_box);
Expand Down

0 comments on commit ff2138b

Please sign in to comment.