Commit Graph

199 Commits

Author SHA1 Message Date
Alessandro Di Federico 3bb6c2e019 Make Pipe::checkPrecondition optional 2024-09-27 10:33:28 +02:00
Alessandro Di Federico 43bfcb6d7b Initialize pointers to nullptr 2024-09-27 10:33:27 +02:00
Alessandro Di Federico 274925268e s/serialize/toString/
We keep serialize for method dealing with streams.
If it returns a `std::string`, let's use `toString`.
2024-09-27 10:33:27 +02:00
Alessandro Di Federico a3755c2dd6 s/Context &Ctx/Context &Context/g 2024-09-27 10:33:27 +02:00
Alessandro Di Federico 606612de40 s/ExecutionContext &Ctx/ExecutionContext &EC/g 2024-09-27 10:33:27 +02:00
Alessandro Di Federico 112658748b EnforceABI: register all recreated functions
Before this change, we were remapping from old to new only functions
that have been requested. Now, we remap also those that are just called.
2024-09-27 10:33:27 +02:00
Alessandro Di Federico a87c7a3d21 Ensure every pipe commits what it should
This commit is the final step in ensuring all the pipes commit what they
should. It also asserts this actually happens, enabling us to easily
catch future problems.
2024-09-27 10:33:26 +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 ae7e7a0bc7 IsolateFunctions: add tracing 2024-08-07 16:07:59 +02:00
Alessandro Di Federico ee2d2e25c6 InlineHelpers: add tracing 2024-08-07 16:07:59 +02:00
Alessandro Di Federico fa6249edc0 Isolate: add FunctionTag to declared functions 2024-08-05 17:42:04 +02:00
Ivan Krysak 4a2db0ba4f UpcastablePointer: streamline empty behavior 2024-06-27 11:05:52 +02:00
Ivan Krysak f3c020ffb3 EnforceABI: ensure every function has a prototype 2024-06-27 11:05:51 +02:00
Ivan Krysak dfa7478685 Adopt reworked model::Type 2024-06-27 11:05:51 +02:00
Ivan Krysak 927e8006b9 Model: rename TypePath to DefinitionReference 2024-06-27 11:05:49 +02:00
Ivan Krysak ac587cbb4f Model: rename Type into TypeDefinition 2024-06-27 11:05:48 +02:00
Ivan Krysak 84c8822c37 Model: drop TypedRegister 2024-06-27 11:05:48 +02:00
Alessandro Di Federico 3e8764093e RawFunctionType return type: adopt literal struct 2024-06-20 10:24:51 +02:00
Alessandro Di Federico b62bc8df91 s/FunctionMetadata/ControlFlowGraph/g 2024-06-20 10:24:51 +02:00
Alessandro Di Federico c3733f293a s/RevngPasses/FunctionPass/g 2024-06-20 10:24:51 +02:00
Alessandro Di Federico 148e6b1979 Rename all LLVMContainer arguments 2024-06-20 10:24:51 +02:00
Alessandro Di Federico bce1d6c0f3 Adopt invalidation along the core pipeline 2024-06-20 10:24:50 +02:00
Alessandro Di Federico 6cff5416d6 InvokeIsolatedFunctions should add IsolatedRoot
Before this commit, it was added by `IsolateFunctions` instead.
2024-06-20 10:24:50 +02:00
Alessandro Di Federico 7553e2acf8 Introduce UniquedBy{Prototype,Metadata}
This commit introduces new tags to specify how LLVMContainer should
deduplicate sets of equivalent functions, typically managed by an
`OpaqueFunctionPool`.
2024-06-20 10:24:50 +02:00
Alessandro Di Federico a6cf3fbb83 Centralize computation of llvm::Function names
This commit introduces a function to obtain the name assigned to a
`llvm::Function` associated to a `model::Function`. This simplifies the
codebase but also enables us to introduce an option to produce
human-friendly names for debugging/testing purposes.
2024-06-20 10:24:49 +02:00
Alessandro Di Federico 3097e94a0d Enable fetching call site prototype without CFG
Before this commit, we used to attach to call site a metadata to trace
back the call site to the CFG (i.e., `FunctionMetadata`).

This led several passes in revng-c to depend on `FunctionMetadata` just
for this.

This commit, attaches to call sites a reference to the prototype itself
(on the `revng.prototype` metadata), breaking many of such dependencies.
2024-06-20 10:24:49 +02:00
Massimo Fioravanti db15f7df9a Propagate info about inputs and outputs of pipes
This comit propagates the deduced info about inputs and outputs of pipes
all the way up to the runner, so that the requested output of a pipe can
be passed to its invocation.
2024-06-20 10:24:49 +02:00
Lauri Vasama 185afcf4c0 Fix spelling of FunctionEntryMDName 2024-05-29 15:42:15 +02:00
Alessandro Di Federico 38ea8f5237 Handle calls to non-functions 2024-05-15 13:19:40 +02:00
Alessandro Di Federico 0459b9d084 Introduce RegisterUsageAnalyses 2024-04-19 18:33:00 +02:00
Pietro Fezzardi df3bd470a1 Enforce determinism on CSV handling
Various parts of revng replace `llvm::GlobalVariable`s representing CSVs
with Allocal/Load/Store. In particular, these are PromoteCSV,
RootAnalyzer and PromoteGlobalToLocalVars.

Before this commit, those places were sloppy when replacing CSVs with
Alloca/Load/Store, and did that iterating on a container sorted by
pointers. This caused Alloca/Load/Store to be emitted in different order
accross runs, which in turn caused more non-determinism down the
pipeline.

This commit fixes the non-deterministic behavior, sorting CSVs based on
their names, which should always be present and deterministic.
2024-03-19 09:43:59 +01:00
Ivan Krysak 6b7650276e EFA: split importModel into multiple methods 2024-03-18 19:32:34 +01:00
Ivan Krysak 9c9e642589 EnforceABI: stop using Layout 2024-03-18 19:32:34 +01:00
Alessandro Di Federico 4bca30df5d InlineHelpers: fix bug preventing inlining helpers 2024-02-09 10:04:18 +01:00
Alessandro Di Federico f997f85efd PromoteCSVs: always recreate allocas 2023-12-12 12:04:33 +01:00
Alessandro Di Federico 98f5304c54 InlineHelpers: do not inline recursive functions
Also, turn it into a ModulePass.
2023-12-12 12:04:33 +01:00
Alessandro Di Federico 0e7d3a9a71 Pass PlainMetaAddress by pointer 2023-12-12 10:20:51 +01:00
Alessandro Di Federico 2e283fdf2a raise_exception_helper -> _abort and _unreachable 2023-12-12 10:20:35 +01:00
Alessandro Di Federico 28a0fa5b7d DetectABI: run to fixed point and more
This commit switches the approach with which we run the ABI analyses: we
now run them until we reach a fixed point. This enables proper
interprocedural propagation of arguments and return values.

Basically, we now inject reads before call sites, so that, if a function
immediately calls another one, the arguments of the callee are
propagated to the caller.

This commit also updates the logic with which we propagate function
prototypes (and names) to callers. The main advantage of this, is that
function wrappers (in particular, PLT entries) now have the same name as
the function they wrap.
2023-12-12 10:05:22 +01:00
Alessandro Di Federico c1bf5562e3 PromoteCSVs: use CSV initializer for non-GPRs
This commit drops calls to `_init_$CPU_STATE` for non-general purpose
registers. Instead, these part of the CPU state are initialized using
the initializer of the CSV, which is in turn provided by QEMU.

This enables us to properly initialize as appropriate fields such as
x86-64's DF flag.
2023-10-24 09:49:05 +02:00
Alessandro Di Federico bf66ecc389 {,Dynamic}Function::Prototype: support typedefs 2023-10-05 10:19:44 +02:00
Djordje Todorovic 2760599483 Add StripDebugInfoFromHelpers Pass
During this phase (EnforceABI) the binary is not meant to be run
so the debug info is not useful anymore, so we are striping them
now in order to avoid taking care of them during the pipeline.
2023-09-21 08:05:48 +02:00
Alessandro Di Federico a5b380b201 Model: rework how we name things
This commit improves the formalization of how we handle names.

The main changes are:

* Now `_` is a reserved prefix and all the generated names start with
  `_`.
* The model verification routine now checks that `CustomName`s in the
  global scope do not collide with any local namespace (e.g., fields of
  a `StructType`).
* We changed the prefix `prefix_` to `unreserved_` to better convey the
  fact that the prefix has been introduce to use an non-reserved name.
2023-08-23 16:14:04 +02:00
Pietro Fezzardi 8683e889db EnforceABI: copy attributes on function calls
Before this commit, we were blinding adding the `nomerge` attribute to
function calls. Now we copy attributes over, so we preserve all the
attributes.

In this way the only place where we add the `nomerge` attribute becomes
Isolate.
2023-07-20 20:30:46 +02:00
Pietro Fezzardi 53bc3ebc17 Isolate: add nomerge attribute to DynamicFunctions 2023-07-20 20:30:45 +02:00
Ivan Krysak 7d235f4fd0 Enforce licence header consistency
Also do some basic cleanup: capitalize first letters, add `.`
at the end of the sentences, and so on.
2023-07-03 15:23:10 +00:00
Ivan Krysak 9f1d9fd5d0 Use Container::contains() where appropriate 2023-07-02 15:06:11 +00:00
Ivan Krysak bc98e0079f Formatting: change PenaltyReturnTypeOnItsOwnLine
The new value is 21.
2023-07-02 13:20:49 +02:00
Alessandro Di Federico 56d43ff089 Isolate/Enforce: add nomerge to calls
Isolated functions already have the `nomerge` attribute, but calls do
not.  This is important in presence of indirect calls.
2023-06-30 16:54:01 +02:00
Giacomo Vercesi 31cd2b53f9 rcc: add codespell
Add codespell to the list of checks performed by
revng-check-conventions. This should reduce the amount of typos present
in the revng codebase.
2023-05-11 10:05:32 +02:00