Commit Graph

6113 Commits

Author SHA1 Message Date
Alessandro Di Federico 7b2744f0ab Register ModuleAnalysisManager in new PassManager 2019-11-21 23:35:42 +01:00
Alessandro Di Federico cd41d055f4 DIBuilder::createFunction now takes SPFlags 2019-11-21 23:34:25 +01:00
Alessandro Di Federico ae8da14d46 Adopt FunctionCallee
`getOrInsertFunction` in LLVM 9 now returns `FunctionCallee`.
2019-11-21 20:52:55 +01:00
Alessandro Di Federico 0eb1bb583f Remove TerminatorInst
LLVM 9 drops the `TerminatorInst` class. This commit replaces it with
`Instruction` where possible and asserts
`Instruction::isTerminator()`. It also switches from
`TerminatorInst::successors` to `successors(TerminatorInst *)`.
2019-11-21 20:50:55 +01:00
Alessandro Di Federico 3818a4fcc6 Drop ConstantRange::ConstantRange
LLVM 9 prevents us from using the `ConstantRange` constructor. This
commit switches to use factory methods.
2019-11-21 20:50:03 +01:00
Pietro Fezzardi 650d255e74 add revng_unreachable in unexpected ASTNode kind 2019-11-20 15:16:17 +01:00
Andrea Gussoni b5c00f7dfc Fix inclusion and library linking 2019-11-20 15:16:17 +01:00
Andrea Gussoni de70a09c7a Fix gcc warnings related to default switch case 2019-11-20 15:16:17 +01:00
Andrea Gussoni 1e22c1cebb Fix ReachabilityPass
Re-add line lost during the rebase.
2019-11-20 15:16:17 +01:00
Andrea Gussoni 46e8447032 Fix indentation 2019-11-20 15:16:17 +01:00
Pietro Fezzardi c6c6f19535 Enforce check-conventions 2019-11-20 15:16:17 +01:00
Pietro Fezzardi 94e6a47f33 Import check-conventions.sh script from revng 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 3c3ebc56a1 Fix preprocessing passes needed by DecompilerPass 2019-11-20 15:16:17 +01:00
Andrea Gussoni 8b8301b33d Fix for PHI assignement pass 2019-11-20 15:16:17 +01:00
Andrea Gussoni 3a830f532d Fix debug dots directory creation 2019-11-20 15:16:17 +01:00
Andrea Gussoni dc77551f83 HACK: fix emission of return statements
Handle returns of structs by emitting a `return void;`

This should be a very temporary fix.
2019-11-20 15:16:17 +01:00
Andrea Gussoni 335dc34ad1 Fix -Wshadow 2019-11-20 15:16:17 +01:00
Andrea Gussoni 46265f6eaf Fix -Wextra-semi 2019-11-20 15:16:17 +01:00
Andrea Gussoni 8255661b8b Fix BasicBlockNodeBB in ASTNode namespace 2019-11-20 15:16:17 +01:00
Pietro Fezzardi f95899c7ac Fix LLVM-style RTTI destruction for ASTNode 2019-11-20 15:16:17 +01:00
Pietro Fezzardi cb58b8a526 Fix destruction of ExprNodes class hierarchy
`ExprNode` and its child classes use LLVM-style RTTI.

Until now their destruction was not handled properly, causing the
constructor-destructor type mismatch warnings on ASAN.
Despite this all the code was working properly, but just for luck,
because of the fact that these classes are very shallow.

This commit fixes the issue, and allow `ExprNode` and its child classes
to be extended without worrying about wrong destructors being invoked.
2019-11-20 15:16:17 +01:00
Pietro Fezzardi 81a1c9c1e1 Remove Liveness again 2019-11-20 15:16:17 +01:00
Andrea Gussoni b0c191f188 Fix path for dot files for debug 2019-11-20 15:16:17 +01:00
Pietro Fezzardi 5fe551a188 Fix destructors and warnings for ExprNodes 2019-11-20 15:16:17 +01:00
Andrea Gussoni b214dd1921 Enforce check-conventions.sh
Replicate this commit 72f836d30079c191d1c30e185114c4c0a0f914df made by
Pietro.
2019-11-20 15:16:17 +01:00
Andrea Gussoni 560a345a2c Enforce -Weverything extensively
Replicate the changes made by this commit
f2a0df309f78e1b5d7c5f81ada5110523644559e perfomed by Pietro on the
branch containing the development fixes for `revng-c`.
2019-11-20 15:16:17 +01:00
Andrea Gussoni 7cae83a3bb Template instance declaration for -Weverything
Add new headers files (terminating with `BB`, as `BasicBlockNodeBB.h`),
which will be used as the new header files by the users, and which
contain a declaration of the template instantiation, and a `using`
aliasing the instantiation.

This has been made to comply with the `-Wundefined-func-template` flag,
automatically enabled when using `-Weverything`
2019-11-20 15:16:17 +01:00
Pietro Fezzardi 812708de96 Remove virtual calls from ASTNodes 2019-11-20 15:16:17 +01:00
Pietro Fezzardi 02ea1e5f94 Fix warnings emerged with -Wextra and -Weverything 2019-11-20 15:16:17 +01:00
Pietro Fezzardi 569ec5658e Add and enforce -Wall and -Werror 2019-11-20 15:16:14 +01:00
Alessandro Di Federico d247745df8 revng: informative error message on missing file 2019-09-04 11:52:07 +02:00
Alessandro Di Federico 25ede62813 Link librevngSupport to libLLVMSupport 2019-09-04 11:52:07 +02:00
Alessandro Di Federico 8d664c1588 Fix RPATHs
This commit replicates the structure of the install directory into the
build directory in order to simplify the management of RPATHs.

This commit also drop `QEMU_INSTALL_PATH`.
2019-09-04 11:52:07 +02:00
Andrea Gussoni fdda9fdd70 Collect metrics about duplication
Collect the metrics regarding duplication during the combing pass, and
output them in `.csv` format.
2019-07-30 18:24:16 +02:00
Andrea Gussoni 4bead538a7 Collect metrics about short circuit simplification
Collection of the metrics related to the short circuit and trivial short
circuit simplification. The metrics are computed directly during the
beautify pass and later serialized on a .csv file.
2019-07-30 18:20:11 +02:00
Andrea Gussoni b6646b692e HACK: requiresNoStatement always true
The companion function for the short circuit simplification, which tells
if the computation of the condition of a conditional node can be
inlined, always returns true, and therefore enables all the possible
optimizations.
2019-07-30 18:20:11 +02:00
Andrea Gussoni 8eb5abaaeb Fix emission computation for continue nodes
Added a new attribute for the `ContinueNode`, which tells if a
`ContinueNode` should be considered implicit. An implicit continue node
means that it can be dropped without it altering the semantics of the
code (e.g., when the `continue` is the last statement inside the body of
a cycle).

This attribute enables us to avoid directly dropping the continue node,
which would also cause the computation attached to this node to be
dropped, also in the output of the decompiler pass.
2019-07-30 18:20:06 +02:00
Andrea Gussoni 52faffb5eb Fix emission of literal constants
Fix the emission of literal constants in case we want to serialize the
address of a `GlobalVariable`.
2019-07-30 17:21:20 +02:00
Andrea Gussoni 520e6fa0fd Do not emit the else when not necessary
We now check if the ASTNode of the `else` branch for which we try to
obtain a compound statement is non existing (`nullptr`), and in such
case we emit an ad-hoc if statement which does not have the else part.
2019-07-30 17:21:20 +02:00
Andrea Gussoni 2aa9f38e63 Fix the PHIASAPAssignementiInfo pass 2019-07-30 14:34:01 +02:00
Andrea Gussoni 9127dba961 TEMP: soft fail 2019-07-23 09:10:04 +00:00
Andrea Gussoni 9e4a9b2484 TEMP: Soft fail for decompilation 2019-07-23 09:09:47 +00:00
Andrea Gussoni 39961f0ec3 Fix switch matching
For the switch reconstruction, we now only match basic block that we now
were created during the switch normalization pass.
2019-06-13 12:21:07 +00:00
Andrea Gussoni 1daf3662f3 DIRTY: handle the array tipe of CPUState struct 2019-06-13 12:20:19 +00:00
Andrea Gussoni 637205dd0e Handle InserValue instruction with init
Handle `InsertValue` instructions which provide a `ConstantStruct` as
initialization.

A new value declaration at the top of the function is emitted and later
used as initilization for the struct which is being populated.
2019-06-13 12:14:47 +00:00
Andrea Gussoni 11298108ff Handle variadic functions in decompilation
Handle the emission of variadic functions (such as the
`indirect_handler` helper function) both in regards if declaration and
definition.

Handle also `undef` values in calls to the `indirect_handler` function.
2019-06-13 12:10:38 +00:00
Alessandro Di Federico 981389d80a revng: handle different version of pyelftools
The contents of ELF dynamic tags is return either as a `str` or a
`bytes` depending on the versions of `pyelftools`.

This commit forces it to be a string to ensure compatibility with both
options.
2019-06-06 17:39:42 +02:00
Alessandro Di Federico 5d559367a4 PTCDump.cpp: use strncpy as appropriate
In `PTCDump.cpp` we were using `strncpy` in an invalid fashion: the `n`
argument was exactly the same size of the buffer, which might lead to a
missing NUL-terminator. This commit increases the buffer size by one
byte and initializes it with '\0'.

This bug was reported by `-Wstringop-truncation` of GCC 9.1.0 on a
Release build.
2019-05-28 21:32:40 +02:00
Alessandro Di Federico e445201b94 Restore getBasicBlockPC and fix FunctionIsolation
This commit restores the old implementation of `getBasicBlockPC` (which
was changed in an incompatible and wrong way) and fixes the bug the
original change tried to fix: in function isolation, jumping from a
function to a basic block that doesn't start with `newpc` now leads to a
basic block containing an `unreachable`.
2019-05-28 17:03:30 +02:00