Commit Graph

16 Commits

Author SHA1 Message Date
Pietro Fezzardi 7d4a1ba467 DLATypeSystem: fix use-after-poison false positive
This commit fixes a use-after-poison false-positive report from ASAN.

This was due to misuse of SpecificBumpPtrAllocator together with
__asan_poison_memory_region.
The region was poisoned but not deallocated, which caused a the false
positive when trying to destroy and deallocate it in the destructor of
LayoutTypeSystem.

This was fixed by switching to plain BumpPtrAllocator, and properly
calling the Deallocate method, which wraps its own battle-tested ASAN
logic.
2021-05-18 12:15:53 +02:00
Pietro Fezzardi 461b1cc715 DLATypeSystem: simplify ownership, lookup, removal
Before this commit DLATypeSystem used a
std::set<std::unique_ptr<LayoutTypeSystemNode> to hold nodes, allowing
heterogenous lookup with bare pointers, fast removal being a set,
and providing address stability without requiring an ordering between
LayoutTypeSystemNodes.

The same requirements is now obtained more cleanly using with a
BumpPtrAllocator for nodes, and a set of naked pointers to them to
enable fast lookup and removal.
2021-05-14 11:23:40 +02:00
Pietro Fezzardi 981274d0b3 LayoutTypeSystem: drop unused overload mergeNodes 2021-05-14 11:23:40 +02:00
Pietro Fezzardi 2b73e29249 Decouple LayoutTypeSystemNode from LLVM IR 2021-05-14 11:23:40 +02:00
Pietro Fezzardi 7be0e6ab23 Drop redundant functions dumpToString
They have been substituted with `print` methods, that are more general.
The `dumpToString` is emitted automatically with a template in a revng
header, for those classes that already have the `print` method anyway.
2021-05-14 11:23:40 +02:00
Pietro Fezzardi e34426c03e Decompiler: handle PHINode with StructType 2021-05-06 10:37:56 +02:00
Pietro Fezzardi 49a493ebbb DLA: handle extractvalue from struct_initalizers 2021-04-29 15:16:08 +02:00
Pietro Fezzardi cdb8f84f48 DLA: Handle StructInitializers 2021-04-27 21:19:06 +02:00
Pietro Fezzardi dc84daf7e8 DLATypeSystem: add assertion on mergeNodes
The mergeNodes API is not guaranteed to work properly if the 2 merged
nodes are the same.
This commit adds an assertion to rule this situation out.
2021-02-03 12:00:04 +01:00
Pietro Fezzardi 2485cd2c8b DLAHelpers: relax assumptions on ExtractValueInst
Before this commit, the DLA code made very strong assumptions about
Functions that returned struct types.
In particular, calls to such Functions were expected to have at most a
number of uses equal to the number of fields of the returned struct.
Moreover, such uses were only expected to be ExtractValueInst.

Now, we still assume that such uses are ExtractValueInst, but we don't
make any strong assumption on their number anymore.

This makes the DLA code less reliant on specific form of LLVM IR, so we
can also drop -gvn-hoist from the decompilation test pipeline.
2021-02-02 11:23:53 +01:00
Pietro Fezzardi 730854aa1c [DLA] Add CreateNonInterferingComponents DLAStep 2021-02-02 11:23:53 +01:00
Pietro Fezzardi 6ae374b5f0 [DLA] Add InterferingInfo to LayoutTypeSystemNode
This is a flag used to mark a given `LayoutTypeSystemNode`.
It represents the fact that the children nodes are either all
interfering with each other, non-interfering with each other, or
unknown.

This information will be filled-in by the
`ComputeNonInterferingComponents` step, and will be used from the
`MakeLayouts` step to decide if the children of the node will be emitted
as fields of a union (interfering) or fields of a struct
(non-interfering).
2021-02-02 11:23:53 +01:00
Pietro Fezzardi c40b3c5386 [DLA] Add LayoutTypeSystem::createArtificialLayout
This method allows to create artificial layouts that are not directly
associated to `llvm::Value`s.
Because of this missing association with `Value`s, the artificial
layouts are not retrievable by using the public `getOrCreateLayoutType`
and `getLayoutType` methods of `LayoutTypeSystem`, but they will be
accessible only by walking the graph.

The capability to add layouts that are not associated to `llvm::Value`s
is necessary for the future implementation of the DLA Step:
`ComputeNonInterferingComponents`.
The step will add artificial layouts to represent non-intefering
components.
2021-02-02 11:23:53 +01:00
Pietro Fezzardi 46a504b9ea [DLA] Drop useless method from LayoutTypeSystem 2021-02-02 11:23:53 +01:00
Pietro Fezzardi cdca33a99f [DLA] Guard costly verify calls with VerifyLog 2021-02-02 11:23:53 +01:00
Pietro Fezzardi fc48930e5e [DLA] Add data structures for dla::TypeSystem 2021-02-02 11:23:53 +01:00