Commit Graph

6113 Commits

Author SHA1 Message Date
Pietro Fezzardi f69f68fe35 DLA: dump .dot for debug in dla::StepManager
Before this commit, each dla::Step handled the printing of its own .dot
files for debug.
This commit moves the logic for dumping the .dot files into the main
loop of dla::StepManager, guarding it with a single Logger.
2022-03-22 10:48:03 +01:00
Pietro Fezzardi 9f1bbc8b49 Drop deprecated \brief Doxygen directive
\brief is a stupid feature that we should stop using:
https://lists.llvm.org/pipermail/llvm-dev/2015-May/085152.html
2022-03-22 10:48:03 +01:00
Pietro Fezzardi 68e1a5cdea Test headers and decompilation w/ canonicalized IR
Before this commit, the tests for model_to_header, helpers_to_header and
their recompilation tests were based on the IR from prepared.bc, that
did not contain DLA results, making these tests not very useful nor
future-proof.

This commit switches those test to use LLVM IR after IRCanonicalization
2022-03-22 08:34:11 +01:00
Pietro Fezzardi dcea204358 Merge feature/dla-remove-inheritance-edges 2022-03-21 17:27:39 +01:00
Pietro Fezzardi ed5f4ac3e9 RemoveInvalidStrideEdges: handle 0-sized nodes
Before this commit, the dla::Step RemoveInvalidStrideEdges was not
taking into account that dropping edges could change the size of the
node where the edges originated from.

This commit fixes the problem, a) recomputing the size automatically
when needed, and b) adding proper dependencies in the dla middleend
pipeline, so that these changes are properly propagated updwards and
don't break any pre-conditions of following dla::Steps.
2022-03-21 17:15:27 +01:00
Pietro Fezzardi 3678e4f730 DLA: completely remove Inheritance edges 2022-03-21 17:08:46 +01:00
Pietro Fezzardi 7192cedcbb DLA: turn off Inheritance edges 2022-03-21 17:08:46 +01:00
Pietro Fezzardi bced6beacb MakeModelGEP: relax assertions on array size 2022-03-21 15:27:51 +01:00
Pietro Fezzardi 7971f0a20d Add dla::Step SimplifyInstanceAtOffset0
This step removes redundant instance-at-offset-0, collapsing the child
into the parent, whenever this operation does not induce instance-loops
on the graph.

This is intended to reduce the number of shallow wrapper structs and
unions.
2022-03-21 11:25:55 +01:00
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 375f83c9da Merge feature/fix-dla-stride-bugs 2022-03-21 09:51:41 +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 0d58538c23 DLA: add isPointerRoot and isPointerLeaf helpers 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
Pietro Fezzardi a6b1afe019 Merge feature/adopt-cmake-format into develop 2022-03-18 12:32:54 +01:00
Alessandro Di Federico 1dcce82dfc Adopt cmake-format 2022-03-18 12:32:44 +01:00
Pietro Fezzardi 131308f9f0 Merge feature/more-logging-helpers into develop 2022-03-18 12:31:51 +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
Alvise de Faveri 16b7c61940 Add writeToLog() for types that have dump() 2022-03-17 18:52:18 +01:00
Alvise de Faveri 45784cce8c YAMLTraits: Add serializeToString() 2022-03-17 18:34:09 +01:00
Giacomo Vercesi e237ee75b0 Add custom traceback support 2022-03-17 18:33:59 +01:00
Pietro Fezzardi bcb031e8fe Merge feature/qualifier-improvements into develop 2022-03-17 17:16:14 +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 75dd8100a7 Merge ale/feature/revng-llvm-pipeline into develop 2022-03-17 17:14:10 +01:00
Alessandro Di Federico bc18091c7d Merge branch 'feature/qualifier-improvements' 2022-03-17 17:09:17 +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 ee602fc5e0 Merge branch 'feature/revng-llvm-pipeline' 2022-03-17 17:02:16 +01:00
Alessandro Di Federico 173ad98661 revng driver: introduce --keep-temporaries 2022-03-17 16:46:02 +01:00
Alessandro Di Federico cdeb1ea507 revng driver: introduce --dry-run 2022-03-17 16:46:02 +01:00
Alessandro Di Federico 6832698e5b Introduce revng llvm pipeline
This is a wrapper to `revng-pipeline` designed to make the adoption of
pipelines easier for places where we are now using `revng opt`.
2022-03-17 16:46:02 +01:00
Alessandro Di Federico e753e28f43 revng: make more extensive use of relative paths 2022-03-17 16:46:02 +01:00
Alessandro Di Federico 3cc138c8d6 Drop cloneMetadata
It was an hack to circumvent a bug in LLVM.
The following LLVM commit properly fixes the problem:

    [Cloning] Clone metadata on function declarations
2022-03-17 16:46:02 +01:00
Alessandro Di Federico 0aef5adc32 Drop scripts/revng-translate reference 2022-03-17 16:46:02 +01:00
Alessandro Di Federico 586feabd3d Drop scripts/revng-model-dump 2022-03-17 16:46:02 +01:00
Alessandro Di Federico af6305725d Rewrite revng driver infrastructure
It really needed some fresh air.
2022-03-17 16:46:00 +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