Interprocedural linear expression propagation#128
Merged
mira-alford merged 27 commits intomainfrom Apr 22, 2026
Merged
Conversation
mira-alford
reviewed
Apr 22, 2026
|
|
||
| Trace_core.with_span ~__FILE__ ~__LINE__ "transform" @@ fun _ -> | ||
| Program.map_procedures | ||
| (fun pid proc -> transform_proc p (Hashtbl.find gs pid) proc) |
Collaborator
There was a problem hiding this comment.
Empty procedures like this:
proc @shadow(x:bv64,y:bv64) -> () {}
[
block %shadow_entry [
goto (%shadow_return);
];
block %shadow_return [
return();
];
];
Have no internal variables and cause the hashmap lookup to crash. Should probably just skip such procedures given there is nothing to copy/transform anyway?
mira-alford
approved these changes
Apr 22, 2026
Collaborator
mira-alford
left a comment
There was a problem hiding this comment.
Aside from that crash on completely empty procedures, LGTM
mira-alford
pushed a commit
that referenced
this pull request
Apr 22, 2026
* move out linear functions * i think it works but it is slow * probably works (not slow) (could be very wrong) * Transform * comment * Better simplification * Fix copyprop collapsing (now to do the linear version... terrifying...) * fix linear copy propagation * It does copy prop faithfully! * Make copied_from not store edges (they were always id) * cleanup * remove old copy prop * Interproc correctly * Stubs * idk * doc * tracing * Bigger test * comment * bigger test... * test * push test oops * propagate bools through call in test * remove todo that is done * Handle id leaves cycles correctly + exit stubs go to bottom * skip empty procedures --------- Co-authored-: Mira-Alford <mira.alford@proton.me>
mira-alford
added a commit
that referenced
this pull request
Apr 22, 2026
* building declarations * Several fixes to smt + expr_smt * cleanup * Satisfied the ocaml formatter * quick fix to wpdual function calls * require `cmdliner>=2` (#132) versions less than 2 don't have the `Cmd.make` function which we now use. * Interprocedural linear expression propagation (#128) * move out linear functions * i think it works but it is slow * probably works (not slow) (could be very wrong) * Transform * comment * Better simplification * Fix copyprop collapsing (now to do the linear version... terrifying...) * fix linear copy propagation * It does copy prop faithfully! * Make copied_from not store edges (they were always id) * cleanup * remove old copy prop * Interproc correctly * Stubs * idk * doc * tracing * Bigger test * comment * bigger test... * test * push test oops * propagate bools through call in test * remove todo that is done * Handle id leaves cycles correctly + exit stubs go to bottom * skip empty procedures --------- Co-authored-: Mira-Alford <mira.alford@proton.me> * removed comments as per jacksons DEMANDS --------- Co-authored-by: Kait <39479354+katrinafyi@users.noreply.github.com> Co-authored-by: b-paul <bpaul@bpaul.xyz>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This transform propagates assignments that are linear functions (a * x + b) through their uses. For example, if
R31_2 := R31_1 - 0x2c0then every use ofR31_2would be replaced by the expressionR31_1 - 0x2c0(plus transitivity).For this transform to be a superset of copy propagation we also need to do a simultaneous copy only analysis, so that phi nodes are properly propagated into (since phis can only have variables in them, not linear expressions). Since it's a superset the old copyprop was removed.
The transform is interprocedural and super fast (700ms)!! I also added some stub stuff to make it propagate R31s on stubs properly !! (deleted abort case text) it handles exits too!!!!
Interestingly also the transform spends a lot of time doing wellformedness checks (the blank part)
