Commit Graph

55 Commits

Author SHA1 Message Date
Alessandro Di Federico 903617e79e IRHelpers: turn some functions into IRBuilder::* 2026-06-19 09:18:16 +02:00
Alessandro Di Federico cc28786000 DwarfToModelConverter: match existing functions
Unfortunately, in DWARF, there's no widespread indicator on whether a
function is regular ARM or Thumb. Therefore, in this commit, instead of
blindly creating a new function, we first check if, in the model, we
already have a function at that address.

This means that, if we have a Thumb function in DWARF, but it doesn't
already exist in the model, we will import as regular ARM, which is
wrong.
Specifically, this can happen with `revng model import debug-info`.
2026-05-15 11:27:34 +02: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
Alessandro Di Federico 97e75d0019 MetaAddress: improve verify 2025-10-29 10:56:59 +01:00
Ivan Krysak 3561c2b907 Adopt IRBuilder wrapper 2025-10-21 19:17:01 +03:00
Giacomo Vercesi d92f4cdca3 ObjectID: introduce byte (de)serialization
Add the `to_bytes` and `from_bytes` to `ObjectID`. This allows
serializing an `ObjectID` instance to raw bytes with a specific binary
format.
2025-10-15 11:58:41 +02:00
Ivan Krysak 97aa3c8247 std::string: use implicit default constructor 2025-07-23 11:38:53 +02:00
Ivan Krysak f391392fe9 Use explicit separator strings 2025-07-23 11:38:52 +02:00
Ivan Krysak 8dff23d586 MetaAddress: pull addressesToString up 2025-07-23 11:38:50 +02:00
Ivan Krysak 96be1a9979 MetaAddress: introduce operator<=> 2025-07-23 11:38:50 +02:00
Lauri Vasama 8c3d774978 Implement MetaAddress DenseMap support 2025-07-17 16:45:03 +02:00
Ivan Krysak 795a84dfe6 MetaAddressType: introduce a prefix consumer 2025-04-15 16:35:42 +03:00
Ivan Krysak 2e85653873 MetaAddressType: introduce Count 2025-04-15 16:35:42 +03:00
Ivan Krysak 169383daa8 MetaAddress: introduce toIdentifier() method
It's equivalent to the existing `toString()` except for the fact that
it uses an identifier-friendly separator (`_`).
2025-04-15 16:35:42 +03:00
Ivan Krysak 3edb6cbb9b Minor improvements 2025-04-15 16:35:42 +03:00
Ivan Krysak 66688134bf MetaAddress: rework hashing 2025-02-13 13:09:50 +02:00
Alessandro Di Federico 15d72e580d MetaAddress::address*: simply ignore Type 2024-08-05 17:41:41 +02:00
Ivan Krysak ac587cbb4f Model: rename Type into TypeDefinition 2024-06-27 11:05:48 +02:00
Alessandro Di Federico 9fce67eee9 Reduce IRBuilder usage in favor of IRBuilderBase 2024-06-20 10:24:50 +02:00
Ivan Krysak e2018fa1c3 MetaAddress: add partial serialization option 2024-03-18 11:58:11 +01:00
Ivan Krysak 86fdb19b9f MetaAddress: pull separator into the header 2024-03-18 11:58:11 +01:00
Ivan Krysak a150b49c70 Support: remove unused dumper 2024-03-18 07:20:41 +00:00
Ivan Krysak cfe28d8e56 Stop using std:: prefix for u?int\d+_t types 2023-11-02 17:10:03 +01:00
Ivan Krysak bc98e0079f Formatting: change PenaltyReturnTypeOnItsOwnLine
The new value is 21.
2023-07-02 13:20:49 +02:00
Ivan Krysak 01b4ec36c9 Formatting: set AllowShortEnumsOnASingleLine
The new value is `false`.
2023-07-02 13:15:08 +02:00
Alessandro Di Federico a65ccc3413 Introduce ValueMaterializer
`ValueMaterializer` is a rewrite of what was called `AdvancedValueInfo`
which follows the same principles.

The main benefits over the old version is:

* We materialize the data-flow graph and the CFG of the relevant part of
  root. This makes debugging significantly easier.
* We drop the old MonotoneFramework infrastructure in favor of
  getMaximalFixedPoint.
* We significantly reduce the amount of queries we make to
  AdvancedValueInfo.
2023-06-30 13:39:22 +02:00
Alessandro Di Federico 4edcb6dd49 MetaAddress::decomposeIntegerPC: accept APInt 2023-06-30 13:35:04 +02:00
Djordje Todorovic c9b2ffaf72 JumpTargetManager: improve data structures
This commit adopts `llvm::DenseSet`, `llvm::DenseMap` and
`std::unordered_set` where needed.
It also tweaks some `llvm::SmallVector` sizes.

It brings an additional ~3% improvement during lifting.
2023-04-27 19:22:03 +02:00
Alessandro Di Federico dbcdad0a4d Switch from llvm::Optional to std::optional 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 52521f8cac Adopt more standard library's features 2023-04-08 08:42:23 +02:00
Alessandro Di Federico f68b7866b3 Introduce BasicBlockID
This commit introduces `BasicBlockID` as the unique identifier for a
`efa::BasicBlock` into the CFG. A `BasicBlockID` is defined by a
`MetaAddress` plus an incremental integer. This enables us to have
multiple instances of the same block in a single function, which is
particularly useful when inlining multiple times the same function.

Apart from this, the commit also does the following:

* It drops representing `MetaAddress`es a `structs` in the IR. This created
  several issues related to ABI. We now represent them as strings.

* It defines more functions in `support.h`, instead of defining prototypes
  by hand in `CodeGenerator.cpp` and the like. Specifically, `unknownPC`
  and `raise_exception_helper`. We also introduce a C "constructor" for
  `PlainMetaAddress`.

* It significantly reduces the API of `GeneratedCodeBasicInfo`, which
  was supposed to be put on a diet since a long time.  Specifically,
  many jump target related methods have been moved to free functions in
  `IRHelpers.h`.  Also `GCBI::getSuccessors` has been pushed into its
  only user, `PruneRetSuccessors`, to prevent further usage of a
  deprecated API. In the future, it would be nice to drop it entirely.

* It introduces `efa::BasicBlock::InlinedFrom`.

* Introduce an enum to represent named argument indices for `newpc`.
  This enables us to more effectively manipulate its argument list.

* It improves the verification and error reporting for
  `efa::FunctionMetadata`.

* Update tests.

This commit is preliminary to another piece of work to improve the
generality of inlining beyond the simple "fake function" scenario, for
which the feature was originally conceived.
2023-02-23 14:51:10 +01:00
Ivan Krysak 53ae25bcde MetaAddress: improve constexpr-friendliness 2022-09-26 10:33:43 +02:00
Alessandro Di Federico c4ca2e5d14 Introduce MetaAddress::isIn 2022-08-08 13:54:41 +02:00
Ivan Krysak 65d1a016d4 Standardize concept naming across the codebase 2022-08-05 17:27:56 +03:00
Ivan Krysak 257bcb9b3c Make MetaAddress constexpr constructible 2022-06-14 12:40:11 +03:00
Ivan Krysak 42c1461b9f Add MetaAddressType::getLLVMCPUFeatures 2022-05-06 18:51:47 +02:00
Ivan Krysak 2a6a7943f4 Fix a couple of minor typos 2022-05-06 18:51:47 +02:00
Alessandro Di Federico 60cce26768 Support streaming llvm::Errors to Loggers 2022-03-08 15:04:34 +01:00
Filippo Cremonese 74217b4fe5 Generate C++ model from YAML definition
Model classes are now described by a YAML document, which is used to
generate C++ headers containing classes and all the boilerplate
required for YAML serialization/deserialization, usage in
SortedVectors, etc. See the README in include/revng/Model for more
info.
2022-01-13 14:34:11 +01:00
Alessandro Di Federico cfb47157b9 clang-tidy: readability-identifier-naming
This commit fixes all the non-compliance with our preliminary clang-tidy
configuration, which will be merged soon.
2022-01-07 09:18:05 +01:00
Alessandro Di Federico fd30d3de42 Import the model's type system
This commit introduces the type system of the model along with several
various other improvements to the model and its users.

* Introduce the type system.
* Introduce possibility to tag certain fields in the model as to be
  optional during YAML serialization.
* All the `Name` fields have been replaced in favor of `CustomName` plus
  a `name` method that will use `CustomName` if available, or an
  automatically generated name otherwise.
* Make TupleTreeReferences behavior more robust: now you either need to
  have a valid pointer to `Root` and a `Path` or be default constructed
  (`nullptr` for `Root` and an empty `Path`). Any other configuration is
  invalid.
* The type system introduces `RawFunctionType`: this superseds the
  previous way in which we were specifying arguments and return
  values. Users of such information have been updated accordingly.
2021-07-21 18:22:58 +02:00
Alessandro Di Federico 1db6e5db5b MetaAddress: handle invalid values in operator+= 2021-03-06 16:59:38 +01:00
Alessandro Di Federico f2c83d2f67 Introduce PlainMetaAddress
This commit extracts a plain `struct` from the `MetaAddress` class. This
enables us to use `MetaAddress` from C and therefore, runtime.

The definition of such `struct`, `PlainMetaAddress`, is in
`PlainMetaAddress.h`, which is included by `early-linked.c`.

A function to print the content of a `PlainMetaAddress` has also been
introduced.

Also, anticipating the linkage of `early-linked.c` triggered a
superflous assertion in `CPUStateAccessAnalysis`. This commit removes
it.
2021-02-19 09:39:49 +01:00
Alessandro Di Federico 7f86530e74 MetaAddress::verify: handle invalid types 2021-02-17 11:44:23 +01:00
Alessandro Di Federico e72bcf796f Simplify MetaAddress::operator== 2021-01-26 18:42:10 +01:00
Alessandro Di Federico 7a560adbfa MetaAddress: drop std::less specialization 2021-01-26 18:42:10 +01:00
Pietro Fezzardi 9869f057b9 Use #pragma once for header include guards 2020-11-13 14:12:18 +01:00
Pietro Fezzardi cd9bc34d9d Enforce new include conventions 2020-11-13 10:00:24 +01:00
Alessandro Di Federico 60fdcbc66a Whitespace changes 2020-10-01 17:40:17 +02:00
Alessandro Di Federico ae3c800109 Implement MetaAddress::{from,to}String 2020-09-02 18:21:07 +02:00