Commit Graph

6113 Commits

Author SHA1 Message Date
Pietro Fezzardi e65b313e5e Drop torture tests
These tests have become redundant, since they are now generated in
revng-qa in the same way as the regular non-torture versions.
2022-02-10 17:27:53 +01:00
Alvise de Faveri 8c14fe180c Add assets/ folder and restructure CMakeLists
1. Add an `assets/` folder that contains:
    - a file with all the flags used for recompilation
    - a header file with portable float definitions
2. Restructure `CMakeLists.txt` so that all artifacts are generated
   in separate folders, and all recompilation tests use the same
   flags
2022-02-10 17:27:21 +01:00
Alvise de Faveri 1a39994759 Add HelpersToHeader pass 2022-02-10 17:12:56 +01:00
Alvise de Faveri 73c743597b Pull out DepGraph and naming from ModelToHeader
Separate `ModelToHeader.cpp` into 3 different files:

1. DependencyGraph, used to calculate the precedence between
   type declarations
2. ModelTypeNames, that holds all the naming logic, whose
   primitives are accessible from other modules through a
   public header
3. ModelToHeader, that now contains only the logic to print
   out declarations and definitions

Also add a compilation test for the headers generated by this pass.
2022-02-10 17:12:56 +01:00
Alvise de Faveri 9a4da22e8c Move ModelToHeaderMain to a new tools/ folder 2022-02-10 17:12:56 +01:00
Alvise de Faveri 70724920bb Move ModelToHeader to HeadersGeneration 2022-02-10 17:12:56 +01:00
Alvise de Faveri cb3ee3c8ac Remove body of non-isolated functions from the IR
Before decompiling, we want to get rid of all unused stuff from the
IR. To do this, we have to:

1. Modify `FilterForDecompilation` so that it removes the body of
   all non-isolated functions
2. Add `strip-dead-prototypes` to the preparation pipeline, so that
   also the declarations of non-isolated functions that are not
   directly called inside an isolated function are stripped from
   the LLVM module. In this way, we can safely execute `HelpersToHeader`
2022-02-10 17:12:45 +01:00
Pietro Fezzardi 15d0d207f4 Merge feature/fix-ghast-upgrading into develop 2022-02-09 18:53:52 +01:00
Alvise de Faveri 691e55097c Add the condition's BB to ASTNode's debug info 2022-02-09 18:53:13 +01:00
Pietro Fezzardi 0639cc8042 Enforce check-revng-conventions 2022-02-09 18:53:12 +01:00
Alvise de Faveri 19ae8757b0 Add -single-decompilation to BeautifyGHAST 2022-02-09 18:53:12 +01:00
Alvise de Faveri 6411302bfd Fix handling of dispatcher fallthrough in Tiling
**Symptoms**: a correct visit of the GHAST resulted in an incorrect
visit order of the CFG (some instructions were visited before their
operands)

**Causes**: When creating the tile of a dispatcher with an inline
successor and a fallthrough, the predecessors of the dispatcher
were correctly connected to the new tile, but the fallthrough
was not, leading to a split in the GHAST between nodes that should
have been connected

**Solution**: Setting `PostDomBB = Fallthrough` if there is a
fallthrough just before calling `createTile()` corrects
this behavior, connecting the tile to its fallthrough node
2022-02-09 18:53:12 +01:00
Alvise de Faveri 0c3a8904c6 Prefer while over do-while in BeautifyGHAST
Run `matchWhile()` before `matchDoWhile()` in BeautifyGHAST.cpp.
Since `while` nodes cannot be transformed into `doWhile`s nor
vice-versa, this has the effect of giving priority to `while` loops
over `do-while`s in cases where you could emit both.
2022-02-09 18:53:12 +01:00
Alvise de Faveri 7b144b2556 Don't upgrade while and doWhile in the GHAST
We should never be changing the nature of a `while` node into a
`doWhile` and vice-versa: we only upgrade standard nodes in
either a `while` or a `doWhile`.
2022-02-09 18:53:12 +01:00
Alessandro Di Federico 3baf3323ed Merge branch 'feature/pipeline-improvements' 2022-02-08 18:35:03 +01:00
Alessandro Di Federico 8f73438a8b Ban tabs and spaces at end of lines 2022-02-08 17:54:07 +01:00
Alessandro Di Federico e80d159944 revng-pipline: simplify Kinds.h 2022-02-08 17:44:33 +01:00
Alessandro Di Federico 9788c49529 Fix pipeline test suite names 2022-02-08 17:44:26 +01:00
Alessandro Di Federico fa8061b805 Drop dead Kinds 2022-02-08 17:44:19 +01:00
Alessandro Di Federico 80d92e2fed Drop FunctionCounter-related files 2022-02-08 17:44:08 +01:00
Alessandro Di Federico c8026ac401 Minor changes 2022-02-08 17:40:09 +01:00
Pietro Fezzardi 29c50fa909 Model: reserve names defined in stdint.h
This commit adds a bunch of type names and macro names to the set of
reserved keywords that cannot be used for names in the revng Model.
These are the names defined in the stdint.h standard C header, that is
included automatically by the decompiler in decompiled code.

We need to reserve these names otherwise it would be possible to add
things to the revng Model with names that clash with the names defined
in stdint.h, which would in turn break recompilation of decompiled code
because of conflicting definitions.
2022-02-08 15:54:02 +01:00
Alessandro Di Federico d9c893547f Merge branch 'feature/revng-pipes' 2022-02-08 08:45:17 +01:00
Massimo Fioravanti d696197597 scripts/revng: adopt revng-pipeline
The revng-translate tool is now a driver for revng-pipeline to perform
the translation.

This commit also drops computing the `-load` "roots". It shouldn't
really be necessary.
2022-02-08 00:05:03 +01:00
Massimo Fioravanti 67f9cbdf4c Introduce the revng-pipeline CLI tool 2022-02-08 00:05:03 +01:00
Massimo Fioravanti fe9686be03 revng-pipeline: introduce C API 2022-02-08 00:05:03 +01:00
Massimo Fioravanti a8a8da3bae Introduce revng pipes
This commit imports all the revng pipes (and other support utilities) to
be used with `revng-pipeline`. In particular, the pipes necessary for
binary translations have been introduced.
2022-02-08 00:05:03 +01:00
Massimo Fioravanti 6f0d0c4f9d CodeGenerator: accept an external model 2022-02-07 22:24:39 +01:00
Massimo Fioravanti 98ecd38162 Drop PureLLVMPipe
Now LLVM passes can be used directly in an LLVMPipe without specifying a
contract for it.
2022-02-07 22:24:39 +01:00
Alessandro Di Federico 3b7d7c5f7e Don't use llvm::outs 2022-02-07 22:24:39 +01:00
Alessandro Di Federico fec5f3537b s/Granularity/Rank/ 2022-02-07 22:24:39 +01:00
Alessandro Di Federico e2cd7cbcdf Pipeline: simplify LLVMContainer 2022-02-07 20:11:37 +01:00
Massimo Fioravanti 396095706f Minor changes to revngPipeline 2022-02-07 20:11:15 +01:00
Alessandro Di Federico 91fd04079a AllPasses.h: include Verify.h 2022-02-07 20:11:15 +01:00
Alessandro Di Federico 0f084ed620 Minor changes 2022-02-07 16:55:46 +01:00
Alessandro Di Federico 21f16ce95d Drop *.orig files
They have been accidentally committed.
2022-02-07 16:55:46 +01:00
Antonio Frighetto 212816753a Introduce TwosComplementArithmeticNormalizationPass 2022-02-03 20:12:23 +01:00
Pietro Fezzardi b0f3683a99 Merge branch feature/model-tooling into develop 2022-02-01 08:49:25 +01:00
Alessandro Di Federico 2b5610bc93 Merge branch 'feature/model-tooling' 2022-01-31 19:24:29 +01:00
Alessandro Di Federico d15f73b20b Upgrade testing to model tooling 2022-01-31 18:20:35 +01:00
Alessandro Di Federico 1c2527f6fa mv tools/{revng-,}lift 2022-01-31 16:37:22 +01:00
Alessandro Di Federico 60b2dbab72 revng: support model subcommands 2022-01-31 16:28:26 +01:00
Alessandro Di Federico 78be0e9268 Explode TupleTree.h 2022-01-31 16:28:26 +01:00
Alessandro Di Federico 280848484e SerializeModelPass: verify model 2022-01-31 16:28:17 +01:00
Alessandro Di Federico c0f8110e4e s/revng-compare-yaml/revng-model-compare/ 2022-01-31 16:28:17 +01:00
Alessandro Di Federico 0d7decccb3 s/revng-dump-model/revng-model-to-json/ 2022-01-31 16:28:17 +01:00
Alessandro Di Federico 7fba073058 Enable testing model diff 2022-01-31 16:28:17 +01:00
Alessandro Di Federico a353e00ac1 Introduce model passes 2022-01-31 16:28:14 +01:00
Alessandro Di Federico 3980ee3fad Introduce model tools 2022-01-31 16:28:14 +01:00
Alessandro Di Federico 29cf330fc8 TupleTreeDiff: use streams 2022-01-31 14:13:25 +01:00