304 Commits

Author SHA1 Message Date
Andrea Gussoni b10024bfc8 InlineHelpers: limit loop-unroll to x86
Only the x86 softfloat helpers iterate over the vector-register lanes
with bounded `for` loops (e.g. the packed `helper_*p[sd]` operate on
`XMM/ZMM_D(i)`). `fix-helpers` can only rewrite the per-lane CSV
accesses once those loops are unrolled. This step is not needed on other
archs, so we avoid it to save space on the generated libtcg helpers and
build time.
2026-06-19 15:35:18 +02:00
Andrea Gussoni 8443f06170 DetectUninlinableHelpers: introduce pass
Introduce a pass which statically demotes some helpers from candidates
for inlining:
1) Helpers which are part of SCC on the callgraph.
2) Helpers which contains an `insertvalue`.
3) Helpers which _fail_ the `CriticalArguments` criterion.

A critical argument is defined starting from the critical operand
definition.
A critical operand is either the condition of a `switch` instruction or
the indices of a `getelementptr` instruction.
If the dataflow computing the the operand trace back to a formal
parameter of the function, that parameter will be considered critical
when attempting the inlining of the helper.

In case each condition is satisfied, the `revng.inline.policy` metadata
is attached to the function, so that it can be used at _inline_ time to
take the decision based on the critical arguments constantness.

The metadata is encoded as an `iN` integer with N = `arg_size() + 1`:
the extra most-significant bit is always zero so LLVM's signed-decimal
`iN` printer renders the value positively (avoiding e.g. `!{i2 -2}`).

The (de)serialisation primitives live in `revng/Support/IRHelpers.h`
as `serializeInliningPolicy` / `deserializeInliningPolicy` so the
runtime `revngFunctionIsolation` doesn't need to link the build-time
`revngHelperInliningAnalyses` to read the metadata back.
2026-05-29 17:12:35 +02:00
Andrea Gussoni 8103e2046c MarkInlineHelpersUpTo: introduce pass
Introduce a build-time pass that tags every QEMU helper transitively
reaching a function defined under one of the configured runtime-library
directories (currently `fpu/` only) as `revng_inline`. The intent is to
make the lift pipeline surface "leaf-level" runtime-library calls (e.g.
softfloat ops) directly in the lifted IR by inlining away every wrapper
helper that sits between QEMU's `helper_*` boundary and the leaf.

We also gate the tagging by a per-function body-size budget.

The pass is run in the pipeline building the `libtcg-helpers-full-*.bc`
artifacts.
2026-05-29 17:12:35 +02:00
Andrea Gussoni 660f5551ee cmake: fix helper-annotation pipeline dependency
Add the `revngHelperArgumentsAnalysis` library to the dependencies of
the helpers building pipeline, so they are rebuilt whenever there is a
change in the library.
2026-05-29 17:12:35 +02:00
Giacomo Vercesi dbc734f23a CMake: force use of Python3
Switch from using `find_package(Python ...)` to `find_package(Python3
...)` as it excludes that CMake picks a Python 2 version by accident.
2026-05-14 11:26:41 +02:00
Alessandro Di Federico 2629f95dd1 Introduce ImportPrototypesFromDatabase
This commit introduces an analysis to import prototypes from a SQLite
database of well-known prototypes, typically built from debug info of
operating systems.

This analysis supersedes import-well-known-models.
2026-04-24 17:54:09 +02:00
Alessandro Di Federico 0385e4c652 Introduce revng::Configuration 2026-04-23 13:40:43 +02:00
Giacomo Vercesi a8e13e4ee7 docs: fix
Fix the docs so that `revng test-docs` passes. Rework the
`model-from-scrach.md` to use the new pipeline.
2026-04-10 11:45:13 +02:00
Giacomo Vercesi 36b7f39606 mkdocs: suppress warning message
Suppress the warning message generated by `mkdocs-material` in relation
to the mkdocs 2.0 upgrade.
2026-03-31 17:00:48 +02:00
Giacomo Vercesi 807a240c4c Revert "Remove use of PIE compiler options"
This reverts commit f9ac4db8ba.
2026-03-04 14:58:02 +01:00
Giacomo Vercesi f9ac4db8ba Remove use of PIE compiler options
The position-indipendence of the code is set by the build environment.
2026-02-16 10:34:38 +01:00
Giacomo Vercesi 798af62b87 Introduce helpers declarations
Re-organize the variants of `libtcg-helpers-*.bc` as such:
* `libtcg-helpers-full-$ARCH.bc`: unchanged, contains all helper
  function with their bodies and all CSVs.
* `libtcg-helpers-declarations-only-$ARCH.bc`: all helper
  functions have been turned to declarations. All CSVs (except a couple
  of special ones) have been dropped.
* `libtcg-helpers-to-inline-$ARCH.bc`: only functions with the
  `revng_inline` section retain their body. Only CSVs that are used by
  these functions are present.

Lift now loads only the `declarations-only` variant of helpers, as
their body is not required until `inline-helpers`. In `inline-helpers`
the `to-inline` variant is loaded and linked, which then allows the
helpers to be inlined.
2026-02-05 10:20:45 +01:00
Alessandro Di Federico d0a841ed6a CMakeLists.txt: re-introduce WELL_KNOWN_BINARIES
This was accidentally disabled, leading to not have well know binaries.
2025-12-19 14:44:09 +01:00
Alessandro Di Federico 1429b526ab Introduce libtcg
This commit drops libptc in favor of its new form libtcg.

It brings several improvements, among which:

* The QEMU version we work on has been upgraded.
* CPUStateAccessAnalysis has been reimplemented in a way that makes it
  easier to debug and solves some limitations (e.g., tracking leaking
  pointers).
* Identification of pieces of the CPU state that are read by each helper
  and fixing access to the CPU state is now performed at build-time.
* We no longer mmap the code we need to translate, dropping all the
  issues related to code that needed to be mapped where something is
  already present.
* We now have two distinct flavors of helper modules: the full one and
  the "slim" one. The latter contains the definition only of functions
  we intend to inline. It is used in most of the pipeline, a good thing
  since we spend less time optimizing code we don't really care about.
  The full module is only used on the re-compilation branch of the
  pipeline.
* We no longer split the `cpu_loop` function.
* We change MetaAddress to rely on architectures from `model::` as
  opposed to the LLVM ones.
* We no longer attach debug info to LLVM IR containing the original
  assembly.
* We now verify that the lifted code only contains code we expect.
2025-10-31 17:25:03 +01:00
Giacomo Vercesi 688b9fe111 Introduce compatibility with revng-pypeline
Add the necessary machinery to allow `Pipe`s, `Analysis`es,
`Container`s, `Model` and `ObjectID` to be implemented in C++ and used
by Python.
2025-09-17 14:02:40 +02:00
Ivan Krysak 9e5053d9fd CMakeLists: remove unused variables 2025-07-23 11:38:52 +02:00
Pietro Fezzardi 643c7ba49b CMakeLists.txt: add dependencies on autogenerated
This commit adds missing dependencies on autogenerated stuff to custom
commands using ./bin/revng
This is necessary because without those explicit dependencies, ninja
could decide to run commands involving ./bin/revng before the
autogenerated files were produced, resulting in errors when running
the ./bin/revng command that depends on them.
2025-05-13 16:18:34 +02:00
Khaled Ismaeel 7156cace7b Drop multiversion support in Python model wrapper 2025-04-30 15:08:45 +02:00
Alessandro Di Federico bf7be3460c Add missing dependency on generated file
This addresses a bug where running `ninja -j1` fails.
2025-04-28 12:58:27 +02:00
Ivan Krysak 80d8ac2b1d Introduce helper list collection 2025-04-17 11:19:17 +03:00
Giacomo Vercesi 6c31138374 Drop unused files in scripts/
Some files under `scripts/` were unused. Delete them as they are no
longer needed.
2025-03-13 14:06:02 +01:00
Alessandro Di Federico 797ad1678b Document CLI commands 2024-12-11 16:15:43 +01:00
Alessandro Di Federico 620d142d53 Reroganize and expand documentation 2024-12-11 16:15:37 +01:00
Alessandro Di Federico 0c7c20ad48 Introduce model, artifacts and analyses references 2024-12-11 16:15:27 +01:00
Alessandro Di Federico 276a4aa974 Generate model docs 2024-12-11 16:15:10 +01:00
Alessandro Di Federico 143c315196 Merge revng-c into revng 2024-11-21 10:50:55 +01:00
Alessandro Di Federico fdd0d6d06c CMakeLists.txt: reduce revng differences 2024-11-04 15:09:56 +01:00
Alessandro Di Federico 36e2faad3d Introduce -Wunreachable-code-break 2024-10-31 17:19:55 +01:00
Alessandro Di Federico d27773c688 CMakeLists.txt: reorg for revng-c compatibility 2024-10-31 17:19:51 +01:00
Giacomo Vercesi 8e65716ad8 Use zstd compression in pipeline
Use the zstd compression for:
* The `LLVMContainer` when serializing
* The invalidation cache when writing to disk
2024-10-30 21:57:55 +01:00
Alessandro Di Federico bf9ef91f4e Drop revng model import binary 2024-10-16 11:46:56 +02:00
Ivan Krysak ce11f37334 abi::Definition: move documentation out 2024-10-08 13:53:53 +02:00
Giacomo Vercesi 993f66d59c revng cli: drop revng- prefix from libexec
Drop using the `revng-` prefix from all executables under
`libexec/revng/`. Now any executable found under there that is
executable and without extension will be considered a `revng`
subcommand, following the usual command-line rules.
2024-10-01 13:38:14 +02:00
Alessandro Di Federico b5f7576573 Rework TupleTreeGenerator tracking 2024-06-20 10:24:50 +02:00
Alessandro Di Federico dd16a320a2 CMake: fix well-known-models install path 2024-03-01 14:53:06 +01:00
Alessandro Di Federico 0c212b66d9 Relicense to MIT 2024-02-29 17:03:36 +01:00
Alessandro Di Federico 2282f1db60 CMake: fix pointless rebuilds 2024-02-09 10:04:27 +01:00
Alessandro Di Federico 757f7e21d7 Import docs 2024-02-09 10:04:24 +01:00
Alessandro Di Federico 61a4aa17b8 CMake: fix pointless rebuilds 2024-02-09 09:04:30 +01:00
Giacomo Vercesi b7e01a764d CMake: generate component-hashes/revng
Generate the `share/revng/component-hashes/revng` file, which contains
the git commit from which the current build of revng (dirty files
notwithstanding) was built from.
2024-01-26 17:46:21 +01:00
Giacomo Vercesi d7d71a5370 CMake: generate component-hashes/revng-c
Generate the `share/revng/component-hashes/revng-c` file, which
contains the git commit from which the current build of revng-c (dirty
files nonwithstanding) was built from.
2024-01-26 17:15:08 +01:00
Andrea Gussoni b6d5a38bbe CMakeLists.txt: flag for no-limit-debug-info
Add a commented line in `CMakeLists.txt` to easily enable
`no-limit-debug-info`, which is useful to make debugging easier when
methods are missing from llvm classes.
2024-01-26 16:47:33 +01:00
Andrea Gussoni 4589330f82 CMakeLists.txt: flag for no-limit-debug-info
Add a commented line in `CMakeLists.txt` to easily enable
`no-limit-debug-info`, which is useful to make debugging easier when
methods are missing from llvm classes.
2024-01-26 15:42:16 +01:00
Massimo Fioravanti f6ff8e544d Add tracking debug infrastructure
Add a mechanism to make the program crash when a given element of the
model is read or written.
2024-01-02 11:14:56 +01:00
Alessandro Di Federico 29e52bb21d CMakeLists.txt: use system's clang
Before this commit, we were using the clang executable associated to the
LLVM installation we link againsts. But that's not what we want here.
2023-11-02 16:48:33 +01:00
Alessandro Di Federico 86e5ae8680 rm share/revng/well-known-models/CMakeLists.txt
Its presence lead to an undesirable situation where the file itself
would get copied to the install directory and using `add_subdirectory`
led to creating a set of support files (which would get installed too).

Simple solution: just push the content of that file in the root
`CMakeLists.txt`.
2023-10-06 17:16:04 +02:00
Alessandro Di Federico e512cd8918 CMake: drop hardcoded clang path 2023-08-23 16:37:39 +02:00
Djordje Todorovic 5c0167f792 Add ImportModelFromC Analysis
This analysis will be used for the following features:

1) Edit Type in the Model
2) Edit Function Prototype in the Model
3) Add Type to the Model

It takes C code as an input, parses it and produces a Model
type that represents the C type.
2023-07-24 11:51:47 +02:00
Andrea Gussoni 4ae0916934 clift: clift-opt binary 2023-07-07 17:48:09 +02:00
Ivan Krysak cd3865ee90 Switch to c++20 from c++2a 2023-07-05 06:07:11 +00:00