Commit Graph

51 Commits

Author SHA1 Message Date
Pietro Fezzardi 86734aef6b Fix revng coding conventions 2021-11-09 15:28:04 +01:00
Pietro Fezzardi 1e5750f26d Setup infrastructure for FileCheck tests 2021-10-21 17:08:46 +02:00
Pietro Fezzardi d042299ff1 Update comment in tests cmake file 2021-10-21 17:08:46 +02:00
Pietro Fezzardi 784f38a2a4 New naming convention from revng/dynamic-functions 2021-10-12 09:57:30 +02:00
Alvise de Faveri 43ae7a91cb DLA: Add DeduplicateUnionFields Step
Add a step that recognizes if two subtrees of a union node are
topologically equivalent and merges them. This corresponds to removing
duplicate fields in unions.

This deduplication was prevously done while emitting layouts.

A check is inserted into DLAMakeLayouts to assert that, after
constructing unions, no union has only one child, which could be the
case if we didn't deduplicate union fields in the graph.
2021-10-06 16:37:37 +02:00
Alvise de Faveri 7e72fc4be1 DLA: Add RemoveConflictingEdges step
Add a DLA step that removes all instance-at-offset-0 edges between nodes
that already have an inheritance edge between them.
2021-10-05 18:16:21 +02:00
Pietro Fezzardi fda2b0042f Drop Beautify dependency on MarkForSerialization 2021-09-22 19:01:44 +02:00
Pietro Fezzardi ce0083a7ff Extract MarkForSerialization in separate library 2021-09-22 15:03:12 +02:00
Pietro Fezzardi a2a29c7942 Fix missing linking with revng and LLVM libraries 2021-08-31 12:30:04 +02:00
Pietro Fezzardi f057441ce8 Fix linking 2021-08-20 11:21:04 +02:00
Alvise de Faveri d819437aa3 Add UT for all DLA steps 2021-07-23 18:11:30 +02:00
Pietro Fezzardi 10d1eab7f4 Decompiler: update to new model APIs 2021-07-21 11:09:28 +02:00
Alvise de Faveri 4eb50d0bb5 Add Unit Test for DLACollapseSingleChild 2021-06-30 17:50:12 +02:00
Alvise de Faveri bfdef657f2 Move DLA files to separate folder 2021-06-18 18:24:04 +02:00
Pietro Fezzardi af8a47fe93 test_reachabilitypass: fix memory leak 2021-05-18 11:46:01 +02:00
Alvise de Faveri 6fbf5724d1 Add Value Manipulation Analysis 2021-05-14 11:18:14 +02:00
Alessandro Di Federico 9fb066a87f Use TupleTree<model::Binary> 2021-05-06 10:37:56 +02:00
Pietro Fezzardi 36a525314a Detect isolated functions using FunctionTags 2021-04-27 21:19:06 +02:00
Alessandro Di Federico 690e5fd9bd Update LoadModelPass usage 2021-03-16 12:01:15 +01:00
Pietro Fezzardi a23a89fd61 DecompileFunction: improve test efficiency
Now we don't iterate over all the Functions in a Module, but we use the
Model to detect the first isolated function.
2021-02-23 11:09:36 +01:00
Pietro Fezzardi e95c21db25 Use Model to detect isolated functions 2021-02-23 10:39:05 +01:00
Pietro Fezzardi 3116b67948 Ensure to find an isolated function in tests 2021-02-11 16:26:20 +01:00
Pietro Fezzardi 9d1d6afe6e MarkForSerialization: extract into its own Pass 2021-02-02 11:23:53 +01:00
Pietro Fezzardi a9e171e4ed UnitTest: update cmake file to match revng 2021-02-02 11:23:53 +01:00
Pietro Fezzardi 52b617a6dd [DLA] Add dla::Step and dla::StepManager
These are the elementary steps of the DataLayoutAnalysis (that is still
to be defined), along with a manager to handle them, their dependencies,
their executions and their invalidations.

In principle, this design could have been implemented inheriting from
`llvm::Pass` and `llvm::legacy::PassManager` (or `llvm::PassInfoMixin`
and `llvm::PMDataManager` for the new step manager).
However, LLVM's passes and managers provide far more complex features
than we need for now, so I decided to keep it simple and roll our own
for now.
We could potentially switch to LLVM stuff later if we need their power.

Some examples of features we don't need for now are:
- capability to pass results from a pass to another that depends on it
- capability to dynamically compute pass dependencies
- capability to dynamically invalidate passes
If some of these become necessary in future, it's a sign that it might
be time to switch to an LLVM-based design

The design is structured as follows.

1) Adding `Step`s to the `StepManager`

The `StepManager` owns the `Step`s, that can be added via the `addStep`
method.
Whenever a new `Step` is added, four properties are checked:
- that all its dependencies have already been added before it;
- that non of its dependencies have been invalidated by the insertion of
  another step that invalidate them.
- that it does not depend on itself
- that it does not invalidate itself
If any of these conditions fail, the `Step` is not added successfully.

Whenever a new `Step` A is added and it invalidates any `Step` B, the
last instance of B added to the `StepManager` before A (if present) is
marked as invalidated.
If one wants to add a new `Step` C that depends on B, it will be
necessary to explicitly add a new instance of A (say A*) before adding
C.
Otherwise, there will be no guarantee that an instance of A executes
before C without being invalidated.

These conditions on invalidations are restrictive but the allow to
specify the dependencies and invalidations that we need for now.
If it turns out we need more complex dependencies and invalidations we
should explore implementing the LLVM-based design.

2) Executing the added `Step`s

After adding the `Step`s to the `StepManger`, they can be executed all
together with the `dla::StepManger::run()` method.

This method runs all the steps in the order they were added by the user
with calls to `addStep`.
The fact that `addStep` strictly ensures that dependencies and
invalidations are respected, guarantees that the execution always works
in the order of `Step`s specified by the user.
It also means that there is no need to check and propagate invalidations
across dependencies between the execution of the `Step`s, because there
is the guarantee that if a `Step` A invalidates `Step` B, another
instance of B will be executed later if some `Step` C needs it, or if
the user has added it explicitly.

When the `dla::StepManager::run()` method returns, all the `Step`s that
were successfully added to the manager have finished running.

3) Implementing a `Step`

Each `Step` has a virtual `runOnTypeSystem` method, that executes the
`Step` and returns true if some change was made, false otherwise.
`TypeSystem` for now is just a forward declaration and all the
implementations of `runOnTypeSystem` simply return true.
2021-02-02 11:23:53 +01:00
Alessandro Di Federico 81da6947d2 Run unit tests from bin/ directory 2021-02-02 09:23:33 +01:00
Alessandro Di Federico 3277d17435 s/decompileFunctionPipeline/decompile_function/ 2021-02-02 09:22:33 +01:00
Alessandro Di Federico 06e8320849 Unit test configuration: remove debugging output 2021-02-01 18:45:39 +01:00
Alessandro Di Federico e31fc91e04 s/decompileFunction.cpp/DecompileFunction.cpp/ 2021-02-01 18:45:33 +01:00
Pietro Fezzardi 2162aa683d Add basic tests for public API decompileFunction 2020-12-01 18:12:00 +01:00
Pietro Fezzardi 429633b627 Use #pragma once for header include guards 2020-11-12 18:00:45 +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 eb1ddab86c RegionCFG: dumpDotOnFile to dumpCFGOnFile 2020-11-06 15:08:00 +01:00
Pietro Fezzardi 217a18edb1 Update copyright notice 2020-11-06 15:07:45 +01:00
Pietro Fezzardi 466d058c5e UnitTests: fix CMake linking for Boost Unit Test 2020-09-09 11:16:50 +02:00
Andrea Gussoni 476a004c30 Use revng_add_private_executable to build tests 2020-09-09 11:16:50 +02:00
Andrea Gussoni 50f59b0eb9 Move ReachabilityPass to tests folder
Move the `ReachabilityPass` library to the `tests` folder, the only
place where it is used, and change it from static library to dynamic
library.
2020-09-09 11:16:50 +02:00
Pietro Fezzardi 2feaa47737 Fix use of boost unit_test_framework
This commit does three things.
- Removes explicit dependency from boost version 1.63. This is no longer
  necessary since orchestra has moved to compiling boost test directly,
  and ships version 1.71 (as of now).
- Switches UnitTests.cmake to using modern cmake package for
  Boost::unit_test_framework
- Adds an header copied from revng, to define
    boost::throw_exception(std::exception const &E)
  This is necessary to compile with -fno-exception and boost
  unit_test_framework.
2020-01-15 18:23:41 +01:00
Andrea Gussoni b5c00f7dfc Fix inclusion and library linking 2019-11-20 15:16:17 +01:00
Pietro Fezzardi 429233f054 Fix more warnings left from -Weverything 2019-11-20 15:16:17 +01:00
Andrea Gussoni 46265f6eaf Fix -Wextra-semi 2019-11-20 15:16:17 +01:00
Andrea Gussoni 20a419cff2 WeightTraits to expose a generic object weight
The method which computes the weight for a `BasicBlockNode` now relies
on a new `WeightTraits` which is specialized for `BasicBlock` and for
`DotNode`.

In this way, we can change the implementation of the `getWeight` method
without having to modify the implementation inside the `revng` project.
2019-05-24 15:36:45 +02:00
Pietro Fezzardi b058c326c6 Enforce coding style 2019-05-08 17:40:53 +02:00
Andrea Gussoni e8ad1e542b Fixes and improvements suggested by MR 2019-05-03 15:46:07 +02:00
Andrea Gussoni 3e18b199bb Use DotFileObject library provided in revng
Now use the `DotFileObject provided by `revng` instead of using our own.
2019-04-23 16:35:37 +02:00
Andrea Gussoni abb72c3b23 Coding style and improvements in MR 2019-04-16 17:37:57 +02:00
Andrea Gussoni 95ddb2b36b BasicBlockNode and RegionCFG now template
`BasicBlockNode` and `RegionCFG` classes are now template classes. This
means that the `BasicBlockNode` class can be used as a generic wrapper
for any type of object in the original graph (it is usually used to wrap
a `llvm::BasicBlock *` for decompilation purposes, but in tests it can
be used to wrap a `DotNode` object) that implementes `GraphTraits`.
2019-04-15 17:30:37 +02:00
Andrea Gussoni 7633274a7e Add tests for combing
Added tests for the combing pass.
2019-04-15 10:11:26 +02:00
Andrea Gussoni 84105a81ee Add test for the ReachabilityPass 2019-04-15 10:11:26 +02:00