Commit Graph

563 Commits

Author SHA1 Message Date
Alessandro Di Federico 6dd346ab04 Move GCBI.getMetaAddressMetadata to IRHelpers.h 2021-12-15 18:03:30 +01:00
Alvise de Faveri 2f4b716e6b Add Model::toString() and writeToFile()
These functions can be used in conjunction to dump the Model on a
file during a gdb session, for example:

```
(gdb)  p  writeToFile(Model->toString(), "/tmp/model.yaml")
```
2021-11-19 10:17:09 +01:00
Ivan Krysak 52f7432f1b Add model::Architecture::getPointerSize() 2021-11-08 16:17:47 +01:00
Alvise de Faveri 2e19fade43 Fix memory leak in TupleTreeKeyWrapper::clone
ConcreteTupleTreeKeyWrapper::clone() should cleanup the Target object
befor cloning, otherwise the destructor of the inner Pointer object
is never called.
2021-10-27 08:42:53 +02:00
Pietro Fezzardi c050dcb621 Handle missing model in SerializeModelPass
Before this commit, SerializeModelPass and SerializeModelWrapperPass had
hard dependencies on the passes that load the model from LLVM-IR.

This commit makes this dependency optional. When the passes for model
serialization are executed, if they see that nobody requested to load
the model, they will not try to serialize it.

This prevents them from crashing when running in pipelines that only
contain passes that ignore the model.

This is particularly beneficial because `revng opt` automatically adds
`-serialize-model` at the end of each pipeline and, before this commit,
this meant that `revng opt` could not be used for unit-testing simple
llvm passes that do not use the model.

With this commit, `revng opt` can be used for unit-tests, even on LLVM IR
with missing model.
2021-10-21 15:02:01 +02:00
Alessandro Di Federico 83f420abda Introduce dump method for model structs 2021-10-21 15:02:00 +02:00
Alessandro Di Federico eb2c3df925 Tag with MetaAddress functions and call sites 2021-10-21 15:02:00 +02:00
Alessandro Di Federico 8546a0c786 CallEdge: only indirect calls have a prototype 2021-10-21 15:01:59 +02:00
Alessandro Di Federico 89532890ed Introduce support for importing DWARF information 2021-10-21 15:01:20 +02:00
Alessandro Di Federico 3a3eea0cf5 Introduce support for dynamic functions 2021-10-21 15:01:19 +02:00
Alessandro Di Federico a023bfa7f5 Introduce ABI handling 2021-10-18 20:44:58 +02:00
Alessandro Di Federico 0dfc81da41 Minor model improvements
* Introduce some documentation for the model.
* Improve the way enums are serialized/deserialized.
* Mark certain fields of model data structures as optional.
* introduces some error messages during model validation.
2021-10-18 20:44:58 +02:00
Alessandro Di Federico 5b50a3320f Introduce error messages during model validation 2021-10-18 20:44:58 +02:00
Alessandro Di Federico d5bfb872d6 Introduce SortedVector::isSorted
This is a debug method.
2021-10-18 20:44:58 +02:00
Alessandro Di Federico 18cfbdbfe0 Whitespace and other minor changes 2021-10-18 12:39:21 +02:00
Ivan Krysak 6714c4cb58 Add Node::copy() and Node::move()
Those member functions are an easy way to reach the underlying node data
without affecting the edges stored by the node.
2021-10-04 14:38:42 +02:00
Pietro Fezzardi a0dbea19e5 Prevent model::Type CustomNames from colliding
This commit reserves the "unnamed_" prefix for revng.
The first use of this reserved prefix is in `model::Type`s
`CustomName`s and `model::Identifier`s.
This commit also makes the `verify()` method stricter for
`model::Identifier` so that an `Identifier` whose name starts with the
reserved prefix does fails verification.
2021-09-02 14:55:47 +02:00
Pietro Fezzardi 3d38451abd Enable error checking on Model deserialization
This commit changes the `TupleTree::deserialize` method to return an
`llvm::ErrorOr<TupleTree>`, enabling users to choose their policies on
error reporting.
2021-09-02 14:42:51 +02:00
Pietro Fezzardi bae9214652 Stricten verification for model::Identifier
Now only `Identifier`s that are valid C identifiers are guaranteed to
verify.
The `fromString` factory is updated accordingly.
2021-09-02 14:42:47 +02:00
Pietro Fezzardi 48f6a60629 Fix callOnPathSteps for KeyedObjectContainer
callOnPathSteps was using linear scan search in KeyedObjectContainer.
This commit fixes it for using binary search, dramatically improving
performance in workloads that do lots of lookups.
2021-09-02 14:39:23 +02:00
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
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
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