Commit Graph

2366 Commits

Author SHA1 Message Date
Alessandro Di Federico cfb47157b9 clang-tidy: readability-identifier-naming
This commit fixes all the non-compliance with our preliminary clang-tidy
configuration, which will be merged soon.
2022-01-07 09:18:05 +01:00
Massimo Fioravanti bdcc1d2e30 BinaryFile::BinaryFile: accept object::Binary
The constructor now accepts a llvm::object::Binary directly rather than
a path. Will be used by the revng-pipeline which will retain ownership
of the binary.
2022-01-05 14:47:25 +01:00
Massimo Fioravanti 889b076828 AdvancedValueInfo: fix wrong NDEBUG check
A extra check was performed in release only rather than in debug only.
2022-01-05 14:47:25 +01:00
Massimo Fioravanti ec0fcfbe63 Model: separate mipsel from mips 2022-01-05 14:47:25 +01:00
Massimo Fioravanti fdfeb2b6e9 LoadModelPass: support for external model 2022-01-05 14:45:01 +01:00
Massimo Fioravanti 79d5ca1e27 Introduce FunctionTags::IsolatedRoot
This will be used by the revng-pipeline to tell apart a `root` calling
isolated functions from a regular one.
2022-01-05 14:45:01 +01:00
Massimo Fioravanti ca4c7e2c09 Add dereferenceIterator and mapToValueIterator
A dereference iterator is used to map a pointer-like object to the
pointee, as an example given a `vector<unique_ptr<int>> Vector`, using
`dereferenceRange(Vector)` will present a range of `int &` rather than a
range of `unique_ptr<int> &`.

mapToValueIterator can be used  on a map range
to access the underlying object directly rather
than the pair<key, object>.
2022-01-05 14:45:01 +01:00
Massimo Fioravanti 80c3121c29 Introduce ProgramRunner
The ProgramRunner will be used by revng-pipeline to invoke the external
linker to operate on object file stored on disk.
2022-01-05 14:45:01 +01:00
Massimo Fioravanti ac20314a92 Helpers to go from llvm:: to model::Function 2022-01-05 14:45:01 +01:00
Alessandro Di Federico d78993ac54 Add TupleTree file (de)serialization
Tuple tree file serialization will be used by the revng-pipeline as a
helper function to load and store the models in the working directory.
2022-01-05 14:44:57 +01:00
Pietro Fezzardi 2f524114e8 RecursiveCoroutine: add operator* for ergonomics
This allows e.g. the following programming pattern:

```
RecursiveCoroutine<std::optional<SomeType>> f();

int g() {
  return *f();
}
```

Without operator* defined for `RecursiveCoroutine` this would fail,
requiring an explicit cast such as:

```
int g() {
  return *static_cast<std::optional<SomeType>>(f());
}
```
2022-01-05 14:37:37 +01:00
Pietro Fezzardi ff4f91a570 Model/Type.h: explicit constructors from uint64_t 2022-01-05 13:33:52 +01:00
Pietro Fezzardi e37425c686 TupleTreeReference: add getConst() method 2022-01-05 13:33:52 +01:00
Pietro Fezzardi 0e1402adfc Fix is_specialization<const X<T>, X>
Before this commit `is_specialization<const X<T>, X>` was not
specialized, so that `const X<T>` did not count as a specialization of
`X`. This resulted in bad selection of template specialization based on
concepts that were using `is_specialization_v`, such as
`IsUpcastablePointer`.

This commit fixes the problem, so that now the concept
`IsUpcastablePointer` is true for `const UpcastablePointer<T>` as well.

This also enabled to remove some workarounds for the `IsMutableSet` and
`IsSortedVector` concepts, and treat them uniformly with other concepts
that were using `is_specialization_v`.
2022-01-05 13:33:52 +01:00
Pietro Fezzardi 275959618f TupleTree: make Root a std::variant<T *, const T*>
This enables holding TupleTreeReferences to immutable model objects
2022-01-05 13:33:52 +01:00
Pietro Fezzardi 69715dafed TupleTreePath: add empty() method 2022-01-05 13:33:52 +01:00
Pietro Fezzardi c338e79de7 Extend TupleTreeCompatible concept
Before this commit, it was only matched by types that satisfied the
constraint `IsUpcastablePointer`, which is too strict.
Now also types that match `UpcastablePointerLike` satisfy the
constraints for this concept.
2022-01-05 13:33:40 +01:00
Pietro Fezzardi 818156e06a DLA upgrades stack's and stack arguments' types 2022-01-04 16:21:07 +01:00
Alessandro Di Federico 8c0b918ace s/DebugHelper.*/IRAnnotators.*/ 2021-12-22 17:47:54 +01:00
Alessandro Di Federico 88dbc39f29 Reorganize LLVM IR debug annotations emission 2021-12-22 17:47:54 +01:00
Alessandro Di Federico 6073133545 CodeGenerator: drop IR emission duties 2021-12-22 17:47:54 +01:00
Alessandro Di Federico 4d7a175996 Extract TupleTree 2021-12-22 17:47:54 +01:00
Alessandro Di Federico 777adcbd45 model::Binary: add segments and imported libraries
Now, `scripts/revng` uses the model and we no longer need to emit
.li.csv and .need.csv.
2021-12-22 17:47:54 +01:00
Pietro Fezzardi decbbc56df Merge librevngcUtils into librevngcSupport 2021-12-22 17:46:45 +01:00
Alessandro Di Federico 5a28bfedea Move SegmentInfo::generateName to BinaryFile.cpp 2021-12-22 13:47:21 +01:00
Alessandro Di Federico 455bf10648 Specialize KeyedObjectTraits for std::string 2021-12-22 13:47:21 +01:00
Alessandro Di Federico 57ae7613e1 Drop obsolete debug files
This commit drops the generation of `.coverage.csv` and `.bbsummary.csv`
files. No one really uses them anymore.
2021-12-22 13:47:21 +01:00
Massimo Fioravanti 9e477d0ada Make a library out of revng-lift 2021-12-22 13:47:21 +01:00
Alessandro Di Federico 7c050ee377 mv include/revng/{TypeShrinking,MFP}/SetLattices.h 2021-12-17 18:51:06 +01:00
Alessandro Di Federico 3e1e69e08f Introduce eraseFromParent 2021-12-17 18:50:08 +01:00
Alessandro Di Federico ddfa9ae767 getPointeeSize: assert bit size is divisible by 8 2021-12-17 18:49:59 +01:00
Alessandro Di Federico a2364bc6a0 GeneratedCodeBasicInfo: parse root lazily
This commit makes sure that GeneratedCodeBasicInfo can be used even in
absence of the `root`.

This also ensure that no time is wasted on brief/focused pipelines that
do not care about analyzing each basic block in the `root` function.
2021-12-17 18:49:42 +01:00
Alessandro Di Federico e113cb579e Introduce revng/Model/IRHelpers.h 2021-12-17 18:49:34 +01:00
Alessandro Di Federico 04633a21ca Tag call sites with CallToLifted 2021-12-17 18:49:26 +01:00
Alessandro Di Federico ec0e88351d model::Function: make CFG the last field 2021-12-17 18:49:17 +01:00
Alessandro Di Federico 9b05bfd2ba StackAnalysis: record FinalStackOffset 2021-12-17 18:49:09 +01:00
Alessandro Di Federico 9a60a5fd82 Expand IRHelpers
* New `getCallTo` overloads accepting `Function *`
* `setInsertPointToFirstNonAlloca`
* Various additional helpers for Load/StoreInst
* `changeFunctionType`
2021-12-17 18:48:36 +01:00
Alessandro Di Federico f38cc9ea06 Drop AdjustStackPointer 2021-12-17 14:01:22 +01:00
Alessandro Di Federico 24f5515842 Import passes of the new stack promotion pipeline 2021-12-17 14:01:00 +01:00
Alessandro Di Federico 58f114f19f Introduce libSupport 2021-12-17 14:00:05 +01:00
Alessandro Di Federico 1dbe474873 Whitespace fixes 2021-12-16 11:56:06 +01:00
Antonio Frighetto 10f45c593a Move StackAnalysis to EarlyFunctionAnalysis 2021-12-15 18:03:30 +01:00
Antonio Frighetto ffd5ac7f57 Drop old StackAnalysis 2021-12-15 18:03:30 +01:00
Antonio Frighetto 35311dcf14 Integrate EarlyFunctionAnalysis with ABIAnalyses
Integrate results of ABIAnalyses in EarlyFunctionAnalysis
and refine such results by suppressing stack pointer
and callee-saved registers from the analyses.
2021-12-15 18:03:30 +01:00
Qian Matteo Chen 886e58553b Introduce new ABIAnalyses
Architecture-agnostic and ABI-independent data-flow analyses that
traverse the recovered functions in order to detect arguments and
return values registers.
2021-12-15 18:03:30 +01:00
Antonio Frighetto 74a35bca10 Introduce new EarlyFunctionAnalysis
An architecture-agnostic analysis that attempts to detect
boundaries of functions, recover the control-flow graph as
well as function prototypes (arguments and return values)
of the original program. The analysis determines whether
the function jumps to its return address (namely, it is a
regular function), it tracks the evolution of the stack
by determining its height (in order to say if the stack is
left in a correct position upon stackframe destruction),
and it identifies callee-saved registers.
2021-12-15 18:03:30 +01:00
Antonio Frighetto a574f3c8e3 Introduce AAWriterPass
A simple pass that adds aliasing scope information as
comments to the IR before load and store accesses.
2021-12-15 18:03:30 +01:00
Antonio Frighetto 14f0e9ed09 Introduce IndirectBranchInfoPrinterPass
A simple pass that serializes the results of the StackAnalysis on disk.
2021-12-15 18:03:30 +01:00
Antonio Frighetto 4ed08d1e94 Introduce SegregateDirectStackAccessesPass
A pass which segregates direct stack accesses from all other
memory accesses through appropriate alias information metadata.
By doing so, we provide a way to say that stack accesses reasonably
do not interfere with any other memory access. This pass also tries
to canonicalize `inttoptr` + `add` instructions into `getelementptr`s
so as to avoid the use of `inttoptr`, which would otherwise inhibit
compiler optimizations.
2021-12-15 18:03:30 +01:00
Antonio Frighetto 215dab9dd2 Introduce CSVAliasAnalysisPass
A pass that decorates memory accesses with
information about CSV aliasing.
2021-12-15 18:03:30 +01:00