Commit Graph

3168 Commits

Author SHA1 Message Date
Alessandro Di Federico b6658df052 Fix various warnings 2019-11-24 22:52:23 +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
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 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 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
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 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 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 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
Alessandro Di Federico 9eb3cfd06a FunctionIsolation: update PHINodes
This commit improves the function isolation pass to fix references to
predecessor basic blocks in phi nodes.

The commit also improves handling of instruction operands to ensure no
unmapped Values are used.
2019-05-27 19:36:12 +02:00
Alessandro Di Federico 8d009296ef FCI: ignore non-translated basic blocks 2019-05-27 19:36:12 +02:00
Andrea Gussoni 9f97826806 raise_exception_helper calls exception_warning
The call to `exception_warning` in `support.c` is now performed
directly by the `raise_exception_helper` function defined in
`support.c`, so that we can avoid calling two different functions in the
translated and isolated module.
2019-05-27 19:36:12 +02:00
Alessandro Di Federico 53df3086ce FunctionIsolation: do not remove anypc and friends 2019-05-27 19:36:12 +02:00
Alessandro Di Federico 357d88377d EnforceABI: Killer branches are noreturn 2019-05-27 19:36:12 +02:00
Alessandro Di Federico c232e20be8 s/func.entry/revng.func.entry/ leftover 2019-05-27 19:36:12 +02:00
Alessandro Di Federico 7815c551db Support for file names in Logger
`Logger` can now print the file name from which it was called
(`--debug-location-max-length`).
2019-05-27 19:36:12 +02:00
Andrea Gussoni c76ba641aa Fix head region candidate election 2019-05-27 18:23:50 +02:00
Andrea Gussoni 5c5ae0a9de Improve metaregion collapse 2019-05-27 18:12:35 +02:00
Andrea Gussoni dd772f5f5f Enhance findReachableNodes algorithm
Enhanced the `findReachableNodes` algorithm, with a new `StackSet`
parallel data structure which is used to quickly check if we are
encountering a node already on the visit stack.

Modified the `findReachableNodes` to include in the returned set of
nodes also nodes which are encountered on self loop paths and that
should consequently be included in this set.
2019-05-24 18:35:52 +02:00