The tests was testing if a function whose entry address is the target of
load was identified as a function or not (it shouldn't).
This test was passing accidentally. This has not been supported since
the introduction of `RootAnalyzer`. In order to support this again, we
need to resurrect `processLoadsAndStores`.
This commit ensures that parts of the model that must point to code
(specifically `Binary::EntryPoint`, `Binary::ExtraCodeAddresses` and
`Function::Entry`) actually point to a segment mapped as +x.
The DLAStep SimplifyInstanceAtOffset0 now only triggers if the parent
node has the child-at-offset-0 node as its only successor, or when the
child-at-offset-0 doesn't have other predecessors.
Doing this guarantees that it's impossible for another predecessor of
the child-at-offset-0 to start seeing memory accesses that were
initially relative to the parent.
This condition is slightly more restrictive than the previous one, but
it takes into consideration some far reaching consequences.
If SimplifyInstanceAtOffset0 aggressively like we did before, DLA can
end up inferring types in some memory locations, like executable
segments, for which there aren't clues in the binary.
This isn't bad per se, but if DLA does that, the newly recovered type is
identified as non-executable data, causing misdecompilation because
rev.ng doesn't decompile memory regions that it understands as non
executable.
This commit, making SimplifyInstanceAtOffset0 less aggressive, makes it
play better with the rest of the assumptions of the decompilation
pipeline.
It also relaxes a decompilation test that was previously working by
chance and that was effectively beyond the current expressive power of
reasoning for DLA at the moment.
Before this commit, the test was implicitly relying on control-flow
recovery and on the specific order of the then/else scopes in an
if-statement.
This commit relaxes that requirement, since it's not part of what the
test is designed to test.
We introduce a new LLVM Pass that should detect implicit
casts, by marking the 3rd argument of ModelCast as `true`.
The backend will omit printing a cast expression if the
ModelCast is implicit one.
Currently, some non-determinism upstream in the ABI detection pipeline
causes the return type of the `compute` function to be misdetected, even
if only very rarely.
Exclud this return type from tests for now.
Consider to re-add it in the future if we enforce stricter determinism,
or when EFA 4 is ready.
Many old unit tests were too rigid, using the model and the LLVM IR.
This commit drops them, and replaces them with decompilation tests based
on revng-qa, relying on `revng model compare` to test model properties,
and on `FileCheck` to test that we emit specific constructs in C.
The new tests cover various features of the decompiler.
* DLA capability to recover complex data structure like linked-lists and
arrays.
* DLA capability to update segment and section types, so that we emit
nice looking accesses to segments in C.
* Capability to emit nice looking integer literals in C
* Capability to emit inline string literals in C and update the model
types of the segments containg such string literals.
This commit:
1. Introduces an alloca for stack arguments of a function. This enables
us to "write" to stack argument. In order to do so, we simply map the
relevant stack portion to the alloca that, since it's a memory
object, can be `load`'d from and `store`'d to.
Note that `llvm::Argument`s are always scalar since if the original
argument was an aggregate, it would have been passed as a pointer,
which is a scalar.
Note also that previously we were using scalar arguments as if they
were *pointers* to the stack arguments. This commit fixes that too
(and updates the tests accordingly).
2. Introduces an alloca for *scalar* stack arguments of a call site.
The alloca is then mapped to the corresponding part of the stack.
Previously, there was no redirection and negative offsets from
`_stack_frame` would pop up.
* Fix non-PrimitiveTypes with low IDs.
* Ensure we use `revng model compare` to test the model.
* Updates the name to reflect the recent changes in naming convention
and in the way we represent `model::Type::ID`s.
This commit switches `model::Type::ID` from being a GUID to be a
progressive number, in order to make things easier for humans.
On top of this, this commit introduces the following changes:
* TypeCopier: import all the necessary PrimitiveTypes and improve
handling of CustomName.
* Move Kind as the last field of the key of each TupleTree type used in
an `UpcastablePointer`.
* Update the ground truth of tests to ignore the `CustomName` in favor
of focusing on `OriginalName`.
* Increase adoption of `model::Binary::makeType`, equivalent to
`Binary.recordNewType(makeType<model::*Type>())`.