682 Commits

Author SHA1 Message Date
Andrea Gussoni 0ae39d72a2 tests: filecheck IR after detect-abi inlining
Verify that softfloat helper calls become visible after the helper
inlining phase in `DetectABI`.

Merge the previous tests for softfloat and these new ones in a single
file, since they use the same ground truth file.
2026-06-19 15:35:18 +02:00
Andrea Gussoni 06733a9f3a InlineHelpers: split into link / inline / delete
Split the `InlineHelpers` pass into the three phases:

- `link-helpers-to-inline` links the missing `revng_inline` helper
  bodies from the `libtcg-helpers-to-inline-arch` module.
- `inline-helpers` inlines, in every function except those tagged
  `Root` or `Helper`, the calls to `revng_inline` helpers whose
  critical arguments on the call site are constant.
- `delete-helper-bodies` drops from the module the body of every
  `revng_inline` function, leaving only the declaration.

The three passes live in a dedicated `revngInlineHelpers` library
(`lib/InlineHelpers/` + `include/revng/InlineHelpers/`), so that
libraries which do not depend on `revngFunctionIsolation` can use them
without creating cyclic dependencies.
2026-06-19 15:35:18 +02:00
Giacomo Vercesi 75059cfdff Port last tests to pypeline
Convert the `revng.test-segregate-stack-accesses` and
`revng.test-detect-stack-size` tests so that they use
the new pipeline.
2026-06-19 15:35:18 +02:00
Giacomo Vercesi 4776a24eb8 tests: use revng merge llvm
Change the code of tests to use the `revng merge llvm` where possible.
2026-06-19 15:35:18 +02:00
Alessandro Di Federico 1ff0eedc5f test-segregate-stack-accesses: test i386 as well 2026-06-19 09:18:15 +02:00
Alessandro Di Federico ffaf735219 sqlite: open read-only when appropriate 2026-06-19 09:18:15 +02:00
Giacomo Vercesi 4f9e811110 pypeline: implement Pypeline Data Viewer
Implement the Pypeline Data Viewer, an HTTP server that allows browsing
the data stored by PRSS.
2026-06-17 17:48:13 +02:00
Ivan Krysak ad8be6819c import-from-c: minor wording improvements 2026-06-16 18:43:45 +02:00
Ivan Krysak 24de1435ff import-from-c: add more tests 2026-06-16 18:43:45 +02:00
Ivan Krysak bbb0a00f46 import-from-c: make output easier to debug 2026-06-16 18:43:45 +02:00
Ivan Krysak 2a97323232 import-from-c: fail on unexpected successes 2026-06-16 18:43:45 +02:00
Ivan Krysak 1609bbe745 Restore the separate enum declaration node 2026-06-16 18:43:45 +02:00
Pietro Fezzardi 6a3ab92a9d Mark to-be-dropped pipeline names as legacy
Several components in both pipeline YAMLs are slated for removal.
Prepend a legacy prefix to their names, and to the matching c++ code, so
they are clearly distinguished from the new Clift-based pipeline until
they are dropped.
2026-06-15 17:28:22 +02:00
Alessandro Di Federico e44c04925e developer-manual/qemu-helpers.md: update 2026-06-15 17:28:22 +02:00
Alessandro Di Federico e4ba9ca989 Drop precedence-tests 2026-06-15 17:28:22 +02:00
Ivan Krysak 37c2cb12ed test-docs: use new pipeline 2026-06-15 17:28:22 +02:00
Ivan Krysak a7820ae28b Simplify end-to-end c decompilation tests 2026-06-15 17:28:22 +02:00
Ivan Krysak 087ca2ff8c Update forgotten license headers 2026-06-15 17:28:22 +02:00
Ivan Krysak b18bb7e0d5 ImportFromC: handle always_inline and noreturn 2026-06-15 17:28:22 +02:00
Ivan Krysak cabbe4d6e6 Tests: use new header pipes 2026-06-15 17:28:22 +02:00
Ivan Krysak 7214a75379 Precedence test: drop 2026-06-15 17:28:22 +02:00
Ivan Krysak d1f9987523 dual-case test: drop 2026-06-15 17:28:22 +02:00
Ivan Krysak c87513cb37 segments-and-sections test: drop 2026-06-15 17:28:22 +02:00
Ivan Krysak 45d8be8a0f pretty-ints test: drop 2026-06-15 17:28:22 +02:00
Ivan Krysak 277e646d19 linked-lists test: adjust for the new backend 2026-06-15 17:28:22 +02:00
Ivan Krysak 5ddde903c5 emit-c-as-directory: move to new backend 2026-06-15 17:28:22 +02:00
Ivan Krysak 190405a77b Rename decompile-to-X pipes to emit-c-as-X
Note that the artifact names were intentionally left untouched.
2026-06-15 17:28:22 +02:00
Ivan Krysak a12880aa27 Append legacy- to the old pipes 2026-06-15 17:28:22 +02:00
Alessandro Di Federico 841b5dab71 SegregateStackAccesses: rewrite around ExtraState
Move all per-function state and logic into a new SegregateFunctionStack
worker, so the pass class itself only holds module-wide state and the
runOnFunction body is just upgrade() + segregate(). The discovery loop
now uses the MFP ExtraState surface to capture the analysis value
before each interesting program point, replacing the splitBasicBlock
trick that introduced fake nodes only to read the lattice value at
them.

Other changes that ride along:
- StackOffsetCache memoizes getStackOffset per function.
- findAllWriters does a single sorted sweep instead of a quadratic
  scan over Ranges.
- The pipeline gains a stack-accesses-segregated artifact entry.
- Test fixtures (filecheck.ll, override.yml, segregate-stack-accesses
  configuration) are updated to match the new IR shape.
2026-06-11 17:39:53 +02:00
Alessandro Di Federico c306157596 SplitStructPhis: replace HoistStructPhis
Replace the hoist-struct-phis pass with a split-struct-phis pass that
breaks struct PHI nodes into per-field PHIs instead of moving them
out, and update both pipelines to use the new name.
2026-06-11 17:39:53 +02:00
Alessandro Di Federico f0e44e5fe8 primitive-types: emit undef_value as typed pointer
Return a pointer to a buffer of the requested size and let the macro
dereference it as the target type, instead of casting a uintmax_t. This
makes the macro usable for types wider than uintmax_t.
2026-06-11 17:39:52 +02:00
Pietro Fezzardi 2bc640a5c2 import-from-c tests: make failures actually fail
These tests could pass even when the analysis crashed. The harness
joins the test command into a single shell line, and the diagnostic
block of the error-comparison branch was missing its statement
terminators: it collapsed into a single echo that swallowed `exit 1`,
so the comparison could never fail the test. Moreover, the exit code
of revng2 was only consumed as a boolean, mistaking crashes for
graceful failures, and tests without an expected-error.txt compared
the empty string against the empty RuntimeError payload extracted
from a crash trace, silently passing.

Now the diagnostics are properly terminated, the content of the error
file is printed on mismatch, and the expected-error path requires
exit code 1, an existing expected-error.txt and a non-empty
RuntimeError payload; any other failing outcome dumps stderr and
makes the test fail.
2026-06-10 13:21:17 +02:00
Andrea Gussoni d4f1a717e2 tests: add floating-point end-to-end tests 2026-05-29 17:12:38 +02:00
Andrea Gussoni 9b5eb460e0 docs: tested docs for QEMU helper functions
Walks through the full helper evolution pipeline (QEMU C ->
original IR -> full -> to-inline -> declarations-only), covering
env-to-CSV rewriting by fix-helpers, REVNG_INLINE/REVNG_EXCEPTIONAL
semantics, CSV access metadata, and per-artifact usage (lift,
enforce-abi, recompile).

All code snippets are tested via revng test-docs.
2026-05-29 17:12:35 +02:00
Giacomo Vercesi 0eebbc912a Add tests for PRSS
Add tests for the PRSS component, these will be run as the `revng-prss`
category.
2026-05-22 15:05:04 +02:00
Giacomo Vercesi 0f319057af pypeline-comparison: avoid sharing the input
When running pypeline comparison tests, copy the `$PWD` to an exclusive
scratch directory, which should eliminate any problems related to the
cache being shared across multiple projects.
2026-05-21 09:55:08 +02:00
Giacomo Vercesi 3d6a1d3764 isort: fix behavior with black
Since isort 5.11.0 if a import statement ends with a trailing comma it's
excluded for sorting, which makes the black-formatted import lines
unformatted by isort. Disable this behavior in the config so all import
lines are sorted as they should.
2026-05-18 10:13:54 +02:00
Alessandro Di Federico 8e34aa3a3c revng-db: ensure CreateFileA is exported once 2026-05-15 11:43:22 +02:00
Alessandro Di Federico a225d26fa2 import-prototypes-from-db test: import ARM test 2026-05-15 11:43:22 +02:00
Alessandro Di Federico 9bc1e65125 import-prototypes test: merge .yml and .filecheck 2026-05-15 11:43:21 +02:00
Alessandro Di Federico 6e6105e8fe import-prototypes-from-db: add linux/x86-64 test
Smoke test that exercises the linux/x86-64 path: feeds malloc/calloc/
realloc plus a NonExistentFunction through the analysis and asserts that
the typed symbols pick up a prototype while the unknown one does not.
2026-05-15 11:27:33 +02:00
Lauri Vasama 5740ac0c9c Add defer-allocas LLVM pass 2026-05-13 15:32:33 +02:00
Pietro Fezzardi d97427e9af primitive-types.h: fix typos in comments 2026-05-11 09:22:09 +02:00
Pietro Fezzardi f6574a1b6c STS: remove workaround on assigns to remove
Remove the workaround that suppressed the redundant
self-assignment that the pass now occasionally introduces in
non-legacy mode.

The remaining self-assignments are not bugs but sub-optimal C
generation, so we just disable the -Wself-assign warning in the
tests.

The sub-optimal code generation comes from passes that emit local
variables (allocas) before conversion to Clift, e.g. STS and
ExitSSA (with more planned). Each of these passes generates local
variables independently and they don't know about each other; the
order between them might also be swapped in the future. The only
clean fix is to unify them into a single transformation pass that
takes the results of multiple analyses (in the LLVM sense) and
emits local variables once. We have plans to do that, and when
it's done the warning can be re-enabled.
2026-05-08 11:37:10 +02:00
Pietro Fezzardi 1e94ca0711 Add SplitExponentialDataflow pass
Introduce a new canonicalisation pass that forces a small set of
exponential-dataflow-prone instructions (SelectInst plus the FShl
and FShr intrinsic patterns) to be stored into a dedicated local
variable. Without this, expanding their value into C expressions
during decompilation can blow up into exponential path enumeration
on real binaries.

This is a temporary workaround. A more principled split of
pathological dataflows is planned and will replace this pass.
2026-05-08 11:37:10 +02:00
Pietro Fezzardi 58e95d330f Drop assign_array macro
The macro is no longer necessary: the code now ensures we never
need to assign anything to an array, which would be ill-advised
nevertheless given that array-typed rvalues in C immediately
decay to pointers.
2026-05-08 11:37:10 +02:00
Pietro Fezzardi 85a9780d28 Drop bit_cast_to_array macro
The macro is no longer necessary: the code now ensures we never
need to bitcast anything to an array, which would be ill-advised
nevertheless given that array-typed rvalues in C immediately
decay to pointers.
2026-05-08 11:37:10 +02:00
Pietro Fezzardi 13fc8b0930 Strip dead prototypes before emitting C
Run -strip-dead-prototypes as part of the LLVM-pass list invoked
just before the Clifter, so that all unused helpers are stripped
away. In particular, this prevents some LLVM intrinsics that
return structs containing i1 (e.g. the overflow intrinsics) from
ending up in the C output and tripping later passes.
2026-05-08 11:37:10 +02:00
Pietro Fezzardi 0251ddd37d Add assign_array and bit_cast_to_array
assign_array is necessary as a fallback for when the decompiled C
code may need assignments among array types. bit_cast_to_array is
necessary because when the target type of a bitcast is an array
the regular bit_cast macro is not enough.
2026-05-08 11:37:10 +02:00
Pietro Fezzardi 3bf02e6f60 Unify implementation of bit_cast, requiring typeof
Rework primitive-types.h so that the various bit_cast macros share
a single implementation based on `typeof`/`__typeof__`. As a
consequence both keywords are added to the model's reserved-name
set so that user identifiers cannot collide with them.
2026-05-08 11:37:10 +02:00