Commit Graph

2366 Commits

Author SHA1 Message Date
Pietro Fezzardi 3f5644dd02 Add operator<=> for model::Qualifier
This allows to keep `model::Qualifier`s in ordered containers, which is
necessary e.g. in `revng-c`.
2021-09-02 14:39:23 +02:00
Pietro Fezzardi aa46b03050 Add name() members to various Model types 2021-09-02 14:39:23 +02:00
Pietro Fezzardi 44b348db6a Provide efficient getName for model::Type enums 2021-09-02 14:39:23 +02:00
Ivan Krysak 612461cffa Enable more explicit edge iteration
Add reverse iterator support
2021-09-02 11:09:29 +03:00
Ivan Krysak 509ee3c41a Disallow label-less mutable edge graphs 2021-09-02 11:09:17 +03:00
Ivan Krysak 95e983fef3 Rename has_parent into HasParent 2021-09-02 11:09:04 +03:00
Ivan Krysak b6d95c2cbc Add GenericGraph::clear 2021-09-02 11:08:52 +03:00
Ivan Krysak 3f1f99deff Add GenericGraph::reserve 2021-09-02 11:08:39 +03:00
Ivan Krysak 9a902cc8ab Implement in-place node creation 2021-09-02 11:08:27 +03:00
Ivan Krysak 009a5ae060 Rework EdgeView to improve code consistency 2021-09-02 11:08:14 +03:00
Ivan Krysak 7d24eeaf48 Add a move-only addNode overload 2021-09-02 11:08:01 +03:00
Ivan Krysak 4df418fcbc Add a EdgeLabel alias 2021-09-02 11:07:49 +03:00
Ivan Krysak 334cdf9f05 Make iterators and mapping filters consistent 2021-09-02 11:07:39 +03:00
Ivan Krysak 027be0b030 Implement renvg::mapped_iterator
It's a specialization of `llvm::mapped_iterator` with better
support for temporary objects (`operator->` doesn't cause UB)
2021-09-02 11:05:22 +03:00
Ivan Krysak e5be45ab3b Add explicit names for iterator types 2021-09-02 11:05:10 +03:00
Ivan Krysak 8535f166a9 Prevent multiple edges between a pair of nodes 2021-09-02 11:04:59 +03:00
Ivan Krysak f15e41433f Make graph testing node type agnostic 2021-09-02 11:04:44 +03:00
Ivan Krysak c8a60f9d8e Implement safe node removal 2021-09-02 09:14:20 +03:00
Ivan Krysak 5b60c22feb Implement the core of the mutable edge node 2021-09-02 09:14:20 +03:00
Ivan Krysak 2050561716 Add a comment on top explaining the node types 2021-09-02 09:14:20 +03:00
Ivan Krysak d768d5d89a Add getters for successor and predecessor counts 2021-09-02 09:14:20 +03:00
Ivan Krysak fbf90f8b17 Implement revng::SmallMap::contains 2021-09-01 16:32:56 +02:00
Andrea Gussoni 16e7b2f051 RegionCFG: Improve moveEdgeTarget
`moveEdgeTarget` and `moveEdgeSource` now directly modify the
successor/predecessor field in place in the edge data structure, instead
of extracting and reinserting later the edge.

This avoid a subtle bug, found in the `createTile` helper function, that
caused the swap of a `then` and `else` branch during a tile creation
step, that consequently broke the semantics in the recovered GHAST.
2021-09-01 15:11:06 +02:00
Pietro Fezzardi f057441ce8 Fix linking 2021-08-20 11:21:04 +02:00
Andrea Gussoni 55c620ab31 RegionCFGTree: refactor connectContinueNode
THe creation and connection of continue nodes is now down in the
population of the collapsed region, avoiding external methods.
2021-08-19 18:51:24 +02:00
Andrea Gussoni 4ce2189bec RegionCFGTree: remove copyNodesAndEdgesFrom 2021-08-19 18:51:24 +02:00
Andrea Gussoni 7323cecec1 RestructureCFG: improve break node creation
Break node creation is now improved to avoid edge index swapping that
can cause inversion of conditions later on in the decompilation
pipeline.

To do this, the creation and connection of the break nodes is done
during the bulk insertion of nodes in a collapsed region.
2021-08-19 18:51:14 +02:00
Andrea Gussoni 3bb3437466 RegionCFG: Add successor index in RegionCFG dots 2021-08-19 18:50:34 +02:00
Alvise de Faveri a0f95e0370 Modify CollapseSingleChild to allow single members
* Inheritance straight lines are now collapsed by CollapseSingleChild
* Don't collapse if parent has more than one parent or if the child has
more than one parent
* Allow the possibility to construct single-member struct: if this
struct is inherited by many other structs, "flattening" the struct is not
the most sensible thing to do, since inheritance information is something
we want to preserve in these cases.
2021-07-27 11:59:48 +02:00
Alessandro Di Federico a5600a68ab TupleTree: improve support for 0-sized tuples 2021-07-21 18:22:58 +02:00
Alessandro Di Federico bf55034fa6 Support deserializing empty TupleTreeReference 2021-07-21 18:22:58 +02:00
Alessandro Di Federico fd30d3de42 Import the model's type system
This commit introduces the type system of the model along with several
various other improvements to the model and its users.

* Introduce the type system.
* Introduce possibility to tag certain fields in the model as to be
  optional during YAML serialization.
* All the `Name` fields have been replaced in favor of `CustomName` plus
  a `name` method that will use `CustomName` if available, or an
  automatically generated name otherwise.
* Make TupleTreeReferences behavior more robust: now you either need to
  have a valid pointer to `Root` and a `Path` or be default constructed
  (`nullptr` for `Root` and an empty `Path`). Any other configuration is
  invalid.
* The type system introduces `RawFunctionType`: this superseds the
  previous way in which we were specifying arguments and return
  values. Users of such information have been updated accordingly.
2021-07-21 18:22:58 +02:00
Alessandro Di Federico 0f8fa271d9 TupleTree: reduce INTROSPECTION responsibilities
This commit also introduces support for optional YAML serialization of
fields.
2021-07-21 18:19:45 +02:00
Alessandro Di Federico a546ac2a37 Introduce model::Register::getSize 2021-07-21 18:19:45 +02:00
Alessandro Di Federico 69367669d7 model::Register: enable as KOC key 2021-07-21 18:19:45 +02:00
Pietro Fezzardi 10d1eab7f4 Decompiler: update to new model APIs 2021-07-21 11:09:28 +02:00
Alessandro Di Federico 56644b8512 Move model::Register in its own file 2021-07-15 13:50:53 +02:00
Pietro Fezzardi 8fa8ca2d03 Rework getWriteableModel to return a TupleTree
The previous design returned a model::Binary &, which did not allow
users writing the model to properly initialize cross references between
different parts of the model.
2021-07-15 13:30:25 +02:00
Alessandro Di Federico b4929b431c Drop IsTupleEnd concept 2021-07-15 13:30:25 +02:00
Alessandro Di Federico 6d10581163 Whitespace and other minor changes 2021-07-15 13:30:25 +02:00
Alvise de Faveri 4eb50d0bb5 Add Unit Test for DLACollapseSingleChild 2021-06-30 17:50:12 +02:00
Alvise de Faveri c1e4b940d0 Add CollapseSingleChild step to DLA 2021-06-30 17:50:12 +02:00
Pietro Fezzardi 6efc356c47 Drop dependency on GCBI and BlockType
During combing, GCBI's BlockType was used to detect unexpectedPC and
anyPC. This method is does not work anymore (since revng started
dropping such info from isolated functions and replacing that with
llvm::unreachable instructions).

This commit drops the dependency on GCBI and BlockType, and starts
detecting blocks to inline by simply looking at their terminator. If
it's an llvm::unreachable, the block is detected as inlineable.
2021-06-30 10:38:00 +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
Pietro Fezzardi 6a2e130ec6 Move openFunctionFile to new Utils library 2021-06-21 14:15:30 +02:00
Alvise de Faveri bfdef657f2 Move DLA files to separate folder 2021-06-18 18:24:04 +02:00
Alvise de Faveri 105edb69a3 DLA: Decouple DLATypeSystem from LLVM Values
- Remove `CreateInterProceduralTypes` and `CreateIntraProceduralTypes`
  from the StepManager and put them in a separate
  `DLATypeSystemLLVMBuilder` object that is in charge of initializing
  the DLATypeSystem graph.
- Remove `MakeLayouts` from the StepManager and split into two free
  functions: `makeLayouts` and `makeLayoutMap()`
- Remove all LLVM-related stuff (Module, LayoutTypePtrs and mappings
  between these and DLATypeSystemNodes) from DLATypeSystem
- Add an IntEqClasses member to DLATypeSystem, to use to map between
  LayoutTypePtrs and Layouts
- Add a TSDebugPrinter object inside the DLATypeSystem, which by default
  prints only IDs
- Define an LLVMTSDebugPrinter inside DLATypeSystemBuilder which
  overrides the default printer's behavior, printing LLVM-related info.
- Add the possibility to dump into a .csv file the bindings between
  Nodes in the TypeSystem and `llvm::Value`s
2021-06-18 18:12:14 +02:00
Pietro Fezzardi b96fbd091d Fix check-conventions with clang-format-12 2021-06-14 23:04:02 +02:00
Pietro Fezzardi 6f7de910a6 Enable warning -Wunused-local-typedefs 2021-06-14 23:04:02 +02:00
Pietro Fezzardi 71c79461d8 MaterializedValue: fix comparison between APInt
Comparing APInt requires them to have the same BitWidth.
2021-06-14 23:04:02 +02:00