Commit Graph

7047 Commits

Author SHA1 Message Date
Andrea Gussoni 9e2528faec EmitFieldAccesses: ptr_add LinearCombination test
Add a test exercising the `LinearCombination` propagation through
`composePtrAdd`.
2026-03-23 17:34:50 +01:00
Pietro Fezzardi 944c6adba8 Merge branch 'feature/field-accesses-fix-ptradd' 2026-03-20 10:18:09 +01:00
Andrea Gussoni b70c9aed66 EmitFieldAccess: ptr_add.offset as BasePointer
Additional test in to struct-ptradd-access.mlir that exercises the case
where the base pointer information comes from the offset operand (RHS)
of ptr_add rather than the pointer operand (LHS).

This tests the relaxed assumptions introduced in the previous commit
where `composePtrAdd` no longer requires the `PointerOperand` to be an
`Address` `PA`.
2026-03-19 17:31:42 +01:00
Andrea Gussoni 5d023b32a4 EmitFieldAccesses: no assumption on composePtrAdd
We now don't assume that the `PointerOperand` of a `ptr_add` leads to a
`Address` PA, nor that the `OffsetOperand` leads to a `Numeric` PA.

We now behave as a simple `composeAdd`, keeping the special `Offset`
scaling by the `PointeeSize` of the `PointerOperand`.
2026-03-19 17:31:42 +01:00
Andrea Gussoni 6eaa1c39ad EmitFieldAccesses: no leaf on intermediate bitcast
Remove the special casing for `composeBitcast`, where we created a
`leaf` PA in case the traversal of the upward tree did only provide a
`Numeric` PA.

This was introduced as a workaround for handling `composePtrAdd` when
the `PointerOperand` was a `Numeric` PA.
2026-03-19 16:49:37 +01:00
Pietro Fezzardi c87910f3d2 Merge branch 'feature/emit-field-accesses' 2026-03-18 17:25:58 +01:00
Andrea Gussoni 02cc6923d0 EmitFieldAccesses: implement pass
The `EmitFieldAccesses` pass transforms `clift` by taking pointer-typed
expressions computed via integerr arithmetic with type-safe field
accesses and array accesses.

The transformation is split in three main phases:
1) `PointerArithmetic` computation.
2) `BestTraversal` computation.
3) `FieldAccess` `clift` rewrite.

The high level driver is implemented in the `EmitFieldAccesses` header
and cpp, while the nested 3 phases are implemented respectively in
`PointerArithmetic`, `BestTraversal` and `FieldAccessReplacement`.

The `computerPointerArithmetic` phase is concerned with taking a
pointer-typed `ExpressionOp`, called `PointerToReplace`, and expressing
it in a `BasePointer+Offset` form.

The `computeBestTraversal` phase is concerned with computing the best
traversal of the type pointed to by `BasePointer`, that can be used to
rewrite the pointer arithmetic in `clift` with just field accesses and
array subscripts.

The `replaceFieldAccess` phase takes the `Traversal` computed at the
previous step, and actually rewrites in `clift` the `PointerToReplace`
in terms of field accesses and array accesses w.r.t. the `BasePointer`.
2026-03-18 17:25:13 +01:00
Andrea Gussoni 4952346620 Clift: reject TypePunned for ArrayType
Reject the `assignTypePunnedConstraint` DDR `Expressions.td` rewrite
when the `DstType` is an `ArrayType`, to avoid an invalid rewrite that
would violate the assumption that `bitcast`s do not admit a `ArrayType`
as `result` type.
2026-03-18 17:25:13 +01:00
Andrea Gussoni cbb3f03910 Clift: fix CastKind::Decay verify
Perform `dealias` over argument operand of the `CastOp`.
2026-03-18 17:25:13 +01:00
Alessandro Di Federico c2fe99337d DetectStackSize: sign-exted LowerBound
This led to misdetect the stack size on 32-bit architectures.
2026-03-18 15:19:18 +01:00
Alessandro Di Federico 0c0ca9803b Merge branch 'feature/pypeline-port-tests' 2026-03-05 14:38:06 +01:00
Giacomo Vercesi 36f9dfe45b tests: leave TODO in tests to port/drop
Add TODOs to the test yamls of tests that are yet to be ported to the
new pipeline, the new backend or will be removed indefinitely when the
old pipeline is removed.
2026-03-05 14:23:06 +01:00
Giacomo Vercesi 26eca524d0 compare_isolate: exclude attributes
Blank out attribute identifiers and exclude attribute declaration lines,
as they might be swapped between executions.
2026-03-05 14:23:06 +01:00
Giacomo Vercesi 2a5c58791d Port tests to the new pypeline
Port as many tests as possible to use the `revng2`.
2026-03-05 14:23:06 +01:00
Giacomo Vercesi d0d3df4f72 Add revng2 quick analyze
Add the counterpart to `revng2 quick artifact` which allows to run the
initial auto analysis on a binary and return its model.
2026-03-05 14:23:06 +01:00
Giacomo Vercesi 161ba6e5c3 revng2 quick artifact: add --analyses option
Add the `--analyses` option which allows specifying the list of analyses
to be run before producing the artifact instead of the default initial
auto analysis.
2026-03-05 14:23:06 +01:00
Giacomo Vercesi 2663a8beb3 LocalStorageProvider: fix invalidation code
Before this commit the `invalidate` code did invalidate all the objects
but left all the rows in `dependencies` that were paired to the produced
objects except the invalidated paths.
In this commit the logic is changed to be done in 3 steps:
1. SELECT all the objects that need to be invalidated, write down their
   rowid
2. Delete all the rows in `dependencies` that were produced in
   conjunction to the objects from (1)
3. Remove the objects from the table, returning invalidation data
This guarantees that the database does not accumulate invalidation data
over time due to invalidations.
2026-03-05 14:23:06 +01:00
Giacomo Vercesi f19da8b440 pype project analyze: output invalidations
Add a command-line option to `pype project analyze` that allows
serializing the invalidated objects of an analysis to yaml on disk.
2026-03-05 14:23:06 +01:00
Giacomo Vercesi ce60d8a1e5 pypeline: integrate model migration infrastructure
When calling `Model.deserialize` the model will be automatically be
migrated if it needs to.
2026-03-05 14:23:06 +01:00
Giacomo Vercesi f4d0573017 pypeline: StorageProvider works with Model
Change the `get_model` and `set_model` interface of `StorageProvider` so
that it is responsibility of the `StorageProvider` to
serialize/deserialize the model before returning to the caller.
This is in preparation to the model migration being implemented, since
it's now a responsibility of the storage provider to deserialize it it
can trivially re-save it to disk if it is migrated.
2026-03-05 14:23:06 +01:00
Giacomo Vercesi a6a3e15e6b pypeline: add env prefixes
Add the `PYPELINE_` prefix to all the pypeline environment variables.
2026-03-05 14:23:06 +01:00
Giacomo Vercesi 6ec9f9a952 TupleTree: overhaul reference caching
Overhaul the logic and method names involved in enabling and disabling
reference caching in `TupleTree<T>`. `TupleTreeReference<T, U>` now
lazily caches the target and will traverse the path only when needed.
Also expose and use these functions in the new pipeline, which should
provide some speedup when executing a `Schedule`.
2026-03-04 14:58:02 +01:00
Giacomo Vercesi 704c5e9bbb TupleTree: fix broken operator==
The `operator==` for keyed `StructDefinitions` was the comparison
between keys, which is misleading.
2026-03-04 14:58:02 +01:00
Giacomo Vercesi 1193b6ef34 TupleTree: upgrade Version: 0
When a `TupleTree` is deserialized, if it has the `Version` field set to
0 upgrade it automatically to the `SchemaVersion`.
2026-03-04 14:58:02 +01:00
Giacomo Vercesi 9cd7554d71 pype project analyze: refactor code
The functions that take care of running an analysis/analysis list have a
lot of duplication, merge the two into a single function that takes care
of running both.
2026-03-04 14:58:02 +01:00
Giacomo Vercesi 4e46343960 pypeline: fix container_format handling
Fix the code that handles setting the `--format`, `--tar` and `--yaml`
command line options, which incorrectly wrote to the `format` kwargs
instead of the `container_format` one.
2026-03-04 14:58:02 +01:00
Giacomo Vercesi a2d263dfc9 pype project analyze: add output argument
Add an argument which specifies where the changed model should be
written to. This replaces the hardcoded behavior of writing the new
model to stdout.
2026-03-04 14:58:02 +01:00
Giacomo Vercesi 9287c51d27 pypeline: fix -C option
Instead of executing `chdir` when using the `-C` option, which is
fragile when other paths are involved, store the option in the click
context and propagate it to the required code paths that require knowing
what the base directory is.
2026-03-04 14:58:02 +01:00
Giacomo Vercesi ae601f2d3c LocalStorageProvider: add inline parameter
Allow the storage provider to be initialized with `local://?inline`.
This will set the cache directory to `$PWD/.cache` instead of
`~/.cache/revng`. This is to simplify testing for pypeline.
2026-03-04 14:58:02 +01:00
Giacomo Vercesi d479438d3c Add ImportFromC analysis to pypeline 2026-03-04 14:58:02 +01:00
Giacomo Vercesi 8804092b90 Add ConvertFunctionsToRaw analysis to pypeline 2026-03-04 14:58:02 +01:00
Giacomo Vercesi 77d825ff59 isolate: whitelist more GVs to preserve
Also include any GV from `ProgramCounterHandler::affectsPC` to the list
of GVs that need to be preserved when splitting off the root module
into function modules.
2026-03-04 14:58:02 +01:00
Giacomo Vercesi 4757cad690 pipeline-comparison: remove use of {push,pod}d 2026-03-04 14:58:02 +01:00
Giacomo Vercesi 807a240c4c Revert "Remove use of PIE compiler options"
This reverts commit f9ac4db8ba.
2026-03-04 14:58:02 +01:00
Pietro Fezzardi d0674e9497 Merge branch 'feature/clift-based-headers-1' 2026-03-04 09:48:38 +01:00
Ivan Krysak 41378913b2 CTokenEmitter: add a suffix-less literal helper 2026-03-04 08:20:00 +00:00
Ivan Krysak b63102ed12 CTokenEmitter: introduce Macro entity kind 2026-02-27 18:28:12 +00:00
Ivan Krysak cd6c6bd22d Introduce isSeparateDeclarationAllowed helper
This is a replacement for `isDeclarationTheSameAsDefinition`.
2026-02-27 18:28:12 +00:00
Ivan Krysak 3bec80c9ba PTML: introduce c.macro token type 2026-02-27 18:28:12 +00:00
Pietro Fezzardi 5415f81204 CTokenEmitter: set actions for the macro location 2026-02-27 18:28:12 +00:00
Ivan Krysak c1f05e4d24 Ranks: introduce the macro location 2026-02-27 18:28:12 +00:00
Pietro Fezzardi d9816bc69b Merge branch 'feature/prepare-clift-based-headers' 2026-02-25 14:22:15 +01:00
Ivan Krysak de4c816147 CTokenEmitter: improve an error message 2026-02-25 14:10:44 +01:00
Ivan Krysak 3a699abdcf Clift: fix helper misuse 2026-02-25 14:10:44 +01:00
Ivan Krysak d521651b1e ImportModelNamesPipe: set helper names too 2026-02-25 14:10:44 +01:00
Ivan Krysak 1a91707a2b GenericGraph: introduce empty() method 2026-02-25 14:10:44 +01:00
Ivan Krysak 1c56e34350 NameBuilder: introduce isAutomaticName 2026-02-25 14:10:44 +01:00
Ivan Krysak 95650e593d primitive-types.h: include stdbool.h 2026-02-25 14:10:44 +01:00
Ivan Krysak 1c3d11096d primitive-types.h: define NULL if absent 2026-02-25 14:10:44 +01:00
Ivan Krysak ad822abc53 Fix static IR helper object names 2026-02-25 14:10:44 +01:00