Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
38a5659
fix: add a `remove_unreachable_instructions` SSA pass
asterite Jun 19, 2025
2702a7d
Add a regression test
asterite Jun 19, 2025
1f59a54
Run it before removing unreachable functions
asterite Jun 19, 2025
d336b7d
Slightly improve pass name
asterite Jun 19, 2025
1d80bd8
Simplify logic
asterite Jun 19, 2025
ea2378d
If a block is unreachable, its successors are too
asterite Jun 19, 2025
36902d8
Traverse blocks in pre-order
asterite Jun 19, 2025
aaa9c0e
All successors are unreachable unless we saw them before
asterite Jun 19, 2025
d0d9ab2
Update snapshots
asterite Jun 19, 2025
cfa132a
Add all successors transitively right away
asterite Jun 19, 2025
50ab93a
One more snapshot
asterite Jun 19, 2025
da3d2c2
DominatorTree to the rescue!
asterite Jun 19, 2025
f1eeaf2
Snapshots
asterite Jun 19, 2025
c4407d0
Merge branch 'master' into ab/ssa-remove-unreachable-instructions
asterite Jun 19, 2025
5e2f39e
`simple_reachable_blocks_optimization` is fine
asterite Jun 23, 2025
4d314ac
add_successors -> add_dominated_blocks
asterite Jun 23, 2025
b2b7865
More renames and comments
asterite Jun 23, 2025
1375346
Comment
asterite Jun 23, 2025
763ce42
Rename tests
asterite Jun 23, 2025
9638edb
Add an unreachable terminator
asterite Jun 23, 2025
426f390
Produce unreachable terminators
asterite Jun 23, 2025
cd83277
Assume unreachable can't be reached
asterite Jun 23, 2025
e21e963
Add a test for constrain not equal
asterite Jun 23, 2025
5b7e58b
Snapshots
asterite Jun 23, 2025
88ffc6d
Merge branch 'master' into ab/ssa-remove-unreachable-instructions
asterite Jun 23, 2025
f06f049
Fix comment
asterite Jun 23, 2025
6118feb
Better handling of unreachable terminator
asterite Jun 23, 2025
3b0cce7
Add another test
asterite Jun 23, 2025
216941f
Remove unreachable instructions in the first SSA pass
asterite Jun 23, 2025
77e8e75
Revert "Remove unreachable instructions in the first SSA pass"
asterite Jun 23, 2025
6e4e138
Handle unreachable during inlining with a panic
asterite Jun 23, 2025
f127e37
Revert "Produce unreachable terminators"
asterite Jun 23, 2025
76d7465
Revert "Add an unreachable terminator"
asterite Jun 23, 2025
97fc0ff
Revert "Fix comment"
asterite Jun 23, 2025
3a8e362
Fix tests
asterite Jun 23, 2025
f72c9db
Remove unreachable instructions in the first SSA pass
asterite Jun 23, 2025
b1153aa
Merge branch 'master' into ab/ssa-remove-unreachable-instructions
asterite Jun 23, 2025
67532e6
Merge branch 'ab/ssa-remove-unreachable-instructions' of github.com:n…
asterite Jun 23, 2025
4524633
Snapshots
asterite Jun 23, 2025
8abe8f8
Try with dummy ref
aakoshh Jun 24, 2025
2e13bd6
Use reverse post order
aakoshh Jun 24, 2025
0f59793
Fix: if no predecessors then reachable
aakoshh Jun 24, 2025
224f58f
Need dominator tree for loops
aakoshh Jun 24, 2025
d2cf2b7
Merge remote-tracking branch 'origin/master' into ab/ssa-remove-unrea…
aakoshh Jun 24, 2025
e141268
Need zeroing as well
aakoshh Jun 24, 2025
2c957c6
Preserve consts
aakoshh Jun 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion compiler/noirc_evaluator/src/ssa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ pub struct ArtifactsAndWarnings(pub Artifacts, pub Vec<SsaReport>);
/// something we take can advantage of in the [secondary_passes].
pub fn primary_passes(options: &SsaEvaluatorOptions) -> Vec<SsaPass> {
vec![
SsaPass::new(Ssa::remove_unreachable_instructions, "Remove Unreachable Instructions"),
SsaPass::new(Ssa::remove_unreachable_functions, "Removing Unreachable Functions"),
SsaPass::new(Ssa::defunctionalize, "Defunctionalization"),
SsaPass::new(Ssa::inline_simple_functions, "Inlining simple functions"),
Expand Down Expand Up @@ -213,7 +214,9 @@ pub fn primary_passes(options: &SsaEvaluatorOptions) -> Vec<SsaPass> {
SsaPass::new(Ssa::brillig_array_get_and_set, "Brillig Array Get and Set Optimizations"),
// Perform another DIE pass to update the used globals after offsetting Brillig indexes.
SsaPass::new(Ssa::dead_instruction_elimination, "Dead Instruction Elimination"),
// A function can be potentially unreachable post-DIE if all calls to that function were removed.
SsaPass::new(Ssa::remove_unreachable_instructions, "Remove Unreachable Instructions"),
Comment thread
asterite marked this conversation as resolved.
// A function can be potentially unreachable post-DIE if all calls to that function were removed,
// or after the removal of unreachable instructions.
SsaPass::new(Ssa::remove_unreachable_functions, "Removing Unreachable Functions"),
SsaPass::new(Ssa::checked_to_unchecked, "Checked to unchecked"),
SsaPass::new_try(
Expand All @@ -229,6 +232,7 @@ pub fn primary_passes(options: &SsaEvaluatorOptions) -> Vec<SsaPass> {
pub fn secondary_passes(brillig: &Brillig) -> Vec<SsaPass> {
vec![
SsaPass::new(move |ssa| ssa.fold_constants_with_brillig(brillig), "Inlining Brillig Calls"),
SsaPass::new(Ssa::remove_unreachable_instructions, "Remove Unreachable Instructions"),
// It could happen that we inlined all calls to a given brillig function.
// In that case it's unused so we can remove it. This is what we check next.
SsaPass::new(Ssa::remove_unreachable_functions, "Removing Unreachable Functions"),
Expand Down
1 change: 1 addition & 0 deletions compiler/noirc_evaluator/src/ssa/opt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ mod remove_enable_side_effects;
mod remove_if_else;
mod remove_truncate_after_range_check;
mod remove_unreachable;
mod remove_unreachable_instructions;
mod simple_optimization;
mod simplify_cfg;
mod unrolling;
Expand Down
Loading
Loading