Commit Graph

326 Commits

Author SHA1 Message Date
Giacomo Vercesi fede2f2090 ProgramRunner: allow redirection of streams
Change ProgramRunner's API to allow to optionally provide stdin and
capture stdout/stderr.
2025-05-05 17:28:48 +02:00
Ivan Krysak 1bce76f511 Bring name mangling out into a support helper 2025-04-24 13:22:14 +02:00
Pietro Fezzardi 5ca182578b Add InstCombineNoArraysPass
This pass wraps LLVM's vanilla InstCombine, to hijack one of its
options. The goal of this hijack is to prevent InstCombine from
splitting and replacing accesses to arrays with GEPs and smaller
accesses.
2025-04-22 17:23:37 +02:00
Pietro Fezzardi ef2c3a7626 Add SROANoArraysPass
This pass wraps LLVM's vanilla SROA, to hijack one of its options.
The goal of this hijack is to prevent SROA from splitting and replacing
memory accesses to arrays with GEPs and smaller accesses.
2025-04-22 17:19:56 +02:00
Pietro Fezzardi 3b10a3c5d9 Move SimplifyCFGWithHoistAndSinkPass to new file
This will be used to collect various customizations of LLVM passes, that
are necessary to enable setting different default options to passes for
insertion in the revng pipeline.
2025-04-22 17:18:26 +02:00
Ivan Krysak 79964eac74 Avoid ' misuse in error messages and comments 2025-04-17 16:41:21 +02:00
Ivan Krysak 514e6c56e0 ProgramCounterHandler: adopt helper registry 2025-04-17 11:19:17 +03:00
Ivan Krysak 48a7822923 FunctionTags: adopt helper registry 2025-04-17 11:19:17 +03:00
Ivan Krysak aa15d8ca21 Standardize abort-like function usage 2025-04-17 11:19:17 +03:00
Ivan Krysak a3c8ced826 getUniqueString: use hash for empty strings 2025-04-17 11:19:17 +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
Alessandro Di Federico c5c657d11b Lift: increase determinism 2025-04-15 15:31:10 +02:00
Giacomo Vercesi 042108bc44 ProgramRunner: cleanup
Clean up the `ProgramRunner` class:
* use llvm-provided wrappers and system-agnostic variables to compute
  the `Paths` variable
* pre-compute the list of path variables so it's not re-computed on
  every invocation of `run` or `isProgramAvailable`
* Wrap the logging code so that it's not triggered if the logger is
  disabled
2025-03-13 16:23:21 +01:00
Giacomo Vercesi 442020bf22 ProgramRunner: print exit code to logger
Print the exit code of the invoked program to the `program-runner`
logger.
2025-03-13 15:16:17 +01:00
Alessandro Di Federico cac8b5d1b1 ELFImporter: search libs in the input directory 2025-03-05 09:57:51 +01:00
Alessandro Di Federico d4cd9beb77 Minor changes 2025-03-05 09:57:51 +01:00
Ivan Krysak 705e4a5955 auto [...] -> auto &&[...] 2025-02-13 13:10:51 +02:00
Ivan Krysak ab1da1d986 FunctionTags: introduce Comment 2025-02-13 13:09:50 +02:00
Pietro Fezzardi e9528f4647 Fix getCopyType function type
This commit changes the prototype of getCopeType, so that it now takes 2
arguments.
1. The llvm::Type returned by the Copy function. This can be any scalar
   llvm::Type.
2. The llvm::type of the argument representing the reference to the
   value being copied. This should be a pointer-sized integer, where
   pointer-sized means with the same size of a pointer in the
   architecture in the input binary.

The second argument is not strictly necessary for now, because the whole
decompilation framework expects a binary with a single architecture,
hence a well defined unambiguous pointer size.
This will be used fully only when we start supporting multiple binaries.
Whenever that happens, if we haven't already fully dropped the Copy
helper function we will have to update the associated
OpaqueFunctionsPool to a type pair as key: the return type and the type
of the argument.
2025-01-29 15:17:15 +01:00
Alessandro Di Federico 2128a80cc8 Preserve metadata after Function::deleteBody
Also, introduce and adopt a simple helper class to get this right.
2025-01-28 12:19:16 +01:00
Andrea Gussoni fa69bd24e5 ScopeGraph: introduce the ScopeGraph
Introduce the `ScopeCloser` and `GotoTarget` annotations in the IR, and
the relative necessary machinery, needed to handle scope closer and goto
edges for the new backend.

A specialization of the `llvm::GraphTraits`, called `ScopeGraph`, that
is able to handle both the above mentioned annotations is provided.

For the `llvm::GraphTraits` implementation, we introduce the
`GeneratorIterator` class, which uses a coroutine to store the status of
the iteration.

A debug logger pass is added, so that we are able to test the
functionality with `FileCheck`.
2024-12-05 15:43:57 +01:00
Andrea Gussoni 023771f084 FunctionTags: correct typo
Correct `function-dispatcher` typo.
2024-12-04 11:22:00 +01:00
Alessandro Di Federico 6e733427bc emitMessage: fix function calle emission 2024-11-27 17:18:39 +01:00
Giacomo Vercesi 58b326b8fa ZstdStream: remove manual memory management
Remove the use of manual memory management, convert to the use of
`std::unique_ptr`.
2024-11-26 09:48:37 +01:00
Alessandro Di Federico 143c315196 Merge revng-c into revng 2024-11-21 10:50:55 +01:00
Alessandro Di Federico 2e4f4d09b9 Remaining FunctionTags have been moved to revng 2024-11-04 15:09:56 +01:00
Alessandro Di Federico e239e18b0c Adopt FunctionPoolTag 2024-11-04 15:09:56 +01:00
Alessandro Di Federico 800340d6e8 IRHelpers.cpp has been moved to revng 2024-11-04 15:09:56 +01:00
Alessandro Di Federico 2ed940dc3a FunctionTags have been moved to revng 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 05881c242a revngSupport: use default set of LLVM libraries 2024-10-31 17:19:51 +01:00
Alessandro Di Federico 16e01f43d6 Import revng-c's FunctionTags.h 2024-10-31 17:19:51 +01:00
Alessandro Di Federico d72f6413f0 Import revng-c's Support/IRHelpers.h 2024-10-31 17:19:51 +01:00
Giacomo Vercesi 3fc9bbf8fc Uniform GzipStream
Uniform the functions/classes in GzipStream with the ones in ZstdStream.
2024-10-30 21:57:55 +01:00
Giacomo Vercesi 5b200df81a Implement ZstdStream
Implement the `zstdCompress` and `zstdDecompress` functions. Also
implement the `ZstdCompressedOstream` which is a `llvm::raw_ostream`
which compresses data on the fly.
2024-10-30 21:57:55 +01:00
Alessandro Di Federico a0c670652c Improve usages of Expected<T> 2024-10-10 14:50:26 +02:00
Alessandro Di Federico 045f982a32 Improve usage of Expected<T> 2024-10-09 15:16:55 +02:00
Alessandro Di Federico 5db142237b lddtreeResolve: adopt consumeError 2024-10-04 15:20:06 +02:00
Giacomo Vercesi f8ffe38687 Unify cache directory logic
Make the cache directory logic uniform in Python and C++, move the
respective implementations under support since it's project-wide logic
and not exclusive to debug-info.
2024-10-01 13:38:13 +02:00
Alessandro Di Federico c1cbb4e9a0 Initialize pointers to nullptr 2024-09-27 12:07:17 +02:00
Alessandro Di Federico baa1bd612e Introduce recreateWithoutBody
Similar to moveToNewFunctionType, but doesn't move the BasicBlocks.
2024-09-27 12:07:16 +02:00
Alessandro Di Federico 5d0d4005c5 s/Ctxt?/Context/g 2024-09-27 10:35:10 +02:00
Alessandro Di Federico 9c99ac33ac s/serializeToLLVMString/toLLVMString/ 2024-09-27 10:35:10 +02:00
Alessandro Di Federico ca99bbbb66 Adopt toString() 2024-09-26 17:51:08 +02:00
Alessandro Di Federico 835a00d80c Minor changes 2024-09-25 10:00:22 +02:00
Alessandro Di Federico 5c9b6ed9b3 Rename DILogger into Log 2024-08-16 13:27:00 +02:00
Alessandro Di Federico 744184c90c Do not use CallBase::getCalledFunction
Use our wrapper, which does not return nullptr if the `FunctionType`s do
not match.
2024-08-07 16:07:59 +02:00
Alessandro Di Federico 0cb3eedd37 Do not use CallBase::getCalledFunction
Use our wrapper, which does not return nullptr if the `FunctionType`s do
not match.
2024-08-07 15:40:56 +02:00
Alessandro Di Federico 7b00473859 PDBImporter: rework .pdb search 2024-08-05 17:41:34 +02:00
Ivan Krysak 94a0ad6b93 Adopt reworked model::Type 2024-06-27 11:07:01 +02:00