Commit Graph

550 Commits

Author SHA1 Message Date
Massimo Fioravanti ea02b4080a PipelineC: introduce rp_apply_model_diff
This exposes the invalidation to users of the C API.
2022-04-15 15:18:56 +02:00
Massimo Fioravanti 3d752f6c7f Introduce revng pipeline --invalidate-all 2022-04-15 15:18:28 +02:00
Massimo Fioravanti eef9ba74da Introduce ModelInvalidationEvent 2022-04-15 15:17:58 +02:00
Massimo Fioravanti 60fd53b1fb Introduce Kind::verify 2022-04-15 15:17:37 +02:00
Massimo Fioravanti df2413962b Introduce TupleTreePath::isPrefixOf(Other) 2022-04-15 15:16:02 +02:00
Massimo Fioravanti c4aa92694c Introduce revng model apply 2022-04-15 15:15:41 +02:00
Massimo Fioravanti 44720eedbd Redesign TupleTreeDiff
`TupleTreeDiff` is now type-safe and owns the changes.
2022-04-15 15:14:13 +02:00
Massimo Fioravanti 38a3c5a086 Introduce TupleTree::deserialize 2022-04-15 15:14:02 +02:00
Massimo Fioravanti a75eaae66a Introduce Logger::getAsLLVMStream 2022-04-15 15:13:43 +02:00
Pietro Fezzardi 7f65b1117a New AddPrimitiveTypesPipe
This pipe is executed during the Lift step and populates the model with
all the required primitive types.
2022-04-12 16:40:27 +02:00
Pietro Fezzardi 6b2b2e8ada Make model::Type::edges() method const 2022-04-08 18:58:58 +02:00
Pietro Fezzardi dfb1bb9fd2 RawFunctionType.edges() uses StackArgumentsType 2022-04-08 18:58:58 +02:00
Pietro Fezzardi e40ded965f QualifiedType RawFunctionType.StackArgumentsType
The `StackArgumentsType` field of `RawFunctionType` was the only
cross-reference between `model::Type`s that did not use
`model::QualifiedType` but a naked `TupleTreeReference`.

Switching it to `QualifiedType` make all cross-references across
`model::Type`s homogeneous.
2022-04-08 18:58:58 +02:00
Pietro Fezzardi 63a6676551 Make EnumType.UnderlyingType a QualifiedType
This was one of the few places left in the type system where a
`model::Type` referred to another one not using QualifiedType, but a
naked `TupleTreeReference`.

Switching it to be a `model::QualifiedType` makes cross-references
between `model::Type`s more homogenenous, requiring less corner-cases
to handle for whoever manipulates types.
2022-04-08 18:58:58 +02:00
Giacomo Vercesi a2b5dbb1dc TupleTreeGenerator: autogenerate Kind 2022-04-08 17:36:59 +02:00
Giacomo Vercesi 457d782ea8 UpcastablePointer::YAMLTraits: use Kind 2022-04-08 17:32:12 +02:00
Giacomo Vercesi a5e3606144 Introduce model::FunctionEdge::Kind 2022-04-08 17:31:40 +02:00
Giacomo Vercesi 039f7db93e model::*: ensure Kind -> Class correspondence 2022-04-08 17:31:05 +02:00
Antonio Frighetto 276d168e32 Introduce LoadFunctionMetadataPass
LoadFunctionMetadataPass lazily loads a `std::map` from isolated
function MetaAddress to `efa::FunctionMetadata`, and caches it.
2022-04-05 20:50:20 +02:00
Antonio Frighetto 9980fc8c67 EFA: support dynamic function calls
EarlyFunctionAnalysis now can handle calls to
dynamically linked functions.
2022-04-05 15:37:57 +02:00
Antonio Frighetto d6a1611c0a EFA: full ABI analysis or CFG collection only
EarlyFunctionAnalysis now can be invoked to schedule a full
ABI analysis over the collected functions via `--detect-abi`
option, or it can limit itself to simply recover the CFG and
serialize it onto the LLVM IR via `--collect-cfg` option.
2022-04-05 15:37:57 +02:00
Antonio Frighetto 20cdfe668a EFA: take the control-flow graph out of the model
The control-flow graph and all its hierarchy components
have been moved from `model` to `efa`. The CFG is now
serialized onto the LLVM IR module as a metadata.
2022-04-05 15:37:57 +02:00
Antonio Frighetto aae31a3a05 Introduce function entry-points collection passes
The collection of the function entry-points has now been separated
from EarlyFunctionAnalysis into two distinct passes: the first one,
which collects functions which are in call-sites of a direct call,
and the second one which collects code pointers in `.rodata` (e.g.,
function pointers, vtables; jump-tables are possibly skipped).
2022-04-05 15:37:57 +02:00
Antonio Frighetto 5848063b66 TupleTree: make const TupleTree& behave as such
A logic issue was addressed with improved state management.
2022-04-05 15:37:57 +02:00
Antonio Frighetto 7ad5772c55 Move revng/ABIAnalyses/Common.h in EFA 2022-04-05 15:37:57 +02:00
Antonio Frighetto 93cc2a5356 Drop Dump/CollectCFG.cpp
Unmaintained code has been removed.
2022-04-05 15:37:56 +02:00
Alessandro Di Federico f6c9b04c81 Adopt clang-tidy: readability-identifier-naming 2022-04-04 21:15:52 +02:00
Alessandro Di Federico 1a2a729e92 Rework FunctionTags::Tag 2022-03-31 12:51:24 +02:00
Alessandro Di Federico 30febba0ab mv revng/{Pipeline,Support}/DynamicHierarchy.h 2022-03-31 12:50:12 +02:00
Pietro Fezzardi de033b50f2 RegisterLLVMPass.h: add missing include
Missing `#include "revng/Pipeline/Loader.h"` causes compilation error
when calling `Loader.registerLLVMPass<LLVMPass>(Name);`.

This is a problem since whoever includes `RegisterLLVMPass.h` should
include `Loader.h` **before** `RegisterLLVMPass.h` to compile without
errors. This is subject to breakage if `Loader.h` ever changes name and
`clang-format` starts reordering the include **after**
`RegisterLLVMPass.h`.

This commit inlcudes `Loader.h` directly in `RegisterLLVMPass.h` to fix
the root cause.
2022-03-30 19:42:22 +02:00
Pietro Fezzardi 32cf3fc3cf OpaqueFunctionsPool: remove redundant LLVMContext 2022-03-30 17:21:48 +02:00
Pietro Fezzardi 838c5f7319 Load type-based OpaqueFunctionsPool from Module
This commit adds two method for OpaqueFunctionsPool that use
a pointer to `llvm::Type` (or a class derived from `llvm::Type`) as key.

Both methods are used to initialize the pool with pre-existing functions
inside an `llvm::Module` that match a specific `FunctionTags::Tag`:
- `initializeFromReturnType` uses the return `llvm::Type` of the
  function as key in the pool
- `initializeFromNthArgType` takes an additional argument which is an
  index N, and uses the return `llvm::Type` of the N-th argument as a
  key in the pool

These methods are useful for avoiding unnecessary proliferation of
opaque functions in an `llvm::Module`, re-using the existing ones
instead if they are already present.
2022-03-30 17:21:48 +02:00
Pietro Fezzardi b27432fcbd Move NotVoid and DerivesFrom to ADT/Concepts.h
since they can be useful elsewhere.
2022-03-30 17:11:40 +02:00
Pietro Fezzardi b4c733ab57 Move Concepts.h into include/ADT for better reuse 2022-03-30 17:09:24 +02:00
Ivan Krysak 59b5d3dce4 Add runtime ABI trait access 2022-03-28 15:43:34 +02:00
Ivan Krysak a10415fd0b Make the function layout argument type aware 2022-03-28 15:43:34 +02:00
Ivan Krysak 1b03adca5e Make function type convertions self-sufficient 2022-03-28 15:38:04 +02:00
Ivan Krysak 20bb0a2b90 Fix some minor abi::FunctionType issues 2022-03-28 15:37:59 +02:00
Ivan Krysak 5108c3e50f Introduce ABI-based register sorting 2022-03-28 15:37:55 +02:00
Ivan Krysak fbc59747bc STLExtras.h: introduce append 2022-03-28 15:37:02 +02:00
Ivan Krysak a77f648775 Introduce std::ranges::{,sized_}range 2022-03-28 15:36:51 +02:00
Ivan Krysak 522b760a12 Fix a problem with SystemV_x86_64 abi::Trait 2022-03-28 15:34:42 +02:00
Ivan Krysak 326624f517 Fix TupleTreeCompatible linkage problem
Now all the generated `.cpp` include `Binary.h`. This ensures we don't
trigger the wrong concept due to forward declarations.

Also, this commit introduces a couple of `static_assert`s which should
enable us to early identification of similar problems.
2022-03-28 15:33:30 +02:00
Ivan Krysak c6370816f7 Drop the abi::revng namespace 2022-03-28 15:32:06 +02:00
Massimo Fioravanti ce4934f48d Introduce revng-link-for-translation
`revng-link-for-translation` provides a standalone tool needed to
perform the final linking stage of the recompilation.
2022-03-28 12:17:05 +02:00
Massimo Fioravanti f63eefba2c Move LinkForTranslationPipe to lib/Recompile 2022-03-28 12:17:05 +02:00
Massimo Fioravanti c05b5dbb28 Steps now represent the *end* of a step
A special "begin" step has been introduced.
2022-03-28 12:17:05 +02:00
Massimo Fioravanti b362d926ec pipeline: drop implicit rank 0 2022-03-28 12:17:05 +02:00
Massimo Fioravanti d617533563 PipelineC: remove redundant documentation 2022-03-28 12:17:05 +02:00
Massimo Fioravanti c1d97bf8b3 pipeline: make globals serializable 2022-03-28 12:17:05 +02:00