Commit Graph

3168 Commits

Author SHA1 Message Date
Alessandro Di Federico 680c706771 DetectABI: introduce extra assertions 2023-05-10 09:15:04 +02:00
Djordje Todorovic ca7bc2e442 c-backend: Generate Inline Types in PTML
In ModelToHeader generate Inline Types in PTML by handling
Structs, Unions and Enums.

In addition, during the ModelToHeader we avoid producing
Structs that describe stacks, and in the DecompileFunction we
produce the definition of it inline if it is safe (referenced
only once).
2023-05-03 13:13:28 +02:00
Alessandro Di Federico eca3e49b77 LLVMContainer: reduce verifications 2023-04-28 14:35:00 +02:00
Alessandro Di Federico da25162d74 JumpTargetManager: drop assertNoUnreachable
The assertion cannot really hold under certain CFG forms.
2023-04-28 14:34:58 +02:00
Alessandro Di Federico 4b2e067574 rcc: ban functions we wrap 2023-04-28 14:34:52 +02:00
Alessandro Di Federico 4eeb942afb LLVMContainer: outline methods to .cpp 2023-04-28 14:34:49 +02:00
Alessandro Di Federico 8b3f641a29 Rename LLVMGlobalKindBase to LLVMKind 2023-04-28 14:34:49 +02:00
Massimo Fioravanti 4d4b587e1d Drop LLVMGlobalKindBase template argument 2023-04-28 14:34:47 +02:00
Alessandro Di Federico 58b50e6b2a Dismiss LLVMContainerBase 2023-04-28 14:34:39 +02:00
Alessandro Di Federico f68185abc9 Push ParseCommandLineOptions into InitRevng 2023-04-28 14:34:35 +02:00
Alessandro Di Federico 50f396c43d Drop revng.csv in favor of a Tag 2023-04-28 14:04:32 +02:00
Alessandro Di Federico 82aae6fa2a Give a name to SegmentBoundaries global
Unnamed globals are evil.
2023-04-28 14:04:32 +02:00
Alessandro Di Federico 1d8382187c Dismiss ConstantStringsPool, use getUniqueString 2023-04-28 14:04:32 +02:00
Alessandro Di Federico 2f917a2772 Introduce ModuleStatistics 2023-04-28 14:04:32 +02:00
Alessandro Di Federico 628aa42cc2 Introduce collectTypes 2023-04-28 14:04:31 +02:00
Alessandro Di Federico 170749b0aa Introduce revng::verify 2023-04-28 14:04:31 +02:00
Alessandro Di Federico ff6352bab4 Add missing headers 2023-04-28 13:54:12 +02:00
Alessandro Di Federico a823db7ea7 Adopt revng::verify 2023-04-28 13:54:12 +02:00
Pietro Fezzardi 503bfd8056 DecompileFunction: drop wrong constant PTML tags
These were a leftover of when `UnaryMinus` and `BinaryNot` were thought
of as only applied to constants, but this is not the case anymore.
2023-04-28 08:16:46 +02:00
Djordje Todorovic c9b2ffaf72 JumpTargetManager: improve data structures
This commit adopts `llvm::DenseSet`, `llvm::DenseMap` and
`std::unordered_set` where needed.
It also tweaks some `llvm::SmallVector` sizes.

It brings an additional ~3% improvement during lifting.
2023-04-27 19:22:03 +02:00
Djordje Todorovic e43fe18021 harvestWithAVI: split up in multiple functions 2023-04-27 19:22:00 +02:00
Djordje Todorovic 3f495d2bc3 harvestWithAVI: run InstCombine only once 2023-04-27 19:16:07 +02:00
Djordje Todorovic 07cd786ec4 Preliminary harvesting: disable InstCombine
Saves up to ~50% of time.
2023-04-27 19:16:07 +02:00
Djordje Todorovic 0604bc4d19 harvestWithAVI: limit InstCombine iterations to 1 2023-04-27 19:16:07 +02:00
Djordje Todorovic 872f14fad4 harvestWithAVI: disable GVN
This commit disables GVN in order to improve lifting performance.

It also increases `EarlyCSEMssaOptCap` so we keep catching all the jump
target we used to.

Lifting /bin/bash goes from ~29mins to ~5mins
2023-04-27 19:16:07 +02:00
Djordje Todorovic 37ab350102 Minor changes 2023-04-27 19:16:07 +02:00
Ivan Krysak a532f738e2 Yield: switch to new layouter invocation style 2023-04-27 18:12:28 +02:00
Ivan Krysak 42a9d95702 Sugiyama: improve artificial entry cleanup
Before this fix, graph preparation sometimes left extra long-edges not
connected to anything in. They were not visible after the SVG
exportation, but they were making edge routing worse (by forcing
horizontal lanes to appear where they shouldn't be - thus spacing nodes
further away from each other than necessary).
2023-04-27 18:12:11 +02:00
Ivan Krysak f57ca5793e Sugiyama: be extra strict when discarding nodes
This makes sure the "owning" piece of the edge is never discarded as
a part of streamlining the layers.
2023-04-27 18:11:57 +02:00
Ivan Krysak 8270f5b3e5 Sugiyama: separate edge restoration
Since the `orderEdges` function no longer consumes the graph, we can
finally make the restoration step separate - leading to more explicitly
stated boundaries as to where the graph is a DAG, and where it is not.
2023-04-27 18:11:32 +02:00
Ivan Krysak a04f88c402 Sugiyama: bring the documentation up to date 2023-04-27 18:11:06 +02:00
Ivan Krysak c5805a754a Sugiyama: switch to the new internal graph 2023-04-27 18:10:06 +02:00
Ivan Krysak 28574a87bc Yield: switch to layout's position and size 2023-04-27 18:09:38 +02:00
Ivan Krysak 58ddbd36e3 Sugiyama: rename InternalGraph into Helpers 2023-04-27 17:28:22 +02:00
Ivan Krysak 3b700f7820 Sugiyama: Rename Layout into InternalCompute
Also renames `calculateSugiyamaLayout()` into `computeInternal()`.
2023-04-27 17:28:22 +02:00
Ivan Krysak 00b450a8c2 Sugiyama: move the namespace under layout
Also removed a few entities to avoid duplication in the full names:
- `yield::layout::sugiyama::LayoutOrientation`
  -> `yield::layout::sugiyama::Orientation`
- `yield::layout::sugiyama::layout(...)`
  -> `yield::layout::sugiyama::compute(...)`
2023-04-27 17:28:22 +02:00
Ivan Krysak 44b9bfd04c Yield: SugiyamaStyle as a part of GraphLayout 2023-04-27 17:28:22 +02:00
Ivan Krysak 268f53cdeb Sugiyama: move the "main" file inside the layouter 2023-04-27 17:28:22 +02:00
Ivan Krysak 6d43876e78 SVG: move one of the sugiyama::layout overloads
It isn't generic enough to be kept in the header, so it was moved
closer to its users.
2023-04-27 17:28:22 +02:00
Ivan Krysak 0de7e3540f Sugiyama: move DAG converter to getBackedges 2023-04-27 17:28:22 +02:00
Ivan Krysak 7ca012dbc3 Minor improvements 2023-04-27 17:28:22 +02:00
Massimo Fioravanti 80248711b4 Update revng-c to use TrackingSortedVector
The revng model is now composed of TrackingSortedVector instead of
SortedVector, and thus uses in revng-c must be updated.
2023-04-26 18:00:42 +02:00
Massimo Fioravanti 254dc99fcb TupleTreeGenerator: emit tracking machinery 2023-04-21 17:50:16 +02:00
Pietro Fezzardi 53d35e7df9 AddAssignmentMarkerPass: fix Copy(LocalVariable)
Before this commit, the pattern Copy(LocalVariable) used to generate
unnecessarily redundant additional LocalVariables.

This commit fixes this problem, indroducing reuse of local variables
when possible.
2023-04-20 17:51:16 +02:00
Pietro Fezzardi 17cbe341c6 Remove DuplicateReferences from pipeline
The pass was necessary to prevent the creation of local variables with
reference types, caused by calls to custom opcodes tagged with
FunctionTags::IsRef.
These local variables would not be valid for decompilation, because C
doesn't have reference types.
However, creation of such variables would pop up if not deduplicated,
due to the fact these calls could have many uses, and MarkAssignments
had a policy of marking for serialization all the instructions with many
uses.
Now that policy has been dropped, so this pass doesn't need to exist
anymore.
2023-04-20 17:51:16 +02:00
Pietro Fezzardi 9bbafa9da4 ExitSSA: group PHI in equivalence classes
Each equivalence class informally represents a set of PHINodes for which
we want to emit a single alloca.
2023-04-20 17:51:16 +02:00
Pietro Fezzardi 3886b882da MarkAssignments: drop check on many uses
This commit changes MarkAssignments (and related tests) so that now
instruction with more than one use are not assigned to a new variable
by default.

In some cases it might still be good to serialize them for readability,
but for those cases we will implementa a standalone pass that only
implements heuristics based on readability.

MarkAssignments now only takes decisions based on semantics of
side-effects.
2023-04-20 17:51:16 +02:00
Giacomo Vercesi a2b7d0e0bf PipelineC: add tracing
Add support for tracing onto the PipelineC. This is done by:
1. Creating wrapper functions for each PipelineC function with the
   script in `scripts/PipelineC_add_tracing.py`. These will call a
   special function called `wrap` which will ultimately call a method
   with a `_` prepended to the name
2. Conversion of all PipelineC methods in `PipelineC.cpp` to `static`
   and their rename with a `_` in front, in order for them to work with
   the wrapper function in (1)
3. Generation of 2 additional include files, one for types and one for
   functions, to be used by users of tracing files in order to have
   introspection.

These steps allow the creation of a trace file with the use of the
`REVNG_C_API_TRACE_PATH` environment variable. The traces can then be
used in conjunction with the `revng trace run` and `revng trace
inspect` commands.
2023-04-20 14:43:13 +02:00
Giacomo Vercesi 19bb38d32b PipelineC: fix UAF on rp_targets_list
The underlying rp_target pointer was not stable, switch to returning a
copy of the target instead.
2023-04-20 14:43:13 +02:00
Giacomo Vercesi 566cb6310b PipelineC: make indexed object stably sorted
Many Pipeline objects (Globals, Ranks, Kinds, Targets in a TargetList)
were ordered by load order, this makes the playback of traces difficult.
Moreover the order of loading of pipeline files also influences the
ordering of other elements (Step, Analys{is,esLists}). These are also
ordered to prevent incosistent ordering.
2023-04-20 14:43:13 +02:00