Commit Graph

2366 Commits

Author SHA1 Message Date
Lauri Vasama 386efffb2f Convert TypeDefinitionAttr ID to UniqueHandle 2025-03-19 12:57:17 +02:00
Alessandro Di Federico c5b9728289 LocalVariableBuilder: add pointer size assumption
This commit further centralizes the creation of allocas + ptrtoint.  The
creation of these pair of instructions is problematic when the size of a
pointer in the input and target architecture differ.

In fact, in such cases, LLVM turns trunc into masking the integer to
suppresse the high bits. This results in problematic code.

This commit introduces an assumption that ensures LLVM does not do that.
2025-03-17 08:51:29 +01:00
Alessandro Di Federico 86f3dcf1ae Minor changes 2025-03-14 17:25:05 +01:00
Giacomo Vercesi a9a0fdc236 ELFImport: fix input file missing
When using revng through `revng daemon` the variable `InputPath` is not
populated, leading to `lddtree` failing silently. Fall back to the input
binary in the resume directory in case the the `InputPath` variable is
empty.
2025-03-14 13:05:39 +01:00
Giacomo Vercesi 87872f9fc5 PipelineManager: add save-after-every-analysis
Add a command-line option to pipeline that saves after every analysis is
run.
2025-03-13 18:03:50 +01:00
Giacomo Vercesi 74eba2954f revng trace run: log commands before execution
Log the commands that are going to be executed by `revng trace run` on
the `trace-runner` logger.
2025-03-13 16:23:21 +01:00
Giacomo Vercesi 41e2e0f73d RunTraceOptions: use doxygen comments
Change the struct field comments on the
`revng::tracing::RunTraceOptions` struct to doxygen comments.
2025-03-13 16:23:21 +01:00
Giacomo Vercesi 6eae722d5b tracing::Argument: make ArgumentState enum private
Move the `ArgumentState` enum to be a private member of the `Argument`
class, since no external users require using the enum.
2025-03-13 16:23:21 +01: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 72d9b46e4b Error.h: improve joinErrors
Change the `joinError` functions to have stronger guarantees when used:
* Change the template signature to `RangeOf` to ensure that the
  container has `llvm::Error`s.
* Check that the size of the passed container is actually positive
  before deferencing `.begin()`.
2025-03-13 15:07:25 +01:00
Andrea Gussoni 93f4a620dd DAGify: implement the DAGify pass
Implement the DAGify pass. This pass, using the results exposed by the
`GenericRegionInfo` analysis, transforms all the retreating edges of
each identified `GenericRegion`, processed in a bottom-up fashion, into
a `goto` edge on the `ScopeGraph`.
2025-03-11 12:26:36 +01:00
Andrea Gussoni 3499d10154 GenericRegion: remove retreatings edges
Remove retreating edges from the `GenericRegion` class, and the
collection of them in `GenericRegionInfo`.
2025-03-11 12:25:24 +01:00
Andrea Gussoni fe127200be GraphAlgorithms: improve comments 2025-03-11 12:25:24 +01:00
Andrea Gussoni ec8972cbed ScopeGraph: require pointer type for ScopeGraph 2025-03-11 12:25:23 +01:00
Andrea Gussoni ce6f9ddb69 ScopeGraph: do not assert when marker not present
Do not assert if the marker function is not present in the input IR, the
`Builder` instantiation takes care of its on-the-fly declaration
instantiation.
2025-03-11 09:28:04 +01:00
Ivan Krysak a094f32c4e Yield: fix node size calculation ignoring margins 2025-03-04 13:34:51 +02:00
Ivan Krysak bf6aa40e05 buildControlFlowGraph: improve error messages
A concept is going to lead to clear feedback as opposed to typical
SFINAE-adjacent construction error message.
2025-02-13 13:10:51 +02:00
Ivan Krysak 705e4a5955 auto [...] -> auto &&[...] 2025-02-13 13:10:51 +02:00
Ivan Krysak f494ae5f5f Standardize comment formatting
Use `*something*` instead of `_something_` when adding emphasis.
2025-02-13 13:09:50 +02:00
Ivan Krysak 492e5dc354 Yield: greatly simplify node size calculation 2025-02-13 13:09:50 +02:00
Ivan Krysak 99a8e28e3b PTMLCTypeBuilder: adopt CommentLineWidth 2025-02-13 13:09:50 +02:00
Ivan Krysak 6994395216 ModelConfiguration: introduce CommentLineWidth 2025-02-13 13:09:50 +02:00
Ivan Krysak 9082c500cb IndentedOstream: introduce currentIndentation() 2025-02-13 13:09:50 +02:00
Ivan Krysak fb95595b10 Backend: add comment emission support 2025-02-13 13:09:50 +02:00
Ivan Krysak 255bd256fe Backend: expose isStatement helper 2025-02-13 13:09:50 +02:00
Ivan Krysak ab1da1d986 FunctionTags: introduce Comment 2025-02-13 13:09:50 +02:00
Ivan Krysak d4ab801ab7 Rename range_with_value_type into RangeOf
Original name was reminiscent of the STL, but there's no such concept
in there, as such it's probably better to use revng naming convention
instead.
2025-02-13 13:09:50 +02:00
Ivan Krysak f5314e45d8 SortedVector: allow constexpr construction 2025-02-13 13:09:50 +02:00
Ivan Krysak 1c9b6a70db PTML: add statement comment support 2025-02-13 13:09:50 +02:00
Ivan Krysak a4550ce7e6 PTML: introduce comment placement helper 2025-02-13 13:09:50 +02:00
Ivan Krysak 08bd4ecca8 Model: introduce statement comment verification 2025-02-13 13:09:50 +02:00
Ivan Krysak 9564959871 Model: introduce statement comments 2025-02-13 13:09:50 +02:00
Ivan Krysak 9e48994c97 EFA: pass the block to the new nodes
Before this commit, only its index was passed.
2025-02-13 13:09:50 +02:00
Ivan Krysak 3b354f2590 TrackingContainer: allow comparisons with wrapped 2025-02-13 13:09:50 +02:00
Ivan Krysak 66688134bf MetaAddress: rework hashing 2025-02-13 13:09:50 +02:00
Ivan Krysak 8841bc7144 Don't include model::NameBuilder from the binary 2025-02-13 13:09:50 +02:00
Ivan Krysak 6c43cebc90 Model: let VerifyHelper depend on NameBuilder 2025-02-13 13:09:50 +02:00
Ivan Krysak 288448f009 Never include model::VerifyHelper from headers 2025-02-13 13:09:50 +02:00
Ivan Krysak 929cb4b35b Minor improvements 2025-02-13 13:09:50 +02:00
Ivan Krysak a93ffd3760 Rename UnusedStackArgumentBytes
Old name was `StackBytesAllocatedForRegisterArguments`.
2025-02-12 16:43:19 +02:00
Giacomo Vercesi a06b380ce0 S3StorageClient: implement parallel upload
Allow uploads to S3 to be executed in parallel, this should reduce the
time it takes for a `save` operation to conclude.
2025-02-06 12:21:23 +01:00
Giacomo Vercesi 761e84fc9f Add revng::cantFail
Add the `revng::cantFail` function which allows to wrap functions with
`std::error_code` and check their result. This is analogous to
`llvm::cantFail` for `llvm::Error`.
2025-02-05 10:46:00 +01:00
Lauri Vasama 6343bfcb40 Add c-verify pass 2025-01-30 14:52:47 +02:00
Lauri Vasama 998114501b Replace PlatformInfo with TargetCImplementation 2025-01-30 14:52:47 +02:00
Lauri Vasama 06d91d485d Factor visitation out of ModuleOp verify 2025-01-30 14:52:47 +02:00
Lauri Vasama fc203afb49 Remove unused CastOp purpose attribute 2025-01-29 23:58:24 +01:00
Pietro Fezzardi 189693140d Add LocalVariableBuilder 2025-01-29 15:17:15 +01:00
Pietro Fezzardi a9c16f8c79 Add helpers to manipulate model type metadata 2025-01-29 15:17:15 +01: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
Pietro Fezzardi 1d7cf58907 Support LoadInst in mayReadMemory 2025-01-29 15:17:15 +01:00