3525 Commits

Author SHA1 Message Date
Giacomo Vercesi ca3c5113d9 Add recompile-isolated to pypeline 2025-11-18 17:47:54 +01:00
Giacomo Vercesi 159ca6b965 Add LinkForTranslation to pypeline 2025-11-18 17:47:54 +01:00
Giacomo Vercesi af4b447f89 Add CompileRootModule to pypeline 2025-11-18 17:47:54 +01:00
Giacomo Vercesi 7462c2daeb Add LinkSupport to pypeline 2025-11-18 17:47:54 +01:00
Giacomo Vercesi d5aeb306f6 Add YieldAssembly to pypeline 2025-11-18 17:47:54 +01:00
Giacomo Vercesi a834f874c9 Add ProcessAssembly to pypeline 2025-11-18 17:47:54 +01:00
Giacomo Vercesi 080c5017f1 Add HexDump to pypeline 2025-11-18 17:47:54 +01:00
Giacomo Vercesi 77f925c792 Add PromoteCSVs to pypeline 2025-11-18 17:47:54 +01:00
Giacomo Vercesi a685cd1055 Add EnforceABI to pypeline 2025-11-18 17:47:54 +01:00
Giacomo Vercesi 0758a95110 Add AttachDebugInfo to pypeline 2025-11-18 17:47:54 +01:00
Giacomo Vercesi 0df05f97b7 Add Isolate to pypeline 2025-11-18 17:47:54 +01:00
Giacomo Vercesi 819538a5df Add CollectCFG to pypeline 2025-11-18 17:47:54 +01:00
Giacomo Vercesi cf52901d6d Add GenerateModelTypeDefinition to pypeline 2025-11-18 17:47:54 +01:00
Giacomo Vercesi ddb36fc70f Add ModelToHeader to pypeline 2025-11-18 17:47:54 +01:00
Giacomo Vercesi 95365c1fb9 Add PureLLVMPasses{Root,}Pipe to pypeline 2025-11-18 17:47:54 +01:00
Giacomo Vercesi 97b471c888 Add Lift to pypeline 2025-11-18 17:47:54 +01:00
Giacomo Vercesi b4f9147646 Introduce LLVMFunctionsContainer
Add another container for LLVM modules. This one stores one
`llvm::Module` per function (all modules share the same
`llvm::LLVMContext` for performance reasons).
2025-11-18 17:47:54 +01:00
Giacomo Vercesi a39906ca85 Factor out cloneFiltered from LLVMContainer
Move the body of `cloneFiltered` from `LLVMContainer` into a free
function in `IRHelpers.h`.
2025-11-17 10:04:13 +01:00
Giacomo Vercesi 1c07656448 pipebox.py: add initialize function
Add the `initialize` function to `pipebox.py`. This allows passing
command-line arguments to the pipebox.
2025-11-17 10:04:13 +01:00
Giacomo Vercesi 153fcf2773 InitRevng: initialize LLVM components
In the constructor of `InitRevng` also call all the `llvm::initialize*`
functions. This is done to be less implementation-specific and having
these functions be called in
`LLVMPipelineRegistry.libraryInitialization`.
2025-11-17 10:04:13 +01:00
Giacomo Vercesi 4f93c9e7ad Container: add mime type
Add the `MimeType` field to the C++ classes. Forward it to python via
nanobind.
2025-11-17 10:04:13 +01:00
Giacomo Vercesi 5b24fff3cc Model: add missing methods
Add the missing `model_name` and `mime_type` to the `Model` class.
2025-11-17 10:04:13 +01:00
Pietro Fezzardi d61f06756f MakeSegmentRef: handle multiple identical operands 2025-11-14 15:53:29 +01:00
Alessandro Di Federico a99edd93f8 st0_x86: fix deserialization 2025-11-13 17:06:38 +01:00
Alessandro Di Federico d50c25a47b Binary: limit ExecutableRanges to FileSize 2025-11-13 14:16:09 +01:00
Alessandro Di Federico 3fb0e8681b CodeGenerator: log JumpTarget reasons 2025-11-13 14:16:09 +01:00
Lauri Vasama fbc1563b43 Add loop detection pass 2025-11-12 15:28:54 +02:00
Lauri Vasama b24f61db40 Improve legalization
Legalization now emits fewer casts depending on context.
2025-11-12 15:28:54 +02:00
Lauri Vasama 359af98ab8 Emit spaces before casts in C 2025-11-12 15:28:54 +02:00
Lauri Vasama d5d1734f5c Add expression usage helpers 2025-11-12 15:28:54 +02:00
Lauri Vasama cee099c2df Rename Clift GoToOp to GotoOp 2025-11-12 15:28:54 +02:00
Lauri Vasama 220439dfce Remove FunctionType::getCliftFunctionType
Change FunctionType::getFunctionType to return clift::FunctionType
instead of clift::ValueType.
2025-11-12 15:28:54 +02:00
Lauri Vasama 68436c58d6 StatementOpInterface::isIndirectlyNoFallthrough 2025-11-12 15:28:54 +02:00
Lauri Vasama 8a1123ad58 Fix MakeLabelOp canonicalization 2025-11-12 15:28:54 +02:00
Lauri Vasama a912df4c06 Fix loop label related issues 2025-11-12 15:28:54 +02: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
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 c883bed765 Drop Logger's StaticEnabled feature 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
Lauri Vasama 086dc9fbc9 Remove RecursiveCoroutine operator*
* Add rc_eval to force evaluation.
2025-10-31 17:23:52 +01:00