Commit Graph

3168 Commits

Author SHA1 Message Date
Alain Carlucci 2cda9be797 Decompile one function + write on raw_ostream 2019-02-08 11:44:17 +01:00
Andrea Gussoni eba245d35e RemoveBadPC pass
Added a pass that removes the `bad_return_pc` check, which is useful
only when we want to preserve semantics, but it is useless and harmful
for decompilation.
2019-02-07 19:27:08 +01:00
Pietro Fezzardi 7fc7ac4c7b Finish EnforceCFGCombingPass 2019-02-07 19:26:37 +01:00
Pietro Fezzardi c455b516d2 Add Liveness again 2019-02-07 14:44:32 +01:00
Andrea Gussoni 2e9ff8449f Improved debugging messages 2019-02-05 10:17:47 +01:00
Andrea Gussoni c43b7989ce Improved SCS identification phase
Now in the `SCS` identification phase, when creating a SCS, if we
contain a node which is the source of another (sub)SCS, we also include
that SCS in the current SCS (in order to increase the number of nested
subregions).

The exception to this situation is when the source of the
other SCS is the head of the region itself under analysis.
2019-02-05 10:17:41 +01:00
Andrea Gussoni 5f5bb6cae8 Serialize RegionCFG at each inflate iteration 2019-02-05 09:56:32 +01:00
Andrea Gussoni 4d6e8a24d3 Inflate a region only once 2019-02-05 09:55:06 +01:00
Andrea Gussoni 6231ba7bed Comb ignores useless conditional nodes
When the `then` and `else` branches of a conditional node reach two
disjoint sets of exit nodes do not consider that nodes in the `inflate`
procedure.
2019-02-05 09:54:23 +01:00
Andrea Gussoni 4bd6767038 Improved purgeDummies function
Improved the `purgeDummies` function, in order to better interact with
the dominator and postdominator trees
2019-02-05 09:54:23 +01:00
Andrea Gussoni 414aba5f66 Dot serialize function now const 2019-02-05 09:54:14 +01:00
Andrea Gussoni 497bd0d02e Fix exit dispatcher creation 2019-02-04 18:34:14 +01:00
Pietro Fezzardi d900086172 EnforceCFGCombingPass: emit artificial nodes 2019-02-02 01:41:37 +01:00
Pietro Fezzardi c9d2ea9462 Fix tranfser function for BasicBlockViewAnalysis 2019-02-02 01:41:07 +01:00
Pietro Fezzardi 2afd5053e6 Rework exit and entry dispatcher trees 2019-02-01 19:24:56 +01:00
Pietro Fezzardi 2c93512f90 Rework BasicBlockNode class 2019-02-01 15:08:53 +01:00
Pietro Fezzardi 2fa2428ef0 Fix BasicBlockViewMap Lattice comparison 2019-02-01 12:02:23 +01:00
Andrea Gussoni 6d7fb09c53 Purge dummies at each inflate iteration
Purge useless dummies at each iteration of the inflate process.
This simplifies the inflate process and make debug easier.
2019-01-31 10:57:22 +01:00
Andrea Gussoni 0cdb63630e Restructure ASTTree anatomy
Added a pointer to the `RootNode` in the ASTTree, and added a
`dumpOnFile` method for easier serialization.
2019-01-30 18:35:24 +01:00
Andrea Gussoni 9202742343 TEMP disable some functions 2019-01-30 16:46:36 +01:00
Pietro Fezzardi 099ae4d479 First stub of flattening 2019-01-30 09:22:20 +01:00
Andrea Gussoni c88ccdff43 Fix include guards
Fixed some include guards in the header files of the imported libraries,
which where missing or not conform to the convention.
2019-01-28 18:54:10 +01:00
Andrea Gussoni e5187a61d9 Use new DominatorTree update features
Instead of rebuilding the dominator and postdominator at each iteration
of the inflate procedure, use the utilities introduced in LLVM 7.0 to
keep the data structures updated after each change to the RegionCFG.
2019-01-28 15:13:25 +01:00
Pietro Fezzardi 20a336344e Add state variable info to dummy BasicBlockNodes 2019-01-25 18:36:37 +01:00
Pietro Fezzardi 9de18977ad Use only cloneNode to clone Nodes 2019-01-25 17:32:55 +01:00
Pietro Fezzardi 3b8400992f Fix dangling pointers to RegionCFG stack variables 2019-01-25 17:20:24 +01:00
Andrea Gussoni 465380b787 Fix AST post-processing phases
Fix for different AST post-processing phases, which didn't take into
consideration the possibility of having an `IfNode` with only between
`then` and `else` branches.
2019-01-25 13:45:03 +01:00
Andrea Gussoni c70b6f1097 Implemented de-optimization on RegionCFGTree
Now, during the simplification of short-circuits the so called
`de-optimization` is also applied to the corresponding `RegionCFGTree`.

This allows us to avoid loss of information during the iterative
refinement phase, which basically divides for ever the existencies of
two nodes that have been cloned starting from a single original one.
2019-01-25 13:45:03 +01:00
Andrea Gussoni 05d736cbb1 AST serialization is now performed on file
We now perform the AST serialization directly on file, without using
stderr. In this way we can follow the evolution of simplifications and
changes to the AST tree.
2019-01-25 13:35:20 +01:00
Andrea Gussoni 7de353785e Implemented conditional node list for IfNode
After short-circuit simplification, we can have that a conditional node
corresponds to more than one `BasicBlockNode`.

This change reflects this fact, and takes care of merging blocks during
short-circuit simplification, and of representing this change in the
serialization.
2019-01-25 13:32:29 +01:00
Andrea Gussoni d591ae13e6 Improved serialization of graphs during inflate
Improved the `dumpOnDotFile` function to take as a parameter also a
sub-folder name.

Modified the `inflate` function to dump on file the graphs after each
modification.
2019-01-25 13:32:28 +01:00
Andrea Gussoni 07181ee5cf Fix continue node connection
Fixed an iterator invalidation during the connection of the `continue`
node.
2019-01-25 13:19:41 +01:00
Andrea Gussoni fb95e225e2 Implemented trivial short-circuit simplification
Implemented the simplification of trivial short-circuit IFs (i.e.,
nested `IfNode` with empty `else` branches).
2019-01-25 13:19:00 +01:00
Andrea Gussoni 4711f65e8b Improved debug info logging 2019-01-25 13:18:26 +01:00
Andrea Gussoni d62bf3951b Flip IFNode nodes with empty then branches 2019-01-25 13:17:40 +01:00
Andrea Gussoni 1ee4eaac9e Remove useless Main.cpp for RemovePCStoresPass 2019-01-25 13:15:02 +01:00
Andrea Gussoni f5dc27262c Improved isEqual operator with deep comparison
Now the `isEqual` operator does what we call a `deep` comparison,
meaning for every type of `ASTNode` it recursively check if the
structures of the AST tree originating in that node can be considered
equivalent (e.g., two sequence nodes are considered equal if every node
they contain is in turn equal).

This operator gives more space to the short-circuit simplification,
which relies heavily on the `isEqual` operator.
2019-01-25 13:15:02 +01:00
Pietro Fezzardi f5fcc4aa24 Completely redesign ownership model for RegionCFG 2019-01-25 13:13:35 +01:00
Pietro Fezzardi 744900d4d5 RestructureCFGPass: add skeleton for flattening 2019-01-22 19:16:48 +01:00
Pietro Fezzardi 40d677e560 RestructureCFG: early check for isolated functions 2019-01-22 19:16:48 +01:00
Pietro Fezzardi ea965ac743 EnforceCFGCombingPass: improve assertions 2019-01-22 19:16:48 +01:00
Andrea Gussoni 14fe9cab07 Preserve collapsed CFG when cloning node 2019-01-22 19:16:48 +01:00
Pietro Fezzardi bbfbb54eed EnforceCFGCombingPass: fix iterators and asserts 2019-01-22 19:16:48 +01:00
Pietro Fezzardi c967f986cd Fix BasicBlockViewMap lattice methods
Fix the `combine` and `lowerThanOrEqual` methods to match the semantics
of the lattice.
2019-01-22 19:16:48 +01:00
Pietro Fezzardi 00169c5833 Switch to new cmake package for revamb libraries
This change makes `CMakeLists.txt` files less verbose and allows proper
registration of debug `Logger`s from revamb `Support` library,
enabling their use without manually enabling them.
This also means that they can be properly enabled with command line
arguments and that we can remove some hacks in the code that was put in
place to work around this limitation.
2019-01-22 19:16:48 +01:00
Pietro Fezzardi d5f2bc7750 First Prototype of EnforceCFGCombingPass 2019-01-22 19:16:48 +01:00
Pietro Fezzardi 05a5660de2 BasicBlockViewAnalysis: add getter for results 2019-01-22 19:16:48 +01:00
Andrea Gussoni 9876e514d5 Improved isEqual operator with deep comparison
Now the `isEqual` operator does what we call a `deep` comparison,
meaning for every type of `ASTNode` it recursively check if the
structures of the AST tree originating in that node can be considered
equivalent (e.g., two sequence nodes are considered equal if every node
they contain is in turn equal).

This operator gives more space to the short-circuit simplification,
which relies heavily on the `isEqual` operator.
2019-01-22 19:16:48 +01:00
Andrea Gussoni 05a5d80151 Short-circuit simplification concept
First concept of short-circuit simplification.
The `isEqual` operator between ASTNodes is very limited (it does only
check if two nodes originate from the same `BasicBlock` in the original
IR.
2019-01-22 19:16:48 +01:00
Andrea Gussoni 8f89ea0f7d Outline not reachable nodes removal
Outlined the removal of nodes not reachable from the entry node in an
external function. This is useful to reuse the function not only for the
main graph, but also for the collapsed regions.
In this way we can remove not reachable nodes in the inner regions, such
as dandling `break` and `continue` nodes (found in an endless loop).
2019-01-21 18:28:59 +01:00