Commit Graph

6688 Commits

Author SHA1 Message Date
Alessandro Di Federico 22cf72dc77 Merge branch 'feature/libtcg-fixes' 2025-11-11 18:12:37 +01:00
Alessandro Di Federico 5d3973b111 Model verify: allow / in most places
`/` is now supported in names except for the parts of the model that use
the name as the key, i.e., `DynamicFunction` and `LocalIdentifier`.

Eventually, `/` should be allowed there as well, but we first need to
make sure that when they end up in a location they are properly
escaped/unescaped.
2025-11-11 17:56:54 +01:00
Alessandro Di Federico c665b2d3a5 InstructionTranslator: handle invalid env accesses 2025-11-11 17:15:49 +01:00
Alessandro Di Federico 939e23445b DataFlowRangeAnalysis: drop overly strict abort 2025-11-11 17:15:49 +01:00
Alessandro Di Federico acf403916d InstructionTranslator: handle LIBTCG_op_ctpop_i* 2025-11-11 17:15:49 +01:00
Alessandro Di Federico e0581fcf5f CodeGenerator: add null_pointer_is_valid to root
LLVM purges loads from `nullptr` in functions not marked with
`null_pointer_is_valid`. This can lead to uninitialized accesses to tiny
code variables, which in turn lead to cross-`TranslationBlock` phis
which can prevent argumentless outlining.

Adding to the `root` function the `null_pointer_is_valid` attribute
fixes this problem.
2025-11-11 17:15:49 +01:00
Alessandro Di Federico 060ec57da1 Merge branch 'feature/pypeline-daemon' 2025-11-11 17:15:36 +01:00
Tommaso Fontana 229d12e538 Pypeline: add tests for the new daemon 2025-11-11 17:15:28 +01:00
Tommaso Fontana b38832e251 Pypeline: move epoch to storage_provider
Move the epoch inside the storage_provider, this allows us to make the
storage_provider_factory to return an async context manager.
This way we can simplify the locking for the daemon, but forces the
CLI project commands to deal with async code.
2025-11-11 17:15:28 +01:00
Tommaso Fontana 8ae70d85d4 Pypeline: replace logging with custom log
Now the pype command has a `--verbose` argument that to enable debug
logging in the pypelien code.
Adapted the codebase to use this new logging format but replacing
`logging` with `revng.pypeline.utils.logger`, this is done in
preparation of debug-log.
2025-11-11 17:15:28 +01:00
Tommaso Fontana 036411b441 Pypeline: add pipebox initialize and -- args
The pipebox now has to have an initialize function that is called with
all arguments passed to the CLI after --.
2025-11-11 17:15:28 +01:00
Tommaso Fontana a7f77b1704 Pypeline: propagate invalidated artifacts objects
Changed the API of storage_provider to treturn the invalidated object
ids and propagated this info to the CLI and daemon.
2025-11-11 17:15:28 +01:00
Tommaso Fontana 0ad8e8c849 Pypeline: add pypeline.daemon
Add implementation of the generic pype daemon.
It's implementation is split into `daemon.py` where we implement an
http framework agnostic interface, and `app.py` that uses it to serve
them using starlette.
2025-11-11 17:15:28 +01:00
Tommaso Fontana 71fad8b361 Pypeline: replace load_container with from_file 2025-11-11 17:15:28 +01:00
Tommaso Fontana 639593164a Pypeline: add autocomplete and refactor CLI
Now pype has an `autocomplete` command usable to enable autocompletion
and revng2 now is based on `pype`, modifying its defalults and
injecting new commands.
2025-11-11 17:15:27 +01:00
Tommaso Fontana 2daa9f938e Pypeline: add mime_type and model_name to Model
Now the model has a mime_type that we expect to return to the UI, and
model_name so the name of the model on disk can be impl-specific.
Moreover, now Model and Container use the same logic to detect if
a mimetype is textual.
2025-11-11 17:15:27 +01:00
Tommaso Fontana 652ffbb0f7 Pypeline: remove abbreviations, normalize quotes 2025-11-11 17:15:27 +01:00
Pietro Fezzardi ca30ec8987 Merge branch feature/ids-no-merge-defaults 2025-11-06 13:33:08 +01:00
Pietro Fezzardi 48749974f0 IDS: simplifyTerminator doesn't merge default
With this commit, the `simplifyTerminator` helper function used by IDS
stops trying to merge the default cases with one of the other cases
arbitrarily.
Now, if the `UnreachableSuccessor` was reached via the default case, the
default case is still arbitrarily redirected to an arbitrary case
successor, but the case and the default do not get merged.
This keeps the logic of the transform simpler, and also allows for
easier successive manipulation by planned upcoming transforms.
2025-11-06 13:32:56 +01:00
Pietro Fezzardi 1480a3f0aa Move simplifyTerminator into IDS source file
The implementation of `simplifyTerminator` is very specific to the
operations of IDS, can be easily misused, and is not currently used
anywhere else in the codebase.
2025-11-06 13:32:56 +01:00
Pietro Fezzardi ff3ab1183d ScopeGraphUtils: improve simplifyTerminator docs 2025-11-06 13:32:56 +01:00
Alessandro Di Federico 378cb91d73 InstructionTranslator: ignore TEMP_CONST outputs 2025-11-05 12:03:22 +01:00
Alessandro Di Federico 21d9cb56a0 Ban functions in .bss 2025-11-05 12:02:58 +01:00
Alessandro Di Federico 8b945b3222 Merge branch 'feature/libtcg' 2025-10-31 17:44:37 +01:00
Alessandro Di Federico c883bed765 Drop Logger's StaticEnabled feature 2025-10-31 17:25:03 +01:00
Alessandro Di Federico d8b0395253 VariableManager: move fields declarations to top 2025-10-31 17:25:03 +01:00
Alessandro Di Federico 6b78293b22 RawBinaryView: outline to .cpp 2025-10-31 17:25:03 +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
Pietro Fezzardi 67523ec115 DLA: hack for unsupported function pointers
The current implementation DLA cannot reason about function pointers,
because function types have zero size.
Given this shortcoming, llvm::Functions are used (as a hack) to
represent their Functions' return types.
This representation is a key factor of how DLA is able to piece
information together interprocedurally.

This hack has consequences.
Assume we're setting up the DLA graph, and we're looking at a use of an
llvm::Function that is inside the body of an llvm::Function and is not
the callee-operand of a Call.
That use is obviously function-pointer typed.
But if we try to create a LayoutTypeSystemNode for the llvm::Value of
the used llvm::Function, the inner machinery of how the DLA graph is
set up will treat is as the return type of the function, which is
obviously wrong.
So we have to prevent that creation at all costs.
Basically creation of LayoutTypeSystemNodes in the DLA graph associated
with llvm::Functions are valid only for representing return types.

This shortcoming does not affect the power of DLA. In its current form,
it doesn't represent function types at all.
The problem is that until we undo this hack we will not be able to
properly support function types in DLA.
This will have to be fixed in the future.

In the meantime, this commit provides an helper function to centralize
how we detect the offending uses of llvm::Functions. In this way, all
the points of the codebase that are affected by this hack are clearly
marked.
2025-10-31 17:25:03 +01:00
Alessandro Di Federico 9e66525613 Merge branch 'feature/recursive-coroutine' 2025-10-31 17:24:17 +01:00
Lauri Vasama 3e0aaaf867 Add new RecursiveCoroutine unit test 2025-10-31 17:23:52 +01:00
Lauri Vasama 086dc9fbc9 Remove RecursiveCoroutine operator*
* Add rc_eval to force evaluation.
2025-10-31 17:23:52 +01:00
Lauri Vasama 429608d122 RecursiveCoroutine improvements 2025-10-31 17:23:52 +01:00
Lauri Vasama fb34338310 Add UniqueCoroutineHandle 2025-10-31 17:23:52 +01:00
Ivan Krysak 5b419540cc Disable IRBuilder checks in some additional places 2025-10-31 09:04:59 +01:00
Alessandro Di Federico c63380cf8c Merge branch 'feature/prepare-libtcg-3' 2025-10-29 15:24:50 +01:00
Alessandro Di Federico 0d5e05688d collectTuple: add non-recursive implementation 2025-10-29 15:10:18 +01:00
Alessandro Di Federico dfbe005307 ReadFields: switch to vectors 2025-10-29 15:10:18 +01:00
Alessandro Di Federico c5d8911b8d Disasm: do not merge non-existing successor block 2025-10-29 15:10:18 +01:00
Alessandro Di Federico 5a0a01794d PrettyIntFormattingPass: improve ImmArg handling 2025-10-29 15:10:18 +01:00
Alessandro Di Federico ecc88b156d IsolateFunctions: Unexpected is no direct branch 2025-10-29 15:10:18 +01:00
Alessandro Di Federico dad1634065 RemoveHelperCalls: drop copy of OpaqueRegisterUser 2025-10-29 15:10:18 +01:00
Alessandro Di Federico 46a0af46c8 TupleTree visits: improve handling of upcast 2025-10-29 15:10:18 +01:00
Alessandro Di Federico 724703910c QuickMetadata: add support for bool 2025-10-29 10:57:41 +01:00
Alessandro Di Federico 246e0d9b59 Logger: handle nameless loggers 2025-10-29 10:57:19 +01:00
Alessandro Di Federico 97e75d0019 MetaAddress: improve verify 2025-10-29 10:56:59 +01:00
Alessandro Di Federico e81dbfd898 Minor changes 2025-10-29 10:56:50 +01:00
Alessandro Di Federico 5807520df0 Merge branch 'feature/prepare-libtcg-2' 2025-10-28 16:29:41 +01:00
Alessandro Di Federico fd216ef374 daemon: improve logging 2025-10-28 11:43:22 +01:00
Alessandro Di Federico c9e7ba7943 TupleTree visits: bypass access tracking
Use non-`const` version to bypass tracking.
2025-10-28 09:18:27 +01:00