Commit Graph

3168 Commits

Author SHA1 Message Date
Pietro Fezzardi 8c4784d076 DLA: split collapsing of SCC into many DLASteps
Before this commit there was a single pass removing equality SCC and
inheritance SCC.
This commit splits the removal of each kind of SCC in a separate
DLAStep, and adds handling of instance-at-offset-0 SCCs that were not
considered before.
2022-03-21 11:19:18 +01:00
Pietro Fezzardi 651ebe4cb6 Add LayoutTypeSystem::verifyInstanceAtOffset0DAG()
This new verification method is propedeutic to switching off Inheritance
nodes entirely.
2022-03-21 11:19:18 +01:00
Pietro Fezzardi e78e780a73 dla::LayoutTypeSystem: fix node style in dot 2022-03-21 10:46:25 +01:00
Pietro Fezzardi c98794d9b0 Rework DLAMakeModelTypes to fix several bugs
Before this commit, DLAMakeModelTypes was generating broken types in
several corner cases involving unions with children at offset different
than zero, and strided accesses.

This commit fixes these issues and reworks the pass to also consider
strides and model::Qualifiers in the correct order.
2022-03-21 09:48:26 +01:00
Pietro Fezzardi d6ae6fd650 Add dla::Step RemoveInvalidStrideEdges 2022-03-21 09:43:10 +01:00
Pietro Fezzardi c3cf053b58 DLAMakeLayouts: fix order of strides 2022-03-21 09:40:31 +01:00
Pietro Fezzardi 0f00d29464 DLA: assert stride nesting in FieldSizeComputation 2022-03-21 09:38:25 +01:00
Pietro Fezzardi 782a67eb9c DLA: sort strides on Instance edges.
Nested SCEVAddRecs are not guaranteed to have strides that go from
larger to smaller. Both cases are valid and can convey interesting
information to DLA. But DLA assumes that the outermost strides are
always larger than the innermost, because this is the only scenario
allowed by well-nested types.

This commit re-orders the strides (and the associated trip counts) so
that they always go from larger to smaller sizes.
2022-03-21 09:36:13 +01:00
Pietro Fezzardi 44b6fd2970 DLAPass: fix runOnModule return value.
Now the method returns true only if there have been changes.
2022-03-18 16:49:29 +01:00
Pietro Fezzardi ed4942a8b0 DLAMakeModelTypes.cpp: assert verifyPointerDAG 2022-03-18 16:49:28 +01:00
Pietro Fezzardi 6d91546816 LayoutTypeSystem: add verifyPointerDAG method 2022-03-18 12:38:25 +01:00
Pietro Fezzardi 901c6e76ca lib/DataLayoutAnalysis/Backend: drop public using 2022-03-18 12:38:25 +01:00
Alessandro Di Federico 1dcce82dfc Adopt cmake-format 2022-03-18 12:32:44 +01:00
Alvise de Faveri 97e3512bd7 ModelGEP: Use revng helpers for logging 2022-03-17 20:52:31 +01:00
Alessandro Di Federico 2b55d1df22 Adopt cmake-format 2022-03-17 18:52:18 +01:00
Giacomo Vercesi e237ee75b0 Add custom traceback support 2022-03-17 18:33:59 +01:00
Pietro Fezzardi c41ca3a451 New revng helpers for Qualifier and QualifiedType 2022-03-17 17:15:50 +01:00
Pietro Fezzardi 4cead8e21e ModelTypeNames.cpp: fix order of qualifiers 2022-03-17 17:15:50 +01:00
Pietro Fezzardi fb54cc22a2 QualifiedType: new typedef-aware helper methods
This commit reworks the helper methods for model::QualifiedType, to
properly traverse typedefs.

These methods are used to check if a QualifiedType is:
- scalar
- primitive
- float
- void
- pointer
- array

This commit add the methods for checking pointers and arrays (that
weren't available before), reworks all the helpers so that they all
traverse typedefs, and adds comments so that it's clear that they
traverse typedefs.
2022-03-17 17:03:28 +01:00
Pietro Fezzardi 630fee4500 model::Qualifier: add static methods for filtering
This commit adds the static methods:
- model::Qualifier::isConst
- model::Qualifier::isArray
- model::Qualifier::isPointer

These methods replace the old, non-static, methods:
- model::Qualifier::isConst
- model::Qualifier::isArray
- model::Qualifier::isPointer

Having these method static is very helpful for filtering, when
iterating on sequences of qualifiers, such as:

  for (const auto &Q :
       llvm::make_filter_range(Qualifiers, Qualifier::isPointer)) {
    // do stuff with Q
  }

This will be very helpful for defining other helper functions for
model::QualifiedType.

This commit also drops the non-static version of the methods, since they
are redundant, and because they would cause ambiguity and failure of
type inference in the snippet above, making them effectively useless for
the goal they were designed for, which is filtering ranges.
2022-03-17 17:03:22 +01:00
Pietro Fezzardi 0158354dc7 DwarfImporter: fix order of Qualifiers
Before this commit the DwarfImporter was importing qualifiers in
reverse order.

As an example the following declaration in C:

  int *x[4];

was imported as a pointer to array, instead of an array of pointers.

This commit fixes the order of the qualifiers.
2022-03-17 17:02:48 +01:00
Alessandro Di Federico 00ce580362 Introduce EnforceABI and PromoteCSV pipes 2022-03-17 14:10:50 +01:00
Alessandro Di Federico 9fb3b647a4 Introduce DropRootPass 2022-03-17 14:10:50 +01:00
Alessandro Di Federico fa3206b26d Rename Lifted tag to Isolated 2022-03-17 14:10:50 +01:00
Alessandro Di Federico ea6383c476 mv {d,registerD}efaultFunctionPrototype 2022-03-17 14:10:50 +01:00
Alessandro Di Federico da7701bd4e Move all executables except revng to libexec/revng
We used to collect all binaries into the `bin/` directory. However this
led to confusions since certain commands where available both as
`revng-command` and `revng command`.

This commit moves all the executables except `revng` into
`libexec/revng`, which, according to FHS, is dedicated to "internal
binaries that are not intended to be executed directly by users or shell
scripts".
2022-03-17 14:10:50 +01:00
Alessandro Di Federico 77335d036a Rename Lifted tag to Isolated 2022-03-17 14:08:05 +01:00
Alessandro Di Federico 997e7f60cb scripts/renvg: handle revng pipeline
Let `scripts/revng` intercept `revng-pipeline` invocations and add, not
only -load, but `-P` (pipelines) too.
2022-03-16 22:10:15 +01:00
Alessandro Di Federico bc8e6a6a24 Minor changes 2022-03-16 22:10:15 +01:00
Pietro Fezzardi 35cd9bbf4a Drop function decompilation API
The only user of the API was caliban, which is now officially
unsupported.
2022-03-16 16:57:05 +01:00
Alessandro Di Federico 7d48059800 Turn revng-lift into a script 2022-03-11 15:37:12 +01:00
Alessandro Di Federico 0793e4afcb Turn lifting into a pass 2022-03-11 15:37:12 +01:00
Alessandro Di Federico 5e38805063 Rename detail namespaces into revng::detail 2022-03-11 15:37:12 +01:00
Pietro Fezzardi ff0a1b8eab DLADeduplicateUnionFields.cpp: fix linkOrderLess
The linkOrderLess comparison function is used for sorting the children
edges of a node.

Before this commit, it could not handle the case of comparing an edge
with itself, yielding wrong results (or assertion failure if assertions
were compiled in).

This commit fixes linkOrderLess to handle that case without asserting,
and adds an early return for it, without requiring to inspect the edges
in depth.
2022-03-10 18:00:05 +01:00
Alessandro Di Federico 5d197bff15 Adopt API changes in the model 2022-03-10 17:59:05 +01:00
Pietro Fezzardi a8da5e14ec DLA: enable union dedup w/o CollapseSingleChild
DeduplicateUnionFields does not depend on CollapseSingleChild, but can
break if CollapseSingleChild has not run.
However, we don't want to introduce an explicit dependency between the
two steps, because CollapseSingleChild could soon become obsolete on
its own, superseeded by a more powerful and costly step.

This commit changes DeduplicateUnionFields with an additional
pre-processing that runs CollapseSingleChild on each node at step one,
to ensure the step does not fail if CollapseSingleChild child is not
executed.
2022-03-10 12:21:01 +01:00
Pietro Fezzardi acef606a73 DLATypeSystem.cpp: improve error reporting 2022-03-08 17:21:24 +01:00
Pietro Fezzardi 8e3b1c0080 DLACollapseSingleChild: preserve InterferingInfo 2022-03-08 17:21:08 +01:00
Pietro Fezzardi 3546eda055 DLATypeSystem.cpp: improve .dot for Instance edges 2022-03-08 17:20:49 +01:00
Pietro Fezzardi 9a6a0369e7 DLADeduplicateUnionFields.cpp: fix log 2022-03-08 17:20:32 +01:00
Alessandro Di Federico ee0b8f44c1 Introduce BinaryImporter
This is a big step to split revng-lift in two parts: one that only
writes the model and one that actually lifts to LLVM IR.

* Introduce `revng import binary`
* Split off `BinaryFile.h`
* Drop `revng.h`
* `GeneratedCodeBasicInfo`: use model
* Reduce role of `GeneratedCodeBasicInfo` in favor of
  `model::Architecture` and `model::Register` methods
* `CodeGenerator`: adopt `RawBinaryView` and model
* `JumpTargetManager`: adopt `RawBinaryView` and model
* `ExternalJumpsHandler`: adopt model
* `InstructionTranslator`: discard `Architecture` in favor of
  `EndianessMismatch`
* Many other changes
2022-03-08 15:15:24 +01:00
Alessandro Di Federico e9b1879067 Handle invalid model::DynamicFunction::Prototype 2022-03-08 15:04:34 +01:00
Alessandro Di Federico ad7e6d9388 EFA: always perform stack adjustment 2022-03-08 15:04:34 +01:00
Alessandro Di Federico 60cce26768 Support streaming llvm::Errors to Loggers 2022-03-08 15:04:34 +01:00
Alessandro Di Federico 0a5d2c04a7 Rework LoadModelPass 2022-03-08 15:04:34 +01:00
Alessandro Di Federico 1a57229693 Introduce model::Binary::DefaultPrototype 2022-03-08 15:04:34 +01:00
Alessandro Di Federico a88a9e52c3 Improve model::Segment 2022-03-08 13:06:47 +01:00
Alessandro Di Federico 97f0941aee Introduce model::Section 2022-03-08 12:26:07 +01:00
Alessandro Di Federico 8570923d64 Introduce model::Relocation 2022-03-08 12:25:59 +01:00
Alessandro Di Federico 39ace7dc56 mv revng{DwarfImporter,ModelImporterDwarf} 2022-03-08 12:25:47 +01:00