Skip to content

Commit

Permalink
[FIX] fixing dbe
Browse files Browse the repository at this point in the history
  • Loading branch information
Cr0a3 committed Oct 29, 2024
1 parent bac42b6 commit 7729833
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Optimizations/Passes/DeadBlockElimination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ impl Pass for DeadBlockElimination {
for block in func.blocks.clone() {
if !used_blocks.contains(&block.name) && index != 0 { // do not remove first block
func.blocks.remove(index);
} else { // no removed block
index += 1;
}

index += 1;
}
}
}
29 changes: 29 additions & 0 deletions tests/bugs/dbe_block_remove_index.yl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# RUN:
cargo run -p ylc -- -in=%s -passes=dbe -fmt
# IN:

define i32 @main() {
entry:
br ret

ret:
br after_should_be_removed

should_be_removed:
ret i32 1

after_should_be_removed:
ret i32 12345
}

# STDOUT:
define i32 @main() {
entry:
br ret

ret:
br after_should_be_removed

after_should_be_removed:
ret i32 12345
}

0 comments on commit 7729833

Please sign in to comment.