Commit Graph

51 Commits

Author SHA1 Message Date
Ivan Krysak 288448f009 Never include model::VerifyHelper from headers 2025-02-13 13:09:50 +02:00
Alessandro Di Federico 143c315196 Merge revng-c into revng 2024-11-21 10:50:55 +01:00
Alessandro Di Federico 8cd4ee3b59 Move Kinds.h to revng 2024-11-04 15:09:56 +01:00
Alessandro Di Federico 8a5ae5f9c1 s/ExecutionContext &Ctx/ExecutionContext &EC/g 2024-09-27 10:35:10 +02:00
Pietro Fezzardi 8311efb21c DLA: re-enable DeduplicateFields after fixing it 2024-07-05 00:43:35 +02:00
Pietro Fezzardi fc02a98aa3 DLA: disable DeduplicateFields
The DLAStep has bugs that are preventing other useful features to be
merged.
2024-06-26 12:21:58 +02:00
Alessandro Di Federico 5186a58053 s/FunctionMetadata/ControlFlowGraph/ 2024-06-18 17:56:24 +02:00
Alessandro Di Federico 0c212b66d9 Relicense to MIT 2024-02-29 17:03:36 +01:00
Alessandro Di Federico 539b2bd435 Rename dla analysis into analyze-data-layout 2024-02-09 09:03:34 +01:00
Pietro Fezzardi f367eafad2 DLA: store node neighbours in increasing ID order 2024-02-04 16:07:30 +01:00
Pietro Fezzardi 73cf39d206 DLA: add MergePointeesOfPointerUnion DLAStep 2024-01-26 16:49:52 +01:00
Massimo Fioravanti 86e45461a0 Introduce pipeline execution context 2024-01-02 11:05:50 +01:00
Pietro Fezzardi 7c1021ffc1 DLA: rearrange Middleend steps
Now CompactCompatibleArrays runs after ArrangeAccessesHierarchically.
Rearranging the accesses hierarchically first allows the following step,
that compacts compatible arrays, to achieve better results, and overall
recover much better looking arrays.
2023-12-05 16:59:08 +01:00
Pietro Fezzardi b8c48be350 Add progress bars to DLA 2023-09-07 12:19:35 +02:00
Alessandro Di Federico 237aefcc9a DLA: drop LoopInfoWrapperPass
It was not being used.
2023-04-14 14:54:14 +02:00
Massimo Fioravanti 87aef3fbad revng-c now uses Model accessors 2022-12-12 11:35:52 +01:00
Pietro Fezzardi 1b05ff38be DLAPass: verify model after updating it 2022-11-30 11:37:00 +01:00
Massimo Fioravanti 335d402245 Change signatures to forward metadata cache. 2022-11-22 12:27:02 +01:00
Pietro Fezzardi 8d7568710a DLA: add PushDownPointers dla::Step 2022-09-30 18:34:10 +02:00
Pietro Fezzardi fbc9844499 DLA: add ResolveLeafUnions dla::Step 2022-09-29 18:38:11 +02:00
Pietro Fezzardi 8e75677307 ArrangeAccessesHierarchically: push down pointers
This commit enables ArrangeAccessesHierachically to push down pointer
edges when rearranging accesses hierarchically.

In particular, if an edge N is being pushed down another edge M, and M
is at offset 0, and N reaches a pointer edge PE that points to a
grandparent G of M at offset 0, then we want to push down the pointer
edge PE so that it points to the target of M, unless there is another
edge M' different from M, such that M' has the same properties of M but
target(M) != target(M').
2022-09-29 18:38:11 +02:00
Pietro Fezzardi ac29a77a70 DLAPass: improve pipeline
This commit introduces an additional run of CollapseSingleChild and
DeduplicateFields before CompactCompatibleArrays and
ArrangeAccessesHierarchically.

This is meant to cleanup the graph so that the two latter steps can be
more effective.
2022-09-29 18:38:11 +02:00
Pietro Fezzardi 0298db677d DLA: add CompactCompatibleArrays dla::Step 2022-09-29 18:38:11 +02:00
Pietro Fezzardi e47733eb66 DLA: new Middleend pipeline 2022-09-15 11:47:11 +02:00
Massimo Fioravanti 370b081c0e Moved kinds to kinds namespace 2022-08-25 17:09:15 +02:00
Antonio Frighetto a7ddddce92 DLA: recover model::Segment type
DLA now handles `segmentRef` opaque function calls.
2022-07-19 13:51:06 +02:00
Pietro Fezzardi 6f41e625e7 DeduplicateUnionFields is now DeduplicateFields
Before this commit, the dla::Step depended on InterferingInfo, but this
was superfluous.

This commit drops the dependency and enables the Step to run before
ComputeNonInterferingComponents.

This also avoids the need to run ComputeNonInterferingComponents twice
(one before and one after DeduplicateUnionFields), so it can only run
once.
2022-06-08 14:16:51 +02:00
Pietro Fezzardi 5a37fe8a84 DLA: add MergePointerNodes Step
This Step merges nodes with outgoing pointer-edges pointing to the same
pointee node.
2022-06-08 10:22:35 +02:00
Pietro Fezzardi ba50eb4a55 DLA: revive and rework CollapseSingleChild Step
The step now collapse parents with their single child if they are
indistinguishable, i.e. if the parent has only that single child, at
offset zero, and their size is the same.
2022-06-08 10:21:44 +02:00
Pietro Fezzardi 2651b8765b DLA: drop CollapseCompatibleArrays
This pass was never implemented and we don't have plans to do it soon.
This commit just drops it to reduce the noise.
Whenever we decide to implement something similar we'll do it from
scratch.
2022-05-27 17:06:49 +02:00
Pietro Fezzardi 31419a5fd1 Remove old unused dla::Layout class
This class was introduced before having model::Type, to represent
roughly the same information.

Now it's dead code and this commit removes it.
2022-05-26 16:46:47 +02:00
Massimo Fioravanti f40cf6471d Transformed DLA in a pipeline analysis 2022-05-25 15:48:27 +02:00
Pietro Fezzardi 96148248b1 Drop old unused flag: -dla-flatc-dir 2022-05-11 12:42:38 +02:00
Giacomo Vercesi ab125b35b0 Fix License headers
Change company name to "rev.ng Labs Srl" in all license headers
to reflect changed company name and legal status
Add missing license headers to files that didn't have one
2022-04-19 12:17:59 +02:00
Pietro Fezzardi 593cc584cb DLA: propagate type info between loads and stores 2022-04-13 12:41:17 +02: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 7192cedcbb DLA: turn off Inheritance edges 2022-03-21 17:08:46 +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 d6ae6fd650 Add dla::Step RemoveInvalidStrideEdges 2022-03-21 09:43:10 +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
Alessandro Di Federico 5d197bff15 Adopt API changes in the model 2022-03-10 17:59:05 +01:00
Pietro Fezzardi 3c7d46a294 DLAPass.cpp: drop useless include 2022-01-04 16:22:47 +01:00
Pietro Fezzardi decbbc56df Merge librevngcUtils into librevngcSupport 2021-12-22 17:46:45 +01:00
Alvise de Faveri 5b8529edd5 DLA: Generate Model Types
Add `MakeModelTypes` and `UpdateFuncPrototypes` to the DLA backend:
* `MakeModelTypes` adds to the model all the types recovered by the DLA
* `UpdateFuncPrototypes` updates function prototypes in the model that
have generic return values or arguments to use the types recovered by
the DLA
2021-11-16 17:00:53 +01:00
Alvise de Faveri 4c8215fc47 DLA: Add pointers
* Changes to the `LayoutTypeSystem` graph

Pointers are identified in the TypeSystem graph as leaf nodes which
have a new type of edge (PointerEdge) that connects them to another
node of the graph. The destination of the edge represents the layout of
the pointed type.

* Changes to the Front-end

Pointer edges, and their destination nodes, are created by the DLA
front-end (`DLACreateIntraProceduralTypes`) whenever an access node has
a size that is compatible with the size of a pointer in the current
Architecture.
Successors might then be added to the newly generated node, if any,
by looking up the llvm::Value it is attached to.

* Changes to the Middle-end

Most of the DLA passes should ignore Pointer Edges, so they are modified
accordingly. Most notably, nodes that represent pointed layouts should
never be merged/pruned-off.

* Changes to the Back-end

The `TypeDeclCreationAction` of the decompiler and the `DLAMakeLayouts`
step of the DLA back-end are modified to take into account the new
information about pointers.

⚠️ There is a known issue with this version of the decompiler,
namely the fact that type loops are not detected and can cause the
emitter to enter an infinite loop.
2021-11-16 17:00:34 +01:00
Alvise de Faveri 43ae7a91cb DLA: Add DeduplicateUnionFields Step
Add a step that recognizes if two subtrees of a union node are
topologically equivalent and merges them. This corresponds to removing
duplicate fields in unions.

This deduplication was prevously done while emitting layouts.

A check is inserted into DLAMakeLayouts to assert that, after
constructing unions, no union has only one child, which could be the
case if we didn't deduplicate union fields in the graph.
2021-10-06 16:37:37 +02:00
Alvise de Faveri 7e72fc4be1 DLA: Add RemoveConflictingEdges step
Add a DLA step that removes all instance-at-offset-0 edges between nodes
that already have an inheritance edge between them.
2021-10-05 18:16:21 +02:00
Alvise de Faveri c1e4b940d0 Add CollapseSingleChild step to DLA 2021-06-30 17:50:12 +02:00
Pietro Fezzardi 6a2e130ec6 Move openFunctionFile to new Utils library 2021-06-21 14:15:30 +02:00