Commit Graph

6113 Commits

Author SHA1 Message Date
Giacomo Vercesi 2df691535d Pipeline: Make recalculateAllPossibleTargets
`recalculateAllPossibleTarget` is now a private member of
PipelineManager This was done since all calls that can trigger a change
in the target list have been isolated and the call is done implicitly.
This removes rp_manager_recompute_all_available_targets from PipelineC,
since it was added as a stopgap until the above was implemented.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi 487af0f4b0 Do not pass file paths to revng from PipelineC
Allow deserializing containers from a byte string rather than pointing
to a file, this allows revng to have an opaque workdir.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi 2fc11ab055 revng daemon: introduce notifications
Add the possibility of passing a list of FIFOs to `revng daemon`. These
can be used to notify an external program when a non-reproducible change
(binary, context) has occurred.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi 93f776217d Split revng.daemon.schema
Splits the module in 2:

* static_handlers: as the name suggests this is where handlers for
  static endpoints (e.g. not dependent on the pipeline) are implemented
* schema_generator: this is where the schema is generated from a
  manager's pipeline definition, together with the handler for the
  autogenerated endpoint
2022-06-29 14:50:58 +02:00
Giacomo Vercesi 05dc27715d Improve pipeline saving capabilities
This commit introduces some changes to how the revng pipeline handles
serializing to disk. Specificaly:

* Pipeline globals (specifically model.yml) are better handled if they
  are in a subdirectory. They are now saved in the "context"
  subdirectory.
* In python:revng.api the pipeline is serialized whenever there is a
  non-reproducible change to the state (e.g. binary upload or model
  change).
  In the case of analyses this is done conservatively by checking that
  the diff produced is not empty.
* The logic for computing a step's subdirectory has been moved to the
  pipeline runner, consequently if a step is asked to serialize it
  will not create any subdirectories.
* Functionality for saving a single step/context has been exposed in
  Pipeline C.
* Finally, all path concatenations are now handled by
  llvm::sys::path::append, for extra os-agnosticism.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi a03547ae66 revng.api: drop wrong exception in get_target
If a step:container does not have any targets, return an empty list
instead of raising an exception.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi 6c2d176827 python.api: introduce lock in destructors
Due to the possibly multi-threaded nature of the python C API, use
the C API lock also when invoking destructors.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi 6d159f2ef2 Kind::serialize: emit :kind if no components
This commit fixes an issue where if a target had no components the
serialized name would have been an empty string instead of ":kind".
2022-06-29 14:50:58 +02:00
Giacomo Vercesi ffab18ee48 revng daemon: identify valid port
This commit resolves a non-deterministic test failure in `revng daemon`.

When running daemon tests, `randint` was used for selecting the listen
port, this caused test failures when the same port number was used for
reused. This has been replaced with the use of port 0 that guarantees
the use of an unused port and psutil to find the port number once it has
been bound by the daemon process.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi dd08f2bf96 revng daemon --help: add description
Add an extended description to the command `revng daemon` which
details the the environment variables at play when running it.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi 79c6086d0d revng.api: autodetect files
`revng.api` now autodetects files (libraries, pipeline yamls) for
initialization via the same mechanism used by `revng.cli`. This removes
the need to pass them via environment variables from `revng daemon`
and allows easy interaction with python's C API.
2022-06-29 14:49:29 +02:00
Giacomo Vercesi a741e39f76 revng-check-conventions: introduce prettier
Adds the formatting tool prettier to allow formatting JS, TS, JSON,
YAML and HTML files.
2022-06-28 15:29:09 +02:00
Giacomo Vercesi 7a9617547a revng-check-conventions: if no changes, do nothing 2022-06-28 15:28:48 +02:00
Giacomo Vercesi 1f69e58af8 DecompileFunction: Add indentation to C code
Add proper indentation to the generated C code with the use of
mlir::raw_indented_ostream
2022-06-28 11:26:41 +02:00
Giacomo Vercesi 661821b45c Add SingleTargetFilename to pipelines
Add SingleTargetFilename for pipeline artifacts
2022-06-28 11:26:40 +02:00
Giacomo Vercesi 29d55849c5 Sync formatting changes
revng-check-conventions now includes the use of prettier for
formatting yaml files.
2022-06-28 11:25:56 +02:00
Pietro Fezzardi 5d31320bd8 Merge branch feature/reference-semantics 2022-06-28 10:39:04 +02:00
Alvise de Faveri d98db76ce1 IRCanonicalization: Add DuplicateReferences pass
This pass adds robustness to the IRCanonicalization pipeline. It
ensures that no reference opcode has more than one use.
2022-06-28 10:30:32 +02:00
Alvise de Faveri be6b35bbbc Marker: Check that we never mark references 2022-06-28 10:30:10 +02:00
Alvise de Faveri f3b2bf2e2d IRCanonicalization: Remove early-cse 2022-06-28 10:29:54 +02:00
Alvise de Faveri 562df4f288 Recompilation: Add -Wno-return-stack-address 2022-06-28 10:29:42 +02:00
Alvise de Faveri 2ffa537605 IRCanonicalization: Add Copy()
Use the `Copy` opcode to substitute load instructiobs.
2022-06-28 10:28:38 +02:00
Pietro Fezzardi d9d9294fe5 MarkAssignment: fix taint set and aggregate types 2022-06-28 10:28:08 +02:00
Alvise de Faveri fefe460ae4 Add parentheses logic for reference opcodes 2022-06-28 10:27:52 +02:00
Alvise de Faveri 6b258c83a1 IRCanonicalization: Fold ModelGEP(AddressOf())
- `FoldModelGEP` folds `ModelGEP(AddressOf())` into `ModelGEPRef`
- `RemoveRefDeref` remove `ModelGEPRef`s with no arguments
2022-06-28 10:26:50 +02:00
Alvise de Faveri 123a1777cd IRCanonicalization: Add RemoveLoadStore pass 2022-06-28 10:25:49 +02:00
Alvise de Faveri f7866ddd85 IRCanonicalization: Add MakeLocalVariables pass 2022-06-28 10:24:48 +02:00
Alvise de Faveri da46b38644 Backend: Various improvements to variables declaration 2022-06-28 10:24:18 +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
Alvise de Faveri ad524a4d4d ModelGEP: Return the size of the gepped field
ModelGEP calls in LLVM IR now return an integer that has the same
size of the field being addressed by the ModelGEP.

AddressOf calls, instead, can accept any integer size as argument but
always return a pointer-sized integer.
2022-06-28 10:14:10 +02:00
Alvise de Faveri f010aea785 ModelGEP: Don't generate index-less GEPs 2022-06-28 10:13:37 +02:00
Alvise de Faveri a31fd8587d AssignmentMarker: Handle variables scoping
If we find values to be used outside their scope, we need to always
mark them for assignment, so that they have a dedicated variable that
is declared in the right scope. To do this we:

1. Export the logic that decides if a value needs a top-scope variable
in a public header, to be used by both `VariableScopeAnalysis` and
`MarkAssignments`.
2. Add the `HasUsesOutsideBB` reason for assignment markers
2022-06-28 10:13:07 +02:00
Alvise de Faveri a1ae60dc77 IRCanonicalization: Add RemovePointerCasts pass 2022-06-28 10:12:52 +02:00
Alvise de Faveri de334a92e9 Backend: Make IntToPtr and PtrToInt transparent 2022-06-28 10:12:22 +02:00
Alvise de Faveri fa68b56573 Add ReadsMemory and WritesMemory Tags
Add `ReadsMemory` and `WritesMemory` Tags and restructure the
logic that decides whether two instructions are interfering
as follows:

1. Consider `Store`s and anything with a `WritesMemory` tag as
   having side effects
2. Consider all the `TaintSet` of an instruction when deciding
   if two instructions interfere
3. Consider both `ReadsMemory` and `WritesMemory` Tags when
   deciding interference
2022-06-28 10:11:06 +02:00
Alessandro Di Federico 1d337bd656 Merge branch 'feature/pipeline-fixes-for-mass-testing' 2022-06-23 13:26:28 +02:00
Alvise de Faveri e05972bd88 Make ref opcodes ReadOnly and InaccessibleMem
Add `ReadOnly` and `InaccessibleMemOnly` attributes to the following
functions:

- `revng_stack_frame`
- `revng_call_stack_arguments`
- `ModelGEP`
- `AddressOf`

This prevents `CSE` from grouping together any of these calls, while
still enabling `DCE` to remove calls that are not used.
2022-06-23 11:23:34 +02:00
Alvise de Faveri 66c243c46d Backend: Don't emit "undef" when logging
Since the InlineLogger is emitted inside a `/* */` comment, we should
not emit the undef comment there.
2022-06-23 11:23:34 +02:00
Massimo Fioravanti 1527a8667b Introduce revng pipeline --analyze-all 2022-06-22 18:11:32 +02:00
Massimo Fioravanti 8c7434f79e pipes::FileContainer: drop temporary file on crash 2022-06-22 18:10:48 +02:00
Massimo Fioravanti 93ccd83f6e Fix: llvm merge back crash
merge back now relies on modifying linkage rather than
OverrideFromSources
2022-06-22 18:10:47 +02:00
Massimo Fioravanti 726caad82b pipeline::Target: fix infinite loop due to typo 2022-06-22 18:10:47 +02:00
Pietro Fezzardi 1b1198ae5f PromoteInitCSVToUndef now removes init_* calls 2022-06-22 15:21:02 +02:00
Alessandro Di Federico 010268b36c Tests: use all !for-runtime 2022-06-22 14:26:44 +02:00
Alessandro Di Federico 73c8f353f1 Fix CMake formatting 2022-06-22 14:26:44 +02:00
Alessandro Di Federico bfdd74be5b Merge branch 'feature/format-fixes' 2022-06-21 18:39:55 +02:00
Alessandro Di Federico ee95dbba26 check-conventions: update for share/revng 2022-06-21 18:38:21 +02:00
Alessandro Di Federico 867c68078a Drop superfluous f"..." 2022-06-21 18:36:59 +02:00
Alessandro Di Federico 0e2b9a0629 check-conventions: don't search in SCRIPT_PATH 2022-06-21 18:36:08 +02:00
Alessandro Di Federico bee6872414 Fix CMake formatting 2022-06-21 18:24:43 +02:00