Dead Code Elimination Transformation#979
Conversation
5ad50bb to
7162989
Compare
|
There should be no more material changes to this pull request. |
michael-schwarz
left a comment
There was a problem hiding this comment.
As soon as you have convinced yourself that the issue with gotos mentioned above is a non-issue, I think this is ready to merge!
|
@sim642 any comments before we merge? |
sim642
left a comment
There was a problem hiding this comment.
How does this handle the fact that there isn't a one-to-one correspondance between our CFG nodes (which we compute liveness for) and CIL statements?
That is, our CFG construction skips over many CIL statements, so we don't compute liveness for many of them. Evene moreso, CfgTools never puts Block statements into nodes (which are handled here), but instead Instr statements (which are left into the default true case here).
It would be good to have (e.g. cram) tests for this that really show all aspects working, because I'm not entirely convinced right now.
CIL transformations working at the level of statements and locations instead of our CFG nodes has been an issue in the past (other transformations have a bunch of hackery regarding this), so it's odd that this transformation can get away with not needing any such special treatment.
Edit: Looks like I still had some misunderstandings about CFG construction. The current implementation kind of gets lucky; if statements and while loops have a location that corresponds to the condition node in the CFG, and are thus kept if the condition node is live, and single All other CIL statements, which are not in the CFG at all, are always kept. This includes plain To do things properly, it looks like it is necessary to traverse through CIL statements in the same way as CFG construction. Then, liveness of Original comment: CIL statements are put in three categories by this transformation:
Only the first category is removed. (By "result" I mean the
The case distinction only handles the recursion. A dead analyzer/src/transform/deadCode.ml Lines 15 to 18 in 8d86284
Edit: it would probably make sense for transformations to work on statements/function declarations (i.e., pass those to |
This is essentially what I've implemented now. Statements that are skipped during CFG construction are tracked directly. Then, a statement between two nodes is considered dead if the preceding or following node is dead (with appropriate handling for statements on multiple such paths). |
28e1878 to
bda31f0
Compare
|
Integrated review (ff9aa70...just-max:goblint-analyzer:deadcode_removal).
Of course it comes down to bash not waiting for processes inside process substitution. Fixed by using temp file instead. Also, it probably never makes sense for cram tests to have backtraces enabled (in CI), since those are very fragile. Edit: Making this work on Mac without having such a system locally is quite frustrating. The |
I feel you, I have the same issue all the time myself too! |
|
As Simmo suggested, I've used a string constant in dead conditions. Everything should be ready now. |
CHANGES: * Add `setjmp`/`longjmp` analysis (goblint/analyzer#887, goblint/analyzer#970, goblint/analyzer#1015, goblint/analyzer#1019). * Refactor race analysis to lazy distribution (goblint/analyzer#1084, goblint/analyzer#1089, goblint/analyzer#1136, goblint/analyzer#1016). * Add thread-unsafe library function call analysis (goblint/analyzer#723, goblint/analyzer#1082). * Add mutex type analysis and mutex API analysis (goblint/analyzer#800, goblint/analyzer#839, goblint/analyzer#1073). * Add interval set domain and string literals domain (goblint/analyzer#901, goblint/analyzer#966, goblint/analyzer#994, goblint/analyzer#1048). * Add affine equalities analysis (goblint/analyzer#592). * Add use-after-free analysis (goblint/analyzer#1050, goblint/analyzer#1114). * Add dead code elimination transformation (goblint/analyzer#850, goblint/analyzer#979). * Add taint analysis for partial contexts (goblint/analyzer#553, goblint/analyzer#952). * Add YAML witness validation via unassume (goblint/analyzer#796, goblint/analyzer#977, goblint/analyzer#1044, goblint/analyzer#1045, goblint/analyzer#1124). * Add incremental analysis rename detection (goblint/analyzer#774, goblint/analyzer#777). * Fix address sets unsoundness (goblint/analyzer#822, goblint/analyzer#967, goblint/analyzer#564, goblint/analyzer#1032, goblint/analyzer#998, goblint/analyzer#1031). * Fix thread escape analysis unsoundness (goblint/analyzer#939, goblint/analyzer#984, goblint/analyzer#1074, goblint/analyzer#1078). * Fix many incremental analysis issues (goblint/analyzer#627, goblint/analyzer#836, goblint/analyzer#835, goblint/analyzer#841, goblint/analyzer#932, goblint/analyzer#678, goblint/analyzer#942, goblint/analyzer#949, goblint/analyzer#950, goblint/analyzer#957, goblint/analyzer#955, goblint/analyzer#954, goblint/analyzer#960, goblint/analyzer#959, goblint/analyzer#1004, goblint/analyzer#558, goblint/analyzer#1010, goblint/analyzer#1091). * Fix server mode for abstract debugging (goblint/analyzer#983, goblint/analyzer#990, goblint/analyzer#997, goblint/analyzer#1000, goblint/analyzer#1001, goblint/analyzer#1013, goblint/analyzer#1018, goblint/analyzer#1017, goblint/analyzer#1026, goblint/analyzer#1027). * Add documentation for configuration JSON schema and OCaml API (goblint/analyzer#999, goblint/analyzer#1054, goblint/analyzer#1055, goblint/analyzer#1053). * Add many library function specifications (goblint/analyzer#962, goblint/analyzer#996, goblint/analyzer#1028, goblint/analyzer#1079, goblint/analyzer#1121, goblint/analyzer#1135, goblint/analyzer#1138). * Add OCaml 5.0 support (goblint/analyzer#1003, goblint/analyzer#945, goblint/analyzer#1162).
Dead code elimination transformation as suggested by Simmo in #850.
The implementation in its current state is still quite messy, but all the important bits should be there.The transformation:
This PR also makes small changes to the transformation subsystem:
Merging will close #850.
TODO: