Commit Graph

2366 Commits

Author SHA1 Message Date
Giacomo Vercesi b042b5495a ModelTypeNames: fix printFunctionPrototype
The prototype of `printFunctionPrototype` has a mis-named argument
following the changes made in `2a7e06df`.
2023-10-23 10:20:54 +02:00
Pietro Fezzardi 48a708c07c Support printing NULL in decompiled C code 2023-10-19 16:18:41 +02:00
Pietro Fezzardi a97287cef3 ModelToPTMLTypeHelpers: refactor APIs
This commit reorders the argument passed to various `printDeclaration`
and `printDefinition` helper functions, to make them more uniform across
each other, and to accept the same arguments in the same order.
2023-10-18 15:19:53 +02:00
Andrea Gussoni 2f4e027ae7 RegionCFGTree: invoke findReachableNodes
Make use of the newly added `findReachableNodes` to identify the
reachable nodes from the `Then` or `Else` when there is no common
`PostDominator`.
2023-10-09 10:34:41 +02:00
Andrea Gussoni deee899ad0 RestructureCFG: improve first iteration outline
Improve the logic of the first iteration outline:
1) The cloning of the nodes involved in the first iteration outlining,
   is now performed with a series of DFS visits from all the late entry
   nodes in the `MetaRegion`, instead of performing a blind clone of all
   the nodes and removing those not needed.
2) Restoring the edges between the cloned nodes has been subject to
   minor changes.
3) The outline nodes are now assigned to a `MetaRegion` using a new
   logic, instead of blindly assigning them to the parent `MetaRegion`.
2023-10-09 10:34:41 +02:00
Andrea Gussoni 4161834bc5 RestructureCFG: improve handling of retreatings
We now explicitly store the retreatings edges, that will eventually be
connected to the `continue` nodes, so that we can explicitly handle
them, without resorting to iterating over the predecessors of the
`EntryNode`, which although correct is a fragile method with respect to
defective situations.

In addition, we check that after the restructuring, all the retreating
edges that we connect to `continue` nodes, do point to the `EntryNode`
before the transformation.
2023-10-09 10:34:41 +02:00
Pietro Fezzardi 57099e9e5d MetaRegion: initialize Parent to nullptr 2023-10-09 10:34:41 +02:00
Pietro Fezzardi 3cfad9f3f9 MetaRegion::updateNodes: simplify and add assert 2023-10-09 10:34:41 +02:00
Andrea Gussoni d2db8d4cfa ControlFlowEdgesGraph: improve at method
Improve the `at` method by giving it a coherent semantics with a
standard `at` map method semantics.
2023-10-09 10:33:48 +02:00
Andrea Gussoni e2090b8746 GraphAlgorithms: nodesBetween double DFS
We now implement the `nodesBetween` primitive with a double DFS visit.
Specifically, we have:
1) A forward DFS that starts from the `Source`, and stops at `Target`.
2) A backward DFS that starts from the `Target`, and stops at `Source`.
The final result is then the intersection of the nodes found by the two
above DFS visits.

A new `findReachableNodes` primitive is also added to perform a DFS from
a `Source` node, which stops at the `Stop` parameter node, if present.

Added unit tests to improve the coverage.
2023-10-09 10:33:48 +02:00
Alessandro Di Federico d8147aa62e Introduce TupleTreeReference::dump 2023-10-05 10:19:44 +02:00
Alessandro Di Federico c6425b2618 TupleTree::verify: more fine grained assertions 2023-10-05 10:19:44 +02:00
Alessandro Di Federico 2cbf3a8313 TypeCopier: minor rework 2023-10-05 10:19:44 +02:00
Alessandro Di Federico 456b916bcc Move TypePath definition 2023-10-05 10:19:44 +02:00
Alessandro Di Federico bf66ecc389 {,Dynamic}Function::Prototype: support typedefs 2023-10-05 10:19:44 +02:00
Djordje Todorovic 68400d9b30 Import from LLVM IR to MLIR
- Add PrepareLLVMIRForMLIR Pass.
  This Pass performs massaging of the LLVM IR
  produced by revng so it can be parsed/accepted
  for the LLVM MLIR Dialect.
- Introduce new pipeline branch: llvmir-to-mlir.yml.
- Add LLVMIRToMLIR step.
- Add ImportLLVMToMLIRPipe pipe.
2023-10-02 17:13:55 +02:00
Pietro Fezzardi 08939f2ae8 OpaqueExtractValues: set name for struct type
This commit sets a name for types we use in OpaqueExtractValues.
These are StructTypes that can only be returned from isolated functions
with RawFunctionType prototype on the model, or from helpers that do not
represent isolated functions.

The name is required because when we will converto to MLIR LLVM Dialect,
there are checks in place that forbid unnamed types.
The code re-uses code that is used to print C code, in order to make
sure that the struct names we use for this are the same as those we emit
in C, to ease debugging.

This commit also cleans up the unittest to make it more concise, while
still testing the same things.
2023-10-02 17:13:55 +02:00
Pietro Fezzardi 8d9f07d7a7 Change indentation of all decompiled C code
This commit changes the indentation of all the C code we emit, from 4
whitespaces to only 2 whitespaces.
2023-09-21 15:17:44 +02:00
Giacomo Vercesi e2504dd6f2 Implement storage credentials update
Add the functionality to rev.ng's infrastructure to allow to dynamically
update the credentials of the underlying storage provider at runtime.
2023-09-14 17:32:08 +02:00
Giacomo Vercesi 0c5bc8c120 Drop unused functions from PipelineC
Remove all the functions that are no longer needed by `revng.api`.
2023-09-14 15:44:33 +02:00
Giacomo Vercesi f710af9f2f Cleanup revng.daemon graphql API
Drop autogenerated queries from the GraphQL API and switch `revng.api`
to use `PipelineDescriptor`.
2023-09-14 15:44:33 +02:00
Giacomo Vercesi 2a239ddf47 Introduce PipelineDescription
Add the PipelineDescription object that describes the structure of a
pipeline. This will be used by all the downstream users instead of
pipeline accessor methods via PipelineC.
2023-09-14 15:44:33 +02:00
Giacomo Vercesi 6b6bfd2693 pipeline::Option: fix TypeName
Fix the `getTypeName` function needed to report the type of an Analysis'
option.
2023-09-14 15:44:32 +02:00
Giacomo Vercesi 29b229455f Tuple Tree: rename Parent in struct.h.tpl
Rename the Parent attribute of a struct to BaseClass to avoid conflicts
with Tuple Tree structs that might need that attribute.
2023-09-14 15:44:32 +02:00
Giacomo Vercesi d2967d2a49 Tuple Tree Generator: remove Model headers
This commit removes the inclusion of the `Binary.h` header in
Tuple-Tree Generator files, allowing Model-independent Tuple Trees to be
generated.
2023-09-14 15:44:32 +02:00
Giacomo Vercesi dab9369942 ContainerFactory: expose mime type
Allow retrieving the mimetype of a container without having to
materialize it in the pipeline.
2023-09-14 15:44:32 +02:00
Alessandro Di Federico 26310efc1c TypeCopier::copyTypeInto: fix returning wrong type
TypeCopier::copyTypeInto used to return a random type among those just
created instead of the new version of the originally requested type.
2023-09-11 14:15:37 +02:00
Giacomo Vercesi 0b2754c824 pipeline: drop Disk from storage methods
This commit changes the following method names across the codebase:
* `storeToDisk` -> `store`
* `loadFromDisk` -> `load`
This has been done since the storage is no longer bound to the local
storage.
2023-09-06 15:23:43 +02:00
Giacomo Vercesi ca82e47f79 FunctionStringMap: switch to using GzipTarFile
Change the serialization and deserialzation functions of
`FunctionStringMap` to use the GzipTarFile. Also change che filename
of the underlying containers accordingly.
2023-09-06 15:23:43 +02:00
Giacomo Vercesi 4a2cd259e3 Introduce GzipTarFile
Add the GzipTarFileWriter and GzipTarReader classes that allow reading a
slightly custom `.tar.gz`.
2023-09-06 15:23:43 +02:00
Giacomo Vercesi 93d3a6238d revng: introduce S3 support
Add the capability for all revng tooling to run with an S3-backed
workdir.
2023-09-06 15:23:43 +02:00
Giacomo Vercesi a84ebd0e51 revng.daemon: trim Eventmanager's functionality
Drop most of the functionality provided by EventManager. Add the
functionality that allows saving the working directory after a period of
inactivity.
2023-09-06 15:23:43 +02:00
Giacomo Vercesi 7f0bea6f6a Improve TemporaryFile
This commit adds the following enhancements to `TemporaryFile`:
* Adds TemporaryFile::make to allow catching the error if the temporary
  file creation fails
* Fix the move assignment, as it would leak the original file until shutdown
* Fix the destructor, as it would be called even on a moved object
2023-09-06 15:23:43 +02:00
Giacomo Vercesi dc90bca33e revng/Support: split part of Statistics in OnQuit
Split the OnQuit functionality of Statistics as a separate header and
object file. Rework the interface to use lambdas instead of the
OnQuitInterface.
2023-09-06 15:23:43 +02:00
Giacomo Vercesi d95c3b4732 Change extension for Decompiled container
The Decompiled container (which use FunctionStringMap) now uses
`.tar.gz` as the container format, as opposed to YAML. Change the
filename of the containers accordingly.
2023-09-06 11:23:40 +02:00
Pietro Fezzardi 6addadcda7 DynamicHierarchy.h: drop unused include 2023-09-05 15:53:43 +02:00
Giacomo Vercesi e719b3b7e5 Add components to revng cli driver
This commit introduces the concept of `Component` to a pipeline step.
This, in turn, can be used by clients to figure out which artifacts are
produced by which revng component.
Additionally, this commit overhauls the `revng daemon-self-test`
command, renaming it to `revng graphql` and adding extra flexibility.
2023-08-23 17:45:36 +02:00
Alessandro Di Federico f3d6bbb047 s/ThePTMLCBuilder/B/g 2023-08-23 16:40:54 +02:00
Alessandro Di Federico 4e1fed5fa0 ModelToHeader: omit _enum_max_value_* when editing 2023-08-23 16:37:39 +02:00
Alessandro Di Federico 330d2b6cc7 Model: rework how we name things
This commit:

* Introduces `_` as a prefix for all non-user entities we emit in
  decompiled code.
  Also, some names have been changed to be more concise.
  Specifically, the following entities have changed:
  `_ENUM_UNDERLYING`, `_ABI`, `_REG`, `_padding_at_`,
  `_artificial_struct_`, `_artificial_wrapper_`, `_stack`,
  `_break_from_loop_`, `_var_`, `_stack_arguments`,
  `_artificial_struct_returned_`, `_enum_max_value_`.
* Introduce _PACKED for `__attribute__((packed))`.
* `EnumEntry` name: drop the `EnumType` name prefix.
2023-08-23 16:37:39 +02:00
Alessandro Di Federico f81e9d615b dumpModelToHeader: introduce struct for options
This commit also introduces a new option for emitting code right after
the `#include` section.
2023-08-23 16:37:39 +02:00
Alessandro Di Federico b5aa75f1f1 Introduce model::PrimitiveType::fromName 2023-08-23 16:14:05 +02:00
Alessandro Di Federico f6a5857d80 StructType: move the Size field up 2023-08-23 16:14:05 +02:00
Alessandro Di Federico f51af94e8f TupleTreeReference::isValid is for assertions only 2023-08-23 16:14:05 +02:00
Alessandro Di Federico f584308ead Introduce getLibrariesFullPath 2023-08-23 16:14:05 +02:00
Alessandro Di Federico a5b380b201 Model: rework how we name things
This commit improves the formalization of how we handle names.

The main changes are:

* Now `_` is a reserved prefix and all the generated names start with
  `_`.
* The model verification routine now checks that `CustomName`s in the
  global scope do not collide with any local namespace (e.g., fields of
  a `StructType`).
* We changed the prefix `prefix_` to `unreserved_` to better convey the
  fact that the prefix has been introduce to use an non-reserved name.
2023-08-23 16:14:04 +02:00
Alessandro Di Federico 247879f7fc model::Type::ID: switch to progressive IDs
This commit switches `model::Type::ID` from being a GUID to be a
progressive number, in order to make things easier for humans.

On top of this, this commit introduces the following changes:

* TypeCopier: import all the necessary PrimitiveTypes and improve
  handling of CustomName.
* Move Kind as the last field of the key of each TupleTree type used in
  an `UpcastablePointer`.
* Update the ground truth of tests to ignore the `CustomName` in favor
  of focusing on `OriginalName`.
* Increase adoption of `model::Binary::makeType`, equivalent to
  `Binary.recordNewType(makeType<model::*Type>())`.
2023-08-23 16:14:04 +02:00
Alessandro Di Federico 70136ab7ef pipeline::Global: verify upon load 2023-08-23 16:14:04 +02:00
Alessandro Di Federico e63573ee81 Introduce model::Binary::path 2023-08-23 16:14:04 +02:00
Alessandro Di Federico 67be2c30b8 Introduce PrimitiveType::FirstNonPrimitiveID 2023-08-23 16:14:04 +02:00