Commit Graph

729 Commits

Author SHA1 Message Date
Alessandro Di Federico a1b0ba752c GenericGraph: implement Edge::operator==
This fixes a subtle bug in GenericGraph. Basically, if the label of an
Edge was the Empty data structure, whose `operator==` always returns
`true`, the comparison between edges was broken.
2024-04-18 17:50:32 +02:00
Alessandro Di Federico dae9f33544 Minor changes 2024-04-18 17:50:31 +02:00
Pietro Fezzardi c48908c6a6 Revamp decompilation tests
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.
2024-03-19 09:44:00 +01:00
Pietro Fezzardi 132adeecd5 Add PeepholeOptimization pass
This pass is dedicated to applying a bunch of peephole optimizations
that are useful for decompilation and haven't been implemented in LLVM
for whatever reason.

At the moment it only runs an optimization that tries to reduce the uses
of incoming values of PHINodes, under very specific condidtions, which
enables emitting less LocalVariables.
2024-03-19 09:44:00 +01:00
Pietro Fezzardi 70c8ae48ff Retire MarkAssignment for SwitchToStatements 2024-03-19 09:44:00 +01:00
Ivan Krysak 8ecdd76e68 ABI-tests: improve ABI mismatch error message 2024-03-15 19:05:10 +01:00
Alessandro Di Federico 0da9d1e1a4 Model: fix handling of 0-sized arguments
We used to support having a single `void` argument. It was for some
C-compatibility ambitions, but just omitting the argument is perfectly
fine.

Also, the DWARF importer has been fixed to handle typedef'd void as
arguments.

More in general, arguments are now required to always have a size.
2024-03-01 14:53:06 +01:00
Alessandro Di Federico 0c212b66d9 Relicense to MIT 2024-02-29 17:03:36 +01:00
Ivan Krysak 6adee367ee RemoveExtraValues: simplify the pass
Simplification includes dropping dependencies onto
`FunctionMetadataCachePass` and `LoadModelWrapperPass`, as well
as removing "StructName" logic outright.
2024-02-20 14:35:56 +01:00
Ivan Krysak 5da851fcd5 lit-tests: remove unnecessary isolated tag 2024-02-20 14:35:56 +01:00
Ivan Krysak 4d97044d15 unit-tests: include helpers 2024-02-09 16:24:47 +01:00
Ivan Krysak b73d4934c8 ABI-tests: extend register comparison
It now accounts for endianness.
2024-02-09 15:09:37 +00:00
Ivan Krysak 52c9ae0b4d ABI-tests: fix vector-less MIPS tests 2024-02-09 15:09:37 +00:00
Ivan Krysak bd6ab10454 ABI-tests: stop using unsupported primitives 2024-02-09 15:09:37 +00:00
Ivan Krysak 16feb420c3 ABI-tests: handle stack argument offset gracefully 2024-02-09 15:09:37 +00:00
Ivan Krysak 654e0958e9 ABI-tests: remove obsolete abi replacement
See the `replace-abi.py` script for how it's done now.
2024-02-09 15:09:37 +00:00
Ivan Krysak b75406f711 ABI-tests: make ID matching more robust 2024-02-09 15:09:37 +00:00
Ivan Krysak 5fcdfebbaf ABI-tests: support pointers-to-copy on the stack 2024-02-09 15:09:37 +00:00
Ivan Krysak 24e907525e ABI-tests: support pointers-to-copy in registers 2024-02-09 15:09:37 +00:00
Ivan Krysak a1ddbe5d83 ABI-tests: improve reported errors 2024-02-09 15:09:37 +00:00
Ivan Krysak d1a78d903b ABI-tests: make tested function set leaner 2024-02-09 15:09:37 +00:00
Ivan Krysak 43c6780baf ABI-tests: introduce ID list deduplication 2024-02-09 15:09:37 +00:00
Ivan Krysak f08d1a2f81 ABI-tests: prefer model::Type::Key to RFT * 2024-02-09 15:09:37 +00:00
Ivan Krysak cf0ce66674 ABI-tests: use updated stdout.yml file format
This also allows to simplify the resulting datastructure somewhat.
2024-02-09 15:09:37 +00:00
Ivan Krysak 4a8455e994 ABI-tests: separate value preservation verifier 2024-02-09 15:09:37 +00:00
Ivan Krysak d13e83163d Minor improvements 2024-02-09 15:09:37 +00:00
Alessandro Di Federico 03642de797 Standardize unit test names 2024-02-09 10:04:27 +01:00
Alessandro Di Federico aaa1b26468 AAPCS ABI: drop support for int128_t 2024-02-09 10:04:26 +01:00
Alessandro Di Federico d9367954a4 Convert all public strings to kebab-case 2024-02-09 10:04:24 +01:00
Alessandro Di Federico 5fbb5ff503 Minor changes 2024-02-09 10:04:17 +01:00
Alessandro Di Federico e718f9aa76 Standardize unit test names 2024-02-09 09:04:28 +01:00
Alessandro Di Federico f6f542769b Convert all public strings to kebab-case 2024-02-09 09:04:25 +01:00
Alessandro Di Federico 7a2e315e29 s/IRCanonicalization/Canonicalize/g 2024-02-09 09:03:34 +01:00
Pietro Fezzardi fdf1720433 Drop ValueManipulationAnalysis (VMA)
This commit drops ValueManipulationAnalysis, which in its original
design based on MinCut and Karger, was never enabled in the
decompilation pipeline.

Until now, VMA was only used in a severely weakened form in
initModelTypes. That for was so weakened that it barely did anything.

We already have a new design for VMA so that it can work before
DataLayoutAnalysis, and on Clift.
At this point, the old VMA is basically useless anyway, and the very few
occasions where it can do something will simply be solved by the
upcoming work on making some of the remaining casts implicit.

At this point it does not make sense to keep VMA alive anymore.
2024-02-07 00:41:30 +01:00
Massimo Fioravanti 5259cc83fd Add types lit tests 2024-02-04 16:49:51 +01:00
Massimo Fioravanti ab856523dd Introduce clift types 2024-02-04 16:49:51 +01:00
Massimo Fioravanti 1434948e7e Add clift unit tests 2024-02-04 16:49:51 +01:00
Andrea Gussoni d940c03e9f clift: use shipped lit for tests infrastructure 2024-02-04 16:49:51 +01:00
Ivan Krysak a52243037b Model: add basic unit tests for TypeBucket 2024-01-29 11:57:54 +02:00
Ivan Krysak 77b1acaf00 Prefer uint64_t to size_t wherever relevant 2024-01-29 11:57:54 +02:00
Ivan Krysak b25a32de2a Stop using std:: prefix for std::size_t 2024-01-29 11:57:54 +02:00
Massimo Fioravanti c276a439b5 Add pipeline invalidation
Replace the stub implementation of invalidation with the proper
implementation. A ReadPathCache is added to each global so that it can
keep tracks of what target are associated to which read paths.
2024-01-02 11:14:56 +01:00
Alessandro Di Federico d648f9b970 s/Layout::returnsAggregateType/Layout::hasSPTAR/ 2023-12-12 12:04:34 +01:00
Giacomo Vercesi 8504a96020 RawFunctionType: use NamedTypedRegister for return
Use the `NamedTypedRegister` type for return values in
`RawFunctionType`. This allows return values to be renamed at the user's
discretion.
2023-12-11 12:03:45 +01:00
Alessandro Di Federico 10dcb7be11 Fix semantics of model::Types purging passes
One of the two passes to purge unused types from the model had a
ill-defined semantics.

This commit simplifies them in two passes: one that purges all the types
unreachable from outside `Binary::Types` and one that does the same but
also preserves types with a `CustomName` or an `OriginalName`.
2023-12-05 16:19:39 +01:00
Pietro Fezzardi 1285c6e7af Make RawFunctionType::StackArgumentsType a TTR
This is homogeneous with all other nullable references to types in the
model, such as the StackFrameType in model::Function, and others.
2023-12-05 16:19:38 +01:00
Pietro Fezzardi 3e49213b43 Drop needsTopScopeDeclaration hack
This commit drops `needsTopScopeDeclaration`.
Now all the LocalVariables are declared at the top of the function.
In DecompileFunction.cpp, the emission of LocalVariables if handled at
the scope of GHAST `ASTNode`s instead of being LLVM BasicBlock-based.
This enables in the future to design and implement an analysis that for
each LocalVariable decides the C scope (represented by an `ASTNode`)
where it's declaration should be emitted to always be visible in all its
uses.
2023-11-28 15:46:19 +01:00
Ivan Krysak fa7bf17dae IRCanonicalization: introduce ternary-reduction 2023-11-21 17:05:18 +01:00
Giacomo Vercesi acd498bf25 Pipeline options: restrict to int and strings
Restrict the type of pipeline options to integers and strings. Rework
the CLOpt mechanism to avoid parsing the string twice.
2023-11-03 12:13:57 +01:00
Ivan Krysak f3acdcdef3 ABI: rewrite the testing suite documentation 2023-11-02 17:10:04 +01:00