Commit Graph

6113 Commits

Author SHA1 Message Date
Alessandro Di Federico dd29699aed FunctionsSummary: print the callee too 2020-11-02 09:05:12 +01:00
Alessandro Di Federico 51b29afc30 Make ABIAnalysis mandatory 2020-11-02 09:05:12 +01:00
Alessandro Di Federico f7cb681b23 Whitespace changes 2020-11-02 09:05:12 +01:00
Alessandro Di Federico ea832c5063 script/revng: print command upon failure 2020-11-02 09:05:03 +01:00
Andrea Gussoni f57a96ab95 generateAst: Fix two successors two dominated tile
Now cover a corner case where we have a tile composed by two successors,
which we entirely dominate, and a common postdominator which we don't
postdominate (basically we miss a superfluos dummy here).

In this case, include in the tile `then` and `else` bodies, but do not
include in the tile the common postdom (it will be taken care by someone
else more higher in the CFG).
2020-10-30 16:58:00 +01:00
Andrea Gussoni fac6b4d8ed Add artifacts with no dispatcher inline
Add artifacts for decompilation that do not inline the function
dispatcher during the enforceABI. Also, serialize as `.ll` all the
artifacts.
2020-10-30 14:17:57 +01:00
Andrea Gussoni 02a4970fa6 EnforceABI: outline function_dispatcher on flag
When the `--enforce-no-safety-checks` flag is passed during the
enforcing, we avoid emitting the inlined `function_dispatcher` and we
emit instead a call to an `indirect_handle` disposable call created on
the fly to respect the ABI information on the callsite.
2020-10-30 14:17:57 +01:00
Alessandro Di Federico d1ea87e536 revng-merge-dynamic: make Python 3 compatible
Wow, we no longer need Python 2.
2020-10-30 09:50:03 +01:00
Andrea Gussoni 9a17f42f8a Add tests for the no-inline modules 2020-10-30 09:36:12 +01:00
Alessandro Di Federico bf2ac34b38 FunctionSymbol blocks are tier-1 CFEPs 2020-10-30 09:10:00 +01:00
Pietro Fezzardi 2b599d0ebc RestructureCFG: fix NDuplicates 2020-10-30 01:12:03 +01:00
Pietro Fezzardi 27f850e433 GlobalDeclCreationAction: fix short literals
Before this commit, when GlobalDeclCreationAction needed to emit
literals for initialization of global variables, it did it using
custom code.
This was not working properly, an in some cases it emitted short
literals which are not allowed in C.
Hence the generated C code that was impossible to recompile without
syntax errors.

This commit fixes this problem, using the getLiteralFromConstant method
of StmtBuilder.
In order to do this, we need to make the StmtBuilder available inside
the GlobalDeclCreationAction, which is not a very clean design.
However, we are already planning to merge the GlobalDeclCreationAction
and the StmtBuilder class, so this issue will be taken care of in the
future.
2020-10-29 14:27:38 +01:00
Pietro Fezzardi b2437ddabc Drop old unused pass RemoveUnexpectedPCPass 2020-10-29 09:34:05 +01:00
Pietro Fezzardi 6cea19ef4d generateAst: update ASTDT instead of recomputing 2020-10-28 18:34:09 +01:00
Pietro Fezzardi 4dcc02c550 weaving: avoid using Sink
Thanks to inlined edges, this is now not necessary anymore.
2020-10-26 17:05:15 +01:00
Pietro Fezzardi 7c2f70cdac Drop RemoveSwitchPass
Now that we fully support switches, there's no need for this pass to
exist anymore.
2020-10-26 14:48:37 +01:00
Pietro Fezzardi 049e687e3b Remove flattening 2020-10-26 14:29:47 +01:00
Pietro Fezzardi c2e8e65baa CDecompilerBeautify: weaken simplifyLastContinue
The simplifyLastContinue beautifier was too ambitious and there were
many corner cases that it handled in the wrong way, leaving the AST in a
shape that could not be emitted, or breaking the semantics.

This commit severely weakens the simplifyLastContinue, so that it does
not break things anymore.
It is now able to match only continue statements that are in the last
position of a sequence node which is the body of a ScsNode.

This obviously is not enough but allows revng-c to pass all the
decompilation tests.
In the future we will need to extend simplifyLastContinue to match more
cases in a sane way.
2020-10-26 14:17:25 +01:00
Pietro Fezzardi 1b4c5b96f0 ASTTree: avoid printing Successors 2020-10-26 14:17:18 +01:00
Pietro Fezzardi cc3ed6c508 Remove all blacklisted function from decompilation 2020-10-26 14:17:02 +01:00
Pietro Fezzardi 88ecb5de14 CDecompilerBeautify: match short-circuits early
This commit moves the matching of short-circuited ifs before the stage
of flipping if nodes with emtpy then.
This is necessary because the if short-circuiting may produce if nodes
with empty then, which can be then flipped by the next beautify step.
2020-10-26 14:16:53 +01:00
Pietro Fezzardi f5e26febe2 Fix simplifyAtomicSequence for switches
Before this commit, we couldn't handle simplification of atomic
sequences in cases of switches that had a default.
The reason is that if you remove a case from a switch that has a
default, you are implicitly saying that the case that you remove will be
handled by the default, hence you're changing the semantics.

Now we handle this case by not removing the case, substituting it with a
SwitchBreak node instead.
2020-10-26 14:16:38 +01:00
Pietro Fezzardi acb21bba5e RegionCFG: remove wrong assertion 2020-10-26 14:16:22 +01:00
Pietro Fezzardi 7ff0d0b8d0 RestructureCFG: Mark anyPC as inlined 2020-10-26 14:15:39 +01:00
Pietro Fezzardi 4fc2ab56a0 RegionCFG::inflate(): fix assertion 2020-10-26 14:15:28 +01:00
Pietro Fezzardi 6024ce9a1b RegionCFG: fix bug ini markUnexpectedPCAsInlined()
This commit fixes a bug causing iterator invalidation in
`markUnexpectedPCAsInlined`.
Before this commit we were iterating over a graph while adding nodes,
which could cause iteration invalidation on realloc.
2020-10-26 14:13:46 +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 6dbb11f39b Drop RemoveBadPCPass
This pass is now useless in revng-c, since we have the
--isolate-no-safety-checks flag in revng.
2020-10-26 14:13:25 +01:00
Pietro Fezzardi 254b8cc12b Add tests for combing and decompilation 2020-10-26 14:13:20 +01:00
Andrea Gussoni 9ef2cc7f04 RegionCFGTree: harden combing of inlined paths
Added assertions that checks that, once, during combing, we start
analyzing a path deriving from an inlined edge, we only encounter nodes
which do not require combing (all predecessors have been visited), or
that are reachable only from inlined edges (this is usually the case for
edges bringing to the `UnexpectedPC` basic block).
2020-10-26 14:13:05 +01:00
Andrea Gussoni b25ed2fae7 RegionCFGTree: Do not process inlined edges.
Whem enqueing the successor of a conditional node, skip the inlined
edges
2020-10-26 14:12:50 +01:00
Andrea Gussoni 4962bcf11b RegionCFGTree: Clone UnexpectedPC in inlining
When we perform the tagging of the inlined edges in occurence of, we
also perform a duplication of the `UnexpectedPC` basic block.
In this way, we can avoid, walking through inlined edges during the
combing, since we now that all the nodes following an inlined edges will
be dominated by the corresponding conditional bringing to it.
2020-10-26 14:12:35 +01:00
Andrea Gussoni 0bc1326e3c RegionCFGTree: print as purple the inlined edges 2020-10-26 14:12:21 +01:00
Pietro Fezzardi 3b630b2f3d generateAst: fix tiles for switch with fallthrough 2020-10-26 14:12:06 +01:00
Pietro Fezzardi a84f69e7c9 ASTTree: add Successor edges to dot dumps 2020-10-26 14:11:49 +01:00
Andrea Gussoni 71bcaff852 generateAst: update SCS body AST in AST gen
Update the `Body` pointer inside an `ScsNode` when processing the
`copyASTNodesFrom` method, in order to update the `Body` pointer of
nested collapsed nodes.
2020-10-26 14:11:32 +01:00
Andrea Gussoni 7783794aa2 generateAst: delete old AST simplification helpers
Remove from the `RegionCFGTreeImpl.h` header the helper functions used
for the first AST simplification that are now part of the
`GenerateAst.h` header.
2020-10-26 14:11:16 +01:00
Pietro Fezzardi 55731fd100 generateAst: fix createSequence 2020-10-26 14:10:58 +01:00
Pietro Fezzardi ee5e934e86 RestructureCFG: merge debug prints 2020-10-26 14:10:44 +01:00
Pietro Fezzardi 74698f9f95 ASTNode: print nodes based on ID 2020-10-26 14:10:36 +01:00
Pietro Fezzardi a4eefdf7f8 ASTNode: drop old useless comments 2020-10-26 14:10:19 +01:00
Pietro Fezzardi 755bca083a Beautify: debug print AST before beautification 2020-10-26 14:10:10 +01:00
Pietro Fezzardi 3df53164c4 Fix weight computation for BasicBlockNodes 2020-10-26 14:09:57 +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
Pietro Fezzardi a2e9a7660d ASTNode and ASTTree: cleanup of data members
This commit removes the old unused field `Processed` from `ASTNode`, and
fixes the default construction of `ASTTree` data memebers.
2020-10-26 14:09:02 +01:00
Pietro Fezzardi a69cefde9b ASTNode: make the Clone method const
In this way we have guarantees that cloning a node does not change it.
2020-10-26 14:08:00 +01:00
Andrea Gussoni 3128c1a4b6 Factor generateAST out as function 2020-10-26 14:07:54 +01:00
Pietro Fezzardi 9d07b639f9 RegionCFGTree: fix creation of switch edge labels 2020-10-26 14:00:30 +01:00
Pietro Fezzardi b16d6dde86 RestructureCFG: prevent computing useless PDT 2020-10-26 14:00:16 +01:00