-
Notifications
You must be signed in to change notification settings - Fork 5
Gamma domain #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Gamma domain #99
Changes from all commits
Commits
Show all changes
96 commits
Select commit
Hold shift + click to select a range
67ed71a
Gamma domain impl
b-paul 4d0b661
Initial gamma domain impl
b-paul a51bf22
Lattice map
b-paul 602917d
pretty
b-paul 7660374
Merge branch 'lattice-collections' into gamma-domain
b-paul 2e3bc9a
state
b-paul adffd50
Merge branch 'lattice-collections' into gamma-domain
b-paul 46f1e76
state
b-paul 1dce320
Merge branch 'lattice-collections' into gamma-domain
b-paul 44a7ba7
state
b-paul de727c9
Merge branch 'lattice-collections' into gamma-domain
b-paul bde8183
state
b-paul 28f62d8
Merge branch 'lattice-collections' into gamma-domain
b-paul 006425e
top on calls
b-paul 71aa1d5
Merge branch 'main' into lattice-collections
b-paul a9fb4af
latticeset plus proptests
b-paul 2873b38
lattice map tests
b-paul 3bc6219
pretty
b-paul 5affc95
Merge branch 'lattice-collections' into gamma-domain
b-paul 97410c3
singleton
b-paul a2a93f0
Merge branch 'lattice-collections' into gamma-domain
b-paul c522e7a
leq
b-paul b6d1b5a
Merge branch 'lattice-collections' into gamma-domain
b-paul 1517918
use lattice collections properly
b-paul 2c98881
leq (surprisingly complicated)
b-paul 60c6f4b
Merge branch 'main' into lattice-collections
b-paul ca01df7
fmt
b-paul 0254bc9
Merge branch 'lattice-collections' into gamma-domain
b-paul 234c681
Switch mapstate to use latticemap
b-paul 4bf7f40
fmt
b-paul 917c7be
hide patriciatree keys
b-paul fbda63c
fmt
b-paul ef2b982
Merge branch 'lattice-collections' into gamma-domain
b-paul 996b5b7
expose top map
b-paul 4c4f24e
Merge branch 'lattice-collections' into gamma-domain
b-paul 096b303
use new map state
b-paul cfb27ba
Merge branch 'main' into gamma-domain
b-paul 0f87530
ide gamma
b-paul 927e14d
Merge branch 'main' into gamma-domain
b-paul e0e0210
intra tests and comment ide
b-paul 687ca48
Merge branch 'main' into gamma-domain
b-paul e6a7adf
fmt
b-paul 1a392f1
remove test transform
b-paul 1a6c877
clarify todo note
b-paul 1d15e85
Force summarising all procedures with surprisingly no overhead
b-paul 33e19bc
monotonic scc index
b-paul b4024a9
optimisations
b-paul a62dc33
Merge branch 'main' of https://github.com/agle/bincaml into ide-impro…
b-paul 5191ae5
remove prints
b-paul 769cf7e
phase 1 only solver
b-paul 21c6cdc
Merge branch 'main' into ide-improvements
b-paul 9dd134b
Merge branch 'main' into gamma-domain
b-paul a86e5d4
Change phase1 only api to summarise just procs
b-paul 6cc7b46
dfg analysis
b-paul 21d1183
add ide analysis (depends on ide-improvements)
b-paul 22987b9
handle phis
b-paul 813f254
transfer only modified dls (faster this time!)
b-paul dc4aea3
dot printer
b-paul 83039d0
Merge branch 'ide-improvements' into gamma-domain
b-paul fd4db94
Reverse phi dir when forwards
b-paul a63360e
Merge branch 'ide-improvements' into gamma-domain
b-paul d6b1c7a
fix for ide changes
b-paul 68eec5d
Correct ide transfer
b-paul 0166ba8
compose on phis...
b-paul 513d14c
Merge branch 'ide-improvements' into gamma-domain
b-paul e4e3a40
more fix
b-paul e439d75
Finally make it work then note it's extremely slow
b-paul 0dcacc4
Merge branch 'main' into gamma-domain
b-paul 368f3cf
Untested solver!
b-paul ccefc79
Maybe works ?!
b-paul fc51a66
entry2exit cache
b-paul c881511
gen stubs and perf
b-paul 07a682b
Compute only relevant defuse or usedef
b-paul 7b6b530
compose correctly
b-paul 91551df
phase 2
b-paul c369103
test promote
b-paul 87903e7
remove test pass
b-paul 28b651b
phase 1 only function
b-paul 3fe939b
Merge remote-tracking branch 'origin/main' into gamma-domain
b-paul fde644a
Merge branch 'idessa' into gamma-domain
b-paul 3e4d1e9
use idessa
b-paul be08d91
docs types
b-paul 9af7e40
reusable defuse
b-paul a0b798b
Merge branch 'idessa' into gamma-domain
b-paul a38f336
Readd intra to test
b-paul cb482fe
Merge branch 'main' into gamma-domain
b-paul 63d0672
fixes
b-paul bc97267
Need output check to catch globals
b-paul 2daea03
ignore globals by assuming
b-paul d920ebe
interproc test
b-paul 13c9b16
Note issue with using summaries
b-paul 090233f
remove test pass
b-paul 03d9ec6
gen stubs properly (way slower now)
b-paul 19adb8b
merge main
b-paul 0c598ef
Merge branch 'main' into gamma-domain
b-paul e3a311c
Fix eval args
b-paul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| (* The forwards overappraximating gamma domain. It is assumed that the program is in ssa form. *) | ||
|
|
||
| include Lang | ||
| include Common | ||
| include Intra_analysis | ||
| include Lattice_collections | ||
|
|
||
| module GammaSet = struct | ||
| include LatticeSet (struct | ||
| include Var | ||
|
|
||
| let show = name | ||
| let name = "variable" | ||
| end) | ||
|
|
||
| let name = "Gamma set" | ||
| let pp fmt v = Format.pp_print_string fmt (show v) | ||
| end | ||
|
|
||
| module Domain = struct | ||
| include MapState (GammaSet) | ||
|
|
||
| let name = "Gamma domain" | ||
|
|
||
| let init proc = | ||
| Procedure.formal_in_params proc | ||
| |> StringMap.values | ||
| |> Iter.append | ||
| ((Procedure.specification proc).captures_globs |> Iter.of_list) | ||
| |> Iter.map (fun v -> (v, GammaSet.singleton v)) | ||
| |> Iter.fold (fun m (v, d) -> update v d m) bottom | ||
|
|
||
| let transfer_state m stmt = | ||
| let open Stmt in | ||
| let eval_expr e = | ||
| Expr.BasilExpr.free_vars_iter e | ||
| |> Iter.fold (fun s v' -> V.join (m v') s) V.bottom | ||
| in | ||
| match stmt with | ||
| | Instr_Assign a -> | ||
| Iter.of_list a |> Iter.map (fun (v, e) -> (v, eval_expr e)) | ||
| | Instr_Assert _ -> Iter.empty | ||
| | Instr_Assume _ -> Iter.empty | ||
| | Instr_Load { lhs; rhs; addr = Scalar } -> Iter.singleton (lhs, m rhs) | ||
| | Instr_Store { lhs; value; addr = Scalar } -> | ||
| Iter.singleton (lhs, eval_expr value) | ||
| | Instr_Load { lhs; rhs } -> Iter.singleton (lhs, m rhs) | ||
| | Instr_Store { lhs; value } -> | ||
| Iter.singleton (lhs, V.join (m lhs) (eval_expr value)) | ||
| (* could use IDE summaries, but that requires access to formal in params of caller *) | ||
| | Instr_Call { lhs } | Instr_IntrinCall { lhs } -> | ||
| StringMap.values lhs |> Iter.map (fun v -> (v, GammaSet.top)) | ||
| (* need to globally go to top which the transfer_state api doesn't support *) | ||
| (*| Instr_IndirectCall c -> raise (Failure "unsupported")*) | ||
| | Instr_IndirectCall _ -> Iter.empty | ||
|
|
||
| let transfer m (stmt : Program.stmt) = | ||
| let open Stmt in | ||
| match stmt with | ||
| (* TODO calls can be more precise with modifies information (only send outputs + modifies to top) but this requires spec info *) | ||
| | Instr_Call _ | Instr_IntrinCall _ | Instr_IndirectCall _ -> top | ||
| | s -> | ||
| transfer_state (fun v -> read v m) s | ||
| |> Iter.fold (fun m (v, s) -> update v s m) m | ||
| end | ||
|
|
||
| module CFGAnalysis = Forwards (Domain) | ||
| module DFGAnalysis = Dataflow_graph.AnalysisFwd (Domain) | ||
| open Idessi | ||
|
|
||
| (* TODO handle memory nicely *) | ||
| module IDEDomain : IDESSIDomain = struct | ||
| let direction = `Forwards | ||
|
|
||
| module DL = struct | ||
| type t = Lambda | Label of Var.t | ||
| [@@deriving eq, ord, show { with_path = false }] | ||
|
|
||
| let show = function Lambda -> "L" | Label v -> Var.name v | ||
| end | ||
|
|
||
| module Value = GammaSet | ||
|
|
||
| let show_state s = | ||
| s | ||
| |> Iter.to_string ~sep:", " (fun (v, s) -> | ||
| Var.to_string v ^ "->" ^ GammaSet.show s) | ||
|
|
||
| type t = BottomEdge | IdEdge | TopEdge | ||
| [@@deriving eq, ord, show { with_path = false }] | ||
|
|
||
| let pp fmt v = Format.pp_print_string fmt (show v) | ||
| let identity = IdEdge | ||
| let bottom = BottomEdge | ||
| let top = TopEdge | ||
|
|
||
| let compose a b = | ||
| match a with IdEdge -> b | BottomEdge -> BottomEdge | TopEdge -> TopEdge | ||
|
|
||
| let join a b = | ||
| match (a, b) with | ||
| | BottomEdge, e | e, BottomEdge -> e | ||
| | TopEdge, _ | _, TopEdge -> TopEdge | ||
| | IdEdge, IdEdge -> IdEdge | ||
|
|
||
| let eval s = function | ||
| | BottomEdge -> Value.bottom | ||
| | IdEdge -> s | ||
| | TopEdge -> Value.top | ||
|
|
||
| let init_data (proc : Program.proc) = | ||
| Procedure.formal_in_params proc |> StringMap.values | ||
|
|
||
| type state_update = (DL.t * t) Iter.t | ||
|
|
||
| open DL | ||
|
|
||
| let transfer_call call params d = | ||
| match d with | ||
| | Lambda -> Iter.singleton (d, IdEdge) | ||
| | Label v -> | ||
| StringMap.to_iter call | ||
| |> Iter.filter (fun (_, e) -> | ||
| Expr.BasilExpr.free_vars e |> VarSet.mem v) | ||
| |> Iter.map (fun (s, _) -> (Label (StringMap.find s params), IdEdge)) | ||
|
|
||
| let transfer stmt d = | ||
| let open Stmt in | ||
| match d with | ||
| | Lambda -> ( | ||
| match stmt with | ||
| | Instr_Load l -> Iter.singleton (Label l.lhs, TopEdge) | ||
| | _ -> Iter.empty) | ||
| | Label v -> ( | ||
| match stmt with | ||
| | Instr_Assign a -> | ||
| Iter.of_list a | ||
| |> Iter.flat_map (fun (v', e) -> | ||
| if VarSet.mem v (Expr.BasilExpr.free_vars e) then | ||
| Iter.singleton (Label v', IdEdge) | ||
| else Iter.empty) | ||
| | _ -> Iter.empty) | ||
|
|
||
| let transfer_phi lhs rhs d = | ||
| match d with | ||
| | Lambda -> Iter.empty | ||
| | Label v -> Iter.singleton (Label lhs, IdEdge) | ||
|
|
||
| let init_p2 (proc : Program.proc) = | ||
| Procedure.formal_in_params proc | ||
| |> StringMap.values | ||
| |> Iter.map (fun v -> (v, Value.singleton v)) | ||
| end | ||
|
|
||
| module IDEAnalysis = IDESSI (IDEDomain) | ||
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is confusing, maybe we should change the lattice name value to
lattice_nameor something