Isolated functions return structs. These structs used to be constructed
using `IRBuilder::CreateAggregateRet`, which is implemented using
`insertvalue` instructions. However, this approach led to ugly
decompiled code.
This commit introduces "constructor" functions that can be easily
pattern matched down the pipeline.
This commit ensures that FunctionIsolation and EnforceABI do only
thing. This means that they no longer modify `root`.
Instead, we have a new pass, `invoke-isolated-functions` that needs to
be run after them and replaces the entry point of the functions with
invokes to the isolated functions, possibly with the appropriate
arguments.
The `revng` script looks in several paths for analysis
libraries. However, before this commit, in case multiple versions of the
same library were available, you'd get unpredictable results.
This commit ensures that each library is considered at most once, in the
right order.
We now employ `argparse` subparsers.
This commit also fixes a bug involving global options with an argument
(such as `--prefix`) that led the argument to be interpreted as the
subcommand.
`--prefix` enables projects using revng to easily and correctly employ
libraries available in build directories organized in a install
tree-like fashion.
We used to stop the harvesting process when the harvesting process was
no longer able to identify new jump targets, even if new CFG edges have
been identified.
This approach prevented to discover additional parts of the CFG thanks
to the increased accuracy gained by a more accurate CFG. This effect is
particularly visible when we have jump tables that can be reached only
through other jump tables.
This enables us to handle situations where the comparison against the
switch value is performed on the lower 32 bits, but the address
computations uses the full 64 bits.
cmp edi,0x23
ja ...
movsxd rdx,DWORD PTR [rcx+rdi*4]
Note that this does not solve all these situations yet.
This commit also introduces a reference output for the new
switch-jump-table-32-bit-comparison test case.
AVI used to work on a cloned root that was initializing the pc to the
program entry point. Under certain conditions, this led to DCE almost
all of the code.
This commit drops support for running StackAnalysis without ABI
analysis. This has been broken for quite some time and a source of slow
downs in (badly) crafted optimization pipelines.
This commit fixes a subtle bug due to `ABIDetectionPass` and
`FunctionBoundariesDetectionPass` using methods from
`GeneratedCodeBasicInfo` (through `StackAnalysis::serializeMetadata`)
without explicitly depending on it.
We used to mark call to noreturn functions as killers, but this is not
correct.
Note that this is a temporary solution, we need to explicitly handle
such situations.
Generated code now either jumps to `anypc` or `unexpectedpc`. The latter
one is to be considered a safety measure and will be populated with an
unreachable instruction on the decompilation pipeline.
This commit makes `PCH::getUniqueJumpTarget` more robust:
1. We bail out only if we find a non-constant write to a field of
`MetaAddress` for which we already have a value. Before, any
non-constant write would lead to bailing out.
2. In case we meet an helper, we now bail out only if we didn't saw any
write to a portion of the `MetaAddress`.
This commit extracts a plain `struct` from the `MetaAddress` class. This
enables us to use `MetaAddress` from C and therefore, runtime.
The definition of such `struct`, `PlainMetaAddress`, is in
`PlainMetaAddress.h`, which is included by `early-linked.c`.
A function to print the content of a `PlainMetaAddress` has also been
introduced.
Also, anticipating the linkage of `early-linked.c` triggered a
superflous assertion in `CPUStateAccessAnalysis`. This commit removes
it.
* Introduce GCBI::buildDispatcher
* Introduce GCBI::getJumpTarget{,Block} and GCBI::getBlocksGeneratedByPC
to easily map `BasicBlock *` to jump targets and viceversa.
* PCH::buildDispatcher now returns a list of the newly created basic
blocks.
* Other minor changes
This commit fixes the following issues:
1. It introduces `getNameFromYAMLEnumScalar` which returns a
`llvm::StringRef` instead of a `std::string`.
2. Lets users decide what to do when `getValueFromYAMLScalar` does not
get any match (abort by defaul, or return an "Invalid" value).