Commit Graph

216 Commits

Author SHA1 Message Date
Alessandro Di Federico 7fab462593 Don't fail if section headers are corrupt 2018-11-14 09:34:49 +01:00
Alessandro Di Federico 37fb3d6e56 Introduce support for little endian MIPS 2018-11-14 09:34:49 +01:00
Pietro Fezzardi b9273210d0 Update to LLVM 7
Updating to LLVM 7 mainly involved the following steps:

* Upgrade APIs for folding ConstantExpr.
* Upgrade APIs for GraphTraits.
* Upgrade APIs for DominatorTreeBase.
* Upgrade APIs for BinaryFormat to parse ELFs.
* Fix the LLVM Linker to properly link the QEMU helpers.
* Disable the new optnone attribute even with optimization -O0. This is
  necessary to allow SROA to do its job properly.
* Upgrade APIs to delete Instructions.
* Properly cleaning up orphaned metadata still referring to Instructions
  that have been destroyed. Recent versions of LLVM are more strict in
  this respect, and will assert when compiled in debug.
* Avoid using LLVM `getGlobalContext` which has been removed from newer
  versions of LLVM.
* Upgrade tests to use the new APIs.
* Upgrade APIs for instruction iterators and reverse iterators.
2018-11-13 18:11:05 +01:00
Alessandro Di Federico dee2cf0d04 Reimplement the reaching definition analyses
This commit reimplements the (conditional) reaching definitions passes
as an instance of a monotone framework.

The `ConditionNumberingPass` has also been reworked in the way it
exposes its results, but it's otherwise unchanged.

A proper unit testing framework is also available to ensure everything
works as supposed to.
2018-10-16 17:39:22 +02:00
Alessandro Di Federico 4538d520a6 SET: fix use after free in assertion
An `assert` used to check the type of a deleted object. This commit
delays the deletion of such object.
2018-10-16 16:59:08 +02:00
Alessandro Di Federico 1c5bb1a84c Whitespace and other minor changes 2018-10-16 16:58:57 +02:00
Alessandro Di Federico 5872dc1ffc Handle top in BoundedValue::setSignedness
In case of a top `BoundedValue` which appears to be used with an
inconsistent signedness, simply change the signedness and keep it to
top.
2018-10-16 16:57:53 +02:00
Alessandro Di Federico 826accaa0a OSRA: fix "It's already on the stack" message
This message used to be emitted unconditionally. It is now emitted only
as appropriate.
2018-10-16 16:57:07 +02:00
Alessandro Di Federico f4c5942d62 Introduce the registerjt logger
This commit introduces a new logger that prints out the name and reason
for each newly registered basic block.
2018-10-16 16:55:57 +02:00
Alessandro Di Federico a704926ddc Ensure blocks are always reachable in root
Through `JumpTargetManager::setCFGForm` the `root` function CFG can be
changed so that the `dispatcher` is minimized, i.e., it jumps only to
those basic blocks that would be otherwise unreachable. This allows us
to perform more accurate and simpler analyses.

To bring the function in this state we used to check if there was at
least a non-dispatcher predecessor, however this did not work with loops
reachable only from the dispatcher, since they had a predecessor, but
that didn't mean it was reachable from the entry.

This commit fixes the problem by navigating the CFG in reverse-post
order, registering all the reachable blocks and then restoring the edge
from the dispatcher to those that are not reachable.

Additionally:

* Basic blocks with no predecessors are now purged before
  `JumpTargetManager::harvest`.
* The `CFGForm` enum is now a namespace.
2018-10-16 16:26:35 +02:00
Alessandro Di Federico 81c003d997 Use MDBuilder to create alias.scope
This commit also fixes a bug due to some problem in how we were building
the self-referencing metadata associated to `alias.scope`.
2018-10-03 23:11:13 +02:00
Alessandro Di Federico 9dcefc8151 Add argument to InlineAsm function
`InlineAsm` instructions resemble function calls. You also have to
provide the prototype of the called function. Before this commit, we
were employing `void(void)`, which was wrong since we were passing in a
CSV.

In this commit we add a pointer argument to this prototype, which
prevents an assertion in LLVM from being triggered.
2018-10-03 23:11:13 +02:00
Alessandro Di Federico 648e4e5945 Fix assertion in function isolation
Update an assertion trying to enforce the fact that `alloca`s copied
from `root` where in the original entry block, while they should be in
the `dummy` entry block.

Additionally, an improvement has been introduced which ensures only one
`alloca` is copied per-function, while, before, we were creating a new
`alloca` for each use in that function.
2018-10-03 23:11:13 +02:00
Alessandro Di Federico cc02713f6d Abandon argparse in favor of LLVM's CommandLine
This commit dismisses the `argparse` library (the only non-runtime C
component of rev.ng) in favor of LLVM's CommandLine library, which
offers several benefits. Among others, now command line arguments can be
easily specified as a global variable, decentralizing their management
and avoiding the long list of arguments in the constructor of singleton
objects such as `CodeGenerator`.
2018-10-03 23:11:13 +02:00
Alessandro Di Federico 43cf36bfce Introduce revng_log and abandon DBG(...)
This commit introduces `revng_log`, a macro analagous to `revng_assert`,
which basically allows to have the benefit of the `Logger` class without
having to compute the expression to log if the logger is disabled.

This commit also completely dismisses the `DBG` macro, converting all
the old code to `Logger` + `revng_log`.
2018-10-03 23:11:13 +02:00
Alessandro Di Federico 076aeac7f3 Move and rename all files
This commit moves around most files. The new directory structure is as
follows:

* `lib/$LIBRARY/`: contains a library, i.e., a set of `.cpp` files used
  by multiple libraries/tools.
* `include/revng/$LIBRARY/`: contains the public headers associated to
  the library in `lib/$LIBRARY/`.
* `tools/$TOOL/`: directory where all the `.cpp` files (and private
  headers) for a tool reside. Currently we have two tools: `revamb` and
  `revamb-dump`.

On top of this, all file names are now in camel case.
2018-10-03 23:11:12 +02:00