Commit Graph

47 Commits

Author SHA1 Message Date
Pietro Fezzardi 188d8fbdbb Make DecompilationPass an llvm::FunctionPass 2019-02-11 15:10:27 +01:00
Andrea Gussoni f790e308e1 Add ID for AST nodes
Added a unique ID to AST nodes, which is useful for serialization
purposes after flattening.
2019-02-11 14:15:07 +01:00
Pietro Fezzardi c5df55dedc Expose DecompilationPass.h header for public use 2019-02-11 14:01:40 +01:00
Pietro Fezzardi f4d5fec5bc First fully functional EnforceCFGComingPass 2019-02-11 12:18:44 +01:00
Pietro Fezzardi 463c40a9cf Add ASTNode children BreakNode and ContinueNode 2019-02-11 12:18:44 +01:00
Pietro Fezzardi 2b1843d898 Fix AST in EnforceCFGCombingPass 2019-02-11 12:18:44 +01:00
Andrea Gussoni 02e1b94daa Added RemoveSwitchPass
Added a new `FunctionPass` which converts `switch` instructions in a
nested chain of `if` checks.
2019-02-11 12:18:44 +01:00
Andrea Gussoni 929c0c4cdf Flattening for AST
Implemented the flattening also for the AST trees, taking also care of
adjusting the pointers to the new BBNode in the `root` `RegionCFG`.
2019-02-11 12:18:44 +01:00
Andrea Gussoni dbffa54124 Handle check BBNode in inflate
Considering the `check` BBNode during the `inflate` procedure, and
fixing the functions handling edges and nodes successors accordingly.
2019-02-11 12:18:44 +01:00
Alessandro Di Federico d00bf31bca Reorganize the build system 2019-02-10 16:20:24 +01:00
Alain Carlucci b2629efd05 Avoid useless computations when decompiling a single function 2019-02-08 11:44:17 +01:00
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
Pietro Fezzardi de19c3fd26 Fix BasicBlockNode::isBasicBlock() 2019-02-06 19:24:44 +01:00
Andrea Gussoni 2e9ff8449f Improved debugging messages 2019-02-05 10:17:47 +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 414aba5f66 Dot serialize function now const 2019-02-05 09:54:14 +01:00
Andrea Gussoni 54880d3a38 Fix dispatcher edge creation
Add the correct predecessor when setting the `true` or `false` branches
of the dispatcher check nodes.
2019-02-05 09:32:09 +01:00
Pietro Fezzardi 10fcd9bbdc Fix getters for Check BasicBlockNodes 2019-02-02 01:40:19 +01:00
Pietro Fezzardi 2afd5053e6 Rework exit and entry dispatcher trees 2019-02-01 19:24:56 +01:00
Pietro Fezzardi 7399590079 BasicBlockNode: remove usesless setter methods
Removing this methods also guarantees that the NodeType of a
BasicBlockNode is never changed after construction.
2019-02-01 17:59:23 +01:00
Pietro Fezzardi 2c93512f90 Rework BasicBlockNode class 2019-02-01 15:08:53 +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
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
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
Pietro Fezzardi f5fcc4aa24 Completely redesign ownership model for RegionCFG 2019-01-25 13:13:35 +01:00
Pietro Fezzardi 6ef68f2ca2 Remove unused headers 2019-01-23 17:03:17 +01:00
Andrea Gussoni 578772ddb4 Fix isDummy for ASTNode
Now the `isDummy` method is invoked on the underlying `CFGNode` only
when we actually have a corresponding node.
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 a540a08c38 Added RemovePCStores pass
Added a new pass that simply purge all the functions in a module from
the useless basic blocks that simply do the `pc` serialization.

Without this until we have available the optimization/comb iterative
refinement, we would not be able to test the short-circuit
simplification.
2019-01-21 18:28:48 +01:00
Andrea Gussoni 659441eb85 Introduced useless dummy simplification
Added a post processing phase on the ASTTree which is in charge of
removing useless dummy nodes
2019-01-17 17:19:08 +01:00
Andrea Gussoni b08da2c045 Serializing CFGs to file 2019-01-17 17:05:10 +01:00
Pietro Fezzardi da299f3095 EnforceCFGCombingPass: inject dummy nodes in CFG 2019-01-16 12:53:08 +01:00
Pietro Fezzardi dc430e446b RegionCFGTree.h: add missing #include<set> 2019-01-15 16:57:15 +01:00
Pietro Fezzardi 5805679ead RestructureCFGPass: fix use of include directory 2019-01-15 16:57:15 +01:00
Pietro Fezzardi 4e941de03a LivenessAnalysis: fix successor_size method 2019-01-15 12:54:19 +01:00
Pietro Fezzardi 68425a71ca Use consistent naming in include guards in headers 2019-01-15 11:19:59 +01:00
Pietro Fezzardi a478de61e5 Create a separate include directory 2019-01-15 11:19:59 +01:00