Commit Graph

149 Commits

Author SHA1 Message Date
Pietro Fezzardi 2fbb8df965 Add MakeModeGEPPass 2022-01-14 14:28:33 +01:00
Pietro Fezzardi ce0083a7ff Extract MarkForSerialization in separate library 2021-09-22 15:03:12 +02:00
Andrea Gussoni 55c620ab31 RegionCFGTree: refactor connectContinueNode
THe creation and connection of continue nodes is now down in the
population of the collapsed region, avoiding external methods.
2021-08-19 18:51:24 +02:00
Andrea Gussoni 7323cecec1 RestructureCFG: improve break node creation
Break node creation is now improved to avoid edge index swapping that
can cause inversion of conditions later on in the decompilation
pipeline.

To do this, the creation and connection of the break nodes is done
during the bulk insertion of nodes in a collapsed region.
2021-08-19 18:51:14 +02:00
Pietro Fezzardi 80f1e2fd6d Explictly convert llvm::StringRef to std::string
Implicit conversion is not available anymore in llvm-12.
2021-05-27 17:14:25 +02:00
Pietro Fezzardi 36a525314a Detect isolated functions using FunctionTags 2021-04-27 21:19:06 +02:00
Pietro Fezzardi fc7a8cac1a RestructureCFG: optimize updating Backedges 2021-04-15 11:16:57 +02:00
Pietro Fezzardi 56ed3f3904 RestructureCFG: fix typo in comments 2021-04-15 09:47:53 +02:00
Alessandro Di Federico 690e5fd9bd Update LoadModelPass usage 2021-03-16 12:01:15 +01:00
Pietro Fezzardi e95c21db25 Use Model to detect isolated functions 2021-02-23 10:39:05 +01:00
Pietro Fezzardi cc65e946cb RestructureCFG: fix exit dispatcher to backedges 2021-02-18 11:59:05 +01:00
Pietro Fezzardi b23cf45fd9 RestructureCFG: refactor entry and exit dispatcher 2021-02-18 11:59:05 +01:00
Pietro Fezzardi 444663ed94 RestructureCFG: refactor logging of MetaRegions 2021-02-18 11:59:04 +01:00
Pietro Fezzardi 1616b9d0ab Fix checkMetaRegionConsistency
This function was intended to check that backedges are entirely enclosed
inside metaregions, i.e. that we cannot have a backedge jumping from a
metaregion to an outer or an inner one.

Before this commit, the assertion was tautological.
2021-02-18 11:59:04 +01:00
Pietro Fezzardi 9a4bb33bfe RegionCFG: refactor simplifySCSAbnormalRetreating 2021-02-18 11:59:03 +01:00
Pietro Fezzardi 2998494d18 RegionCFG: use meaningful names for dummy nodes
This helps debugging.
2021-02-18 11:59:03 +01:00
Pietro Fezzardi 9d1d6afe6e MarkForSerialization: extract into its own Pass 2021-02-02 11:23:53 +01:00
Pietro Fezzardi 93d9cbb67b Enforce new include conventions 2020-11-12 18:00:45 +01:00
Alessandro Di Federico 37fde04594 Move licensing details to LICENSE.md 2020-11-09 10:03:33 +01:00
Andrea Gussoni f3f11533b8 ASTTree: Reorganize AST dot printing
Reorganize the AST dot printing in order to use LLVM facilities for
files handling. In addition, clean up the code, and add a function
(useful in debug) in order to dump the dot of and AST from GDB (accepts
a `char *` instead of a `std::string`.
2020-11-06 15:08:00 +01:00
Andrea Gussoni df0985f1fc RegionCFG: dumpOnFile to dumpASTOnFile 2020-11-06 15:08:00 +01:00
Andrea Gussoni eb1ddab86c RegionCFG: dumpDotOnFile to dumpCFGOnFile 2020-11-06 15:08:00 +01:00
Andrea Gussoni 7362e7beeb RegionCFG: Reorganize graph debug
Now, when the `debug-log=restructure` flag is active, debug graphs are
organized in a more rational way.

First of all, all the graphs are now put in a single directory, and are
divided first by function name and then by type.

Also, as in the case of the tiling debug graphs, their name is more
consistent with the rest of the codebase.
2020-11-06 15:08:00 +01:00
Pietro Fezzardi 217a18edb1 Update copyright notice 2020-11-06 15:07:45 +01:00
Pietro Fezzardi 2b599d0ebc RestructureCFG: fix NDuplicates 2020-10-30 01:12:03 +01:00
Pietro Fezzardi 049e687e3b Remove flattening 2020-10-26 14:29:47 +01:00
Pietro Fezzardi cc3ed6c508 Remove all blacklisted function from decompilation 2020-10-26 14:17:02 +01:00
Pietro Fezzardi 38935f3a40 Remove functions from decompilation blacklist
We're now able to handle them, so there's no need to skip them anymore.
2020-10-26 14:13:31 +01:00
Pietro Fezzardi ee5e934e86 RestructureCFG: merge debug prints 2020-10-26 14:10:44 +01:00
Pietro Fezzardi c7b05cbb2c RestructureCFG: fix CollapsedMap 2020-10-26 14:09:41 +01:00
Pietro Fezzardi 432957c649 RestructureCFG: cleanump AST and NDuplicates 2020-10-26 14:09:26 +01:00
Andrea Gussoni 3128c1a4b6 Factor generateAST out as function 2020-10-26 14:07:54 +01:00
Pietro Fezzardi b16d6dde86 RestructureCFG: prevent computing useless PDT 2020-10-26 14:00:16 +01:00
Andrea Gussoni ced4f1a6a8 [TILING] Fix NDuplicates counting
Count the number of duplication (needed later in the `Mark` pass) right
before the AST generation phase, where the `RegionCFG` will be destroyed
by the tiling matching.
2020-10-26 13:57:17 +01:00
Andrea Gussoni b52206cb68 [TILING] Implement tiles creation
Now we implement correct tiles creation, and we handle correctly handle
different situations were inlining is present
2020-10-26 13:56:57 +01:00
Andrea Gussoni bee02ee5d1 [EDGEINLINE] Change findReachableNodes interface
Change the interface of the `findReachableNodes` helper function, so
that now accepts arguments passed by pointer instead of by reference.
Also, the helper function now does not accept a `nullptr` `Source`
parameter.
2020-10-26 12:17:20 +01:00
Andrea Gussoni 24712518b3 [EDGEINFO] Implement EdgeInfo for inlining info
The `Successors` and `Predecessors` field on the `BasicBlockNode` are
now promoted from being a `std::pair` composed by the pointer to the
successor and the set representing the cases, to a pair between the
pointer to the successor and a new struct called `EdgeInfo`.

This struct is used to contain both the information about the cases, the
information representing whether and edge is inlined or not, and
possibly more information in the future.
2020-10-26 12:16:55 +01:00
Pietro Fezzardi 66243838c8 Allow decompiling functions called bb.main
They were disabled before this commit, to work around some limitation of
an old benchmark suite.
2020-09-11 18:29:37 +02:00
Pietro Fezzardi fc98fc69f5 Fix detection of isolated functions using metadata 2020-07-22 17:27:02 +02:00
Pietro Fezzardi 1a9ae59e4a RestructureCFG: major refactoring of switches
Now edges have sets representing labels.
There's no distinction between Dispatchers and Regular switches at the
GHAST level anymore.
2020-07-20 19:02:19 +02:00
Pietro Fezzardi 7f6ce70c82 Refactor RegionCFG::inflate() method 2020-07-16 10:48:12 +02:00
Pietro Fezzardi a078be2478 RestructureCFG: avoid dedicated untangling of root
This commit removes a call to untangle() that was performed before the
whole combing algorithm on the root RegionCFG.

The call was redundant before introducing the weaving, and became
plainly wrong after adding the weaving, because it ended up trying to
untangle the root RegionCFG before weaving (which is supposed to run
first).

Removing the dedicated call fixes the bug, because weaving is performed
first as part of the call to generateAst().
2020-07-09 18:17:20 +02:00
Pietro Fezzardi f7e8599c5e Enforce check-conventions.sh
All commits should pass check-conventions.sh from now on.
2020-06-15 15:40:02 +02:00
Andrea Gussoni 933dd20e44 Restructure dispatcher creation
Now that `Check` nodes are nomore a thing, restructure the dispatcher
creation code in order to be more clean.
2020-06-15 15:06:23 +02:00
Andrea Gussoni e611e47a20 Remove Check nodes
Check nodes are nomore a thing. Remove all methods and accessor related
to them.
2020-06-15 15:06:23 +02:00
Andrea Gussoni 1c842fbd28 Rework Dispatcher kind attribute and constructor
Reorganize attribute `Kind` incorporating it into the `Type` attribute,
by lowering its memory footprint.
Modified the constructors, some accessors and helpers accordingly.
2020-06-15 15:06:23 +02:00
Andrea Gussoni be39c9a5e3 Actualize assert to new node types 2020-06-15 15:06:23 +02:00
Andrea Gussoni a8b25fdd52 Differentiate entry and exit dispatcher
Differentiate the entry and exit dispatchers introduced during the
restructuring with a different `Kind` enum inside the node.
2020-06-15 15:06:23 +02:00
Andrea Gussoni 1f94d0fdd7 Remove assertions on SwitchNode
Disable assertions which are no more valid since `CheckNodes` are no
more present in the `RegionCFG`.
2020-06-15 15:06:22 +02:00
Andrea Gussoni 0fb4fc6503 Enable the untangle procedure again 2020-06-15 15:06:22 +02:00