31 Commits

Author SHA1 Message Date
Alessandro Di Federico 143c315196 Merge revng-c into revng 2024-11-21 10:50:55 +01:00
Alessandro Di Federico 0c212b66d9 Relicense to MIT 2024-02-29 17:03:36 +01:00
Pietro Fezzardi 73cf39d206 DLA: add MergePointeesOfPointerUnion DLAStep 2024-01-26 16:49:52 +01:00
Giacomo Vercesi a4ad571e61 rcc: Fix typos
Fix the typos detected by `codespell`
2023-05-11 10:04:32 +02: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 1ccf0bd5df DLA: simplify constructor of DeduplicateFields 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 07dc677196 dla::CollapseSingleChild: remove invalidation
The invalidation was overly strict and not necessary.
2022-09-29 18:38:11 +02:00
Pietro Fezzardi f0a1903201 DLA: add ArrangeAccessesHierarchically dla::Step 2022-09-15 11:47:11 +02:00
Pietro Fezzardi 8ff8a795e4 DLA: Add DecomposeStridedEdges dla::Step 2022-09-14 11:33:37 +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 5c9ae203e6 DLA: fix deps for ComputeUpperMemberAccesses 2022-06-08 10:20:13 +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
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 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 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
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 637bf70ff3 DLA: Make CollapseSingleChild a function
Since the reasoning behind single child collapsing can be reused in
other points of the DLA pipeline, move the logic that acts on a single
node in a static function out of the CollapseSingleChild step.
2021-10-05 18:16:21 +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
Alvise de Faveri bfdef657f2 Move DLA files to separate folder 2021-06-18 18:24:04 +02:00