88 Commits

Author SHA1 Message Date
Massimo Fioravanti 335d402245 Change signatures to forward metadata cache. 2022-11-22 12:27:02 +01:00
Pietro Fezzardi 70a6185ce8 DLA/Frontend: don't skip calls with 0 uses
Before this commit we were not adding nodes to DLATypeSystem for calls
with 0 uses.

This commit fixes the problem, and only avoids adding nodes for calls
that return void.
2022-11-09 16:23:34 +01:00
Pietro Fezzardi 9440aa434d DLA: pointer edges only for pointer-sized nodes
Before this commit, the creation of intra-procedural types and edges
was too liberal, possibly leading to creation of pointer edges starting
from nodes that were not pointer-sized.

This commit fixes the issue, never creating outgoing pointer edges from
non-pointer-sized nodes.
2022-11-08 11:47:50 +01:00
Pietro Fezzardi bf83f40e3b Move SCEVBaseAddressExplorer.h from public headers 2022-10-21 10:00:23 +02:00
Pietro Fezzardi a60fa30d5b DLA/Frontend: handle indirect calls prototypes 2022-08-09 08:02:10 +02:00
Alessandro Di Federico 662cbfda84 Minor changes 2022-08-08 16:22:14 +02:00
Antonio Frighetto e06f9841ed DLA/Frontend: support Segment.Type struct already filled
Avert DLA's middle-end from performing optimizations by
making new segment nodes point placeholder nodes.
2022-07-29 11:05:22 +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
Alvise de Faveri 221b8f74d9 Add reference semantics to stack opcodes
`revng_stack_frame` and `revng_stack_args` are treated as returning
a reference, and are always followed by an `AddressOf` call.
2022-06-28 10:23:45 +02:00
Pietro Fezzardi 89734f6208 DLA: add pointer placeholders to model types
This commit adds placeholder pointer nodes to the DLA graph during
initialization, to point to nodes that represent model types whose size
should not altered during the Middleend.
2022-06-14 12:51:48 +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
Pietro Fezzardi 14d40096b7 Rearrange Liveness and MarkForSerialization
These two parts of the code needed to be separated into libraries
because they were used both by the old C backend and by
IRCanonicalization.

Now that the old C backend is dead, they have been incorporated into
IRCanonicalization.
Further changes are necessary to strip away the last leftovers of the
old C backend from MarkAnalysis.
2022-04-21 09:51:45 +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
Antonio Frighetto 765219d58c Support for control-flow graph out of the model
The control-flow graph has been taken out of the model. Related changes
to `getCallSitePrototype` have been here addressed.
2022-04-06 16:25:05 +02:00
Alvise de Faveri ddf8adca70 DLA: drop ModelFuncHelpers and use shared ones 2022-03-22 10:55:16 +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 7192cedcbb DLA: turn off Inheritance edges 2022-03-21 17:08:46 +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
Alessandro Di Federico 1dcce82dfc Adopt cmake-format 2022-03-18 12:32:44 +01:00
Alessandro Di Federico 77335d036a Rename Lifted tag to Isolated 2022-03-17 14:08:05 +01:00
Pietro Fezzardi 050af6e5c6 Move getLoadStoreSizeFromPtrOpUse to DLA frontend
This helper was only used once in DLACreateIntraProceduralTypes.cpp.
This commit moves it there, paving the way for better isolation of
helpers.
2022-03-01 12:18:22 +01:00
Pietro Fezzardi e2a82f8dfc Drop useless include DLAHelpers.h 2022-03-01 11:38:04 +01:00
Pietro Fezzardi 64d30a4790 DLATypeSystemBuilder: isolate assertion methods
The assertGetLayoutTypePreConditions methods didn't really need to be
exposed as methods in a header. This commit moves them to static
standalone functions in the only place they're used.
2022-02-28 18:06:44 +01:00
Pietro Fezzardi 5cdc63cda6 Apply new revng coding conventions 2022-02-28 18:02:25 +01:00
Pietro Fezzardi d237bc439e IRCanonicalization: switch to FunctionTags 2022-01-14 14:29:05 +01:00
Pietro Fezzardi 818156e06a DLA upgrades stack's and stack arguments' types 2022-01-04 16:21:07 +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 8a337a4525 DLA: ignore loops with trip count 0 2021-12-17 13:50:46 +01:00
Pietro Fezzardi abee369841 Handle calls whose callee is not an llvm::Function 2021-12-14 16:57:41 +01:00
Pietro Fezzardi 375eb70dc8 SCEVBaseAddressExplorer: ignore non-const strides 2021-12-14 16:56:51 +01:00
Alvise de Faveri 89091510d5 DLA: Handle functions with same prototype in FE
Since in the model a FunctionPrototype can be shared among different
functions or indirect calls, we should take into account this fact when
initializing the DLA.

In particular, if the aforementioned case happens, we want to add
equality edges between the return value(s) and the arguments of all the
functions that have the same prototype. These will then be merged by
later steps in the middle-end, and the resulting information will be
shared among all the merged nodes.
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
Pietro Fezzardi 032463c539 Fix handling of calls with unnamed callees 2021-10-12 09:57:30 +02:00
Pietro Fezzardi f057441ce8 Fix linking 2021-08-20 11:21:04 +02:00
Alvise de Faveri 4eb50d0bb5 Add Unit Test for DLACollapseSingleChild 2021-06-30 17:50:12 +02:00
Alvise de Faveri 47db3fdb11 Promote AccessSizes to full-fledged TS nodes
While doing thie, also drop `printAccessNode()` from DLA DebugPrinter.

The information about which LLVM instruction originated a given access
node is already available in the csv generated by the `dla-accesses-log`
logger.
2021-06-25 18:07:17 +02:00
Alvise de Faveri bfdef657f2 Move DLA files to separate folder 2021-06-18 18:24:04 +02:00