Commit Graph

2366 Commits

Author SHA1 Message Date
Ivan Krysak 11f07c6708 TypeNames: emit comments when outputting types 2023-07-21 04:58:50 +00:00
Ivan Krysak e0b956b1c2 Model: rework edit path helpers from the ground up 2023-07-21 04:58:50 +00:00
Kacper Kołodziej b05a56e2da Move isMemory to IRHelpers.h 2023-07-20 18:09:48 +02:00
Kacper Kołodziej 75ed8f7788 Add WrittenRegisters set to FunctionSummary
WrittenRegisters will be used in propagating prototypes to wrappers
functionality to check if function writes to arguments or stack pointer.
2023-07-20 18:09:48 +02:00
Andrea Gussoni 42f74ad998 RestructureCFG: use nodesBetween helper
Use the `nodesBetween` helper provided by the `GraphAlgorithms` header
instead of the custom `findReachableNodes` implementation.
2023-07-19 16:31:48 +02:00
Andrea Gussoni ac6139bc0f clift: import mlir::clift dialect 2023-07-07 17:48:13 +02:00
Andrea Gussoni c8871fc508 GraphAlgorithms: drop old nodesBetween
We now switch to the `llvm::df_iterator` based `nodesBetween`
implementation.

This new implementation makes use of the idiomatic way of extending the
DFS implementation provided by LLVM, instead of rolling our custom
implementation for the `nodesBetween` algorithm.
2023-07-07 15:02:08 +02:00
Andrea Gussoni f7db37e990 SetOperations: new header with useful set helpers 2023-07-07 15:02:08 +02:00
Andrea Gussoni 1a0c429ef9 GraphAlgorithms: introduce extended DFS algorithms
We improve the `getBackedges` and `nodesBetween` helper functions that
can be used for backedge discovery and computation of all the nodes
reachable on all the paths defined between two nodes in a graph.

We build upon the `llvm::df_iterator` function, by customizing the visit
stack to perform the desired visits.
2023-07-07 15:02:08 +02:00
Andrea Gussoni a613b873e8 GraphAlgorithms: introduce isDAG verifier helper 2023-07-07 13:33:30 +02:00
Ivan Krysak b0dcc3d9ee Formatting: forbid clang format off 2023-07-05 14:33:06 +02:00
Ivan Krysak ce6d9a6dbf Formatting: forbid \brief 2023-07-05 14:33:03 +02:00
Ivan Krysak fe0531868c Use Container::contains() where appropriate 2023-07-05 06:07:09 +00:00
Ivan Krysak 888e5371eb Formatting: change PenaltyReturnTypeOnItsOwnLine
The new value is 21.
2023-07-05 06:06:07 +00:00
Ivan Krysak 3c584cfabc Formatting: set AllowShortEnumsOnASingleLine
The new value is `false`.
2023-07-05 06:05:04 +00:00
Ivan Krysak ee0dc1866d Forbid clang format off 2023-07-03 15:23:10 +00:00
Ivan Krysak 9f1d9fd5d0 Use Container::contains() where appropriate 2023-07-02 15:06:11 +00:00
Ivan Krysak 5779cd878d KOCs: make more STL-like
This adds a couple of newer methods missing from these templates.
2023-07-02 15:06:11 +00:00
Ivan Krysak 4ab4d85ead STLExtras: remove incomplete iterator concepts 2023-07-02 15:06:11 +00:00
Ivan Krysak 690df84eca Concepts: prefer non-strict SpecializationOf
Not every case can benefit from extra liniency, so they were manually
reviewed on a case by case basis.

Additionally, this drops a couple of "this should be a non-strict
specialization" commits, because of a bug with clang
(see the GenericGraph concepts rework commit for more details) as
to avoid confusion (we wouldn't want anyone trying to solve these
"todo"s) until the clang struct type deduction is fixed. Especially
considering that there are currently no cases where these softer
versions would be beneficial (we never inherit from templates in
question).
2023-07-02 15:06:11 +00:00
Ivan Krysak 37b8f80bf1 Concepts: introduce SpecializationOf
It was not available earlier because it required clang-13+
2023-07-02 17:05:52 +02:00
Ivan Krysak b927e26f94 Drop concepts provided by the standard library
We needed these because our libc++ version didn't provide them. Now that
that's no longer the case, they can be safely dropped.
2023-07-02 13:20:49 +02:00
Ivan Krysak a123ec2c35 Remove clang-format off around concepts
Now that clang-format no longer breaks anything involving a concept or
a requires clause on sight, these are no longer necessary
2023-07-02 13:20:49 +02:00
Ivan Krysak bc98e0079f Formatting: change PenaltyReturnTypeOnItsOwnLine
The new value is 21.
2023-07-02 13:20:49 +02:00
Ivan Krysak 01b4ec36c9 Formatting: set AllowShortEnumsOnASingleLine
The new value is `false`.
2023-07-02 13:15:08 +02:00
Ivan Krysak c523167302 Formatting: enforce access modifier whitespaces 2023-07-02 13:09:52 +02:00
Ivan Krysak 7ed14ca65c Minor improvements 2023-07-02 11:06:55 +00:00
Alessandro Di Federico a65ccc3413 Introduce ValueMaterializer
`ValueMaterializer` is a rewrite of what was called `AdvancedValueInfo`
which follows the same principles.

The main benefits over the old version is:

* We materialize the data-flow graph and the CFG of the relevant part of
  root. This makes debugging significantly easier.
* We drop the old MonotoneFramework infrastructure in favor of
  getMaximalFixedPoint.
* We significantly reduce the amount of queries we make to
  AdvancedValueInfo.
2023-06-30 13:39:22 +02:00
Alessandro Di Federico 4c01d9c28d BidirectionalNode: implement edge removal 2023-06-30 13:38:27 +02:00
Alessandro Di Federico 4edcb6dd49 MetaAddress::decomposeIntegerPC: accept APInt 2023-06-30 13:35:04 +02:00
Alessandro Di Federico 466871e866 Introduce RegisterClobberer 2023-06-30 13:28:36 +02:00
Alessandro Di Federico f120ad334c Statistics.h: rework 2023-06-30 13:06:58 +02:00
Alessandro Di Federico 5e72f8e31b ConstantRangeSet::dump: custom APInt formatter 2023-06-30 12:35:18 +02:00
Alessandro Di Federico 08b8b0bd9f ConstantRangeSet::size: fix corner case
In order to correctly represent the size of a 32-bit ConstantRange, you
need 33 bits.
2023-06-30 12:35:18 +02:00
Alessandro Di Federico b21861b7f9 GraphTraits<GenericGraph>: fix const support
GraphTraits were not fully usable in case of a `const` graph due to a
missing std::conditional_t for the definition of the `Node` type.
2023-06-30 12:35:18 +02:00
Alessandro Di Federico 5ebec631b9 getMaximalFixedPoint: fix Flow argument type 2023-06-30 12:35:18 +02:00
Ivan Krysak e3be901f1f STLExtras: allow skip to result in empty ranges
This only affects the case where the number of elements to be skipped
exactly matches the number of elements in the container.
2023-06-30 12:35:18 +02:00
Alessandro Di Federico d3c37fc692 ProgramCounterHandler::expandNewPC: take CallBase 2023-06-30 12:35:18 +02:00
Alessandro Di Federico 84dd10cbdb GenerichGraph.h: nullptr-initialize Edge::Neighbor 2023-06-30 12:35:18 +02:00
Alessandro Di Federico b53d3f457b Minor changes 2023-06-30 12:35:18 +02:00
Pietro Fezzardi e2791443fb Remove extractvalue instructions in decompilation
Now extractvalue instruction are replaced by dedicated
OpaqueExtractValue custom opcode, that prevents LLVM from doing strange
things with extractvalues during optimizations (such as e.g. sinking).

This is important since extractvalue instructions and struct-typed
values in general in our LLVM IR are not real first-class citizens, but
only a byproduct of the binary lifting process, and they actually
represent bundles of registers that are returned from isolated
functions.
2023-06-30 10:48:59 +02:00
Pietro Fezzardi c3d7125dd5 Drop old unused RestoreExtractValuesPass
Now we don't restore the extractvalue instructions anymore, so this
whole pass is dead code.
2023-06-30 10:48:59 +02:00
Andrea Gussoni 2162bd6f4a BeautifyGHAST: change Standard to WhileTrue
Rename the `LoopType` enum element `Standard` to `WhileTrue`, to better
convey the information that in that stage the loop as not been promoted.
2023-06-26 15:23:00 +02:00
Andrea Gussoni 3b07a6fba6 BeautifyGHAST: Introduce the hybrid not simplify
Introduce the hybrid beautifier aiming to simplify double `not`s (one on
the IR side (e.g., a `icmp ne`), and one on the `ExprNode` side on the
`GHAST` in the form of a `NotNode`.

To do this hybrid beautifier, we basically need to do the following:
- Implement a preliminary collection phase which computes which
  `ExprNode`s are affected by which `BasicBlock`.
- Compute the so-called consesus, i.e., verify that for all the
  `ExprNode`s affected by a certain `BasicBlock`, the transformation
  would be beneficial in terms of output. Basically:
    1) That the number of `!(!=)` transformed into `(==)` outscores the
       number of correlated `(!=)` which are transformed into `!(==)`.
    2) That the number of `!(==)` transformed into `(!=)` outscores the
       number of correlated `(==)` which are transformed into `!(!=)`.
- Actually perform the transformation for those situations where the
  consensus agrees.
2023-06-26 15:23:00 +02:00
Alessandro Di Federico fa61c784c2 Reintroduce st0_x86 as floating point return value 2023-06-23 17:54:16 +02:00
Pietro Fezzardi 3016c2ad41 MakeModelGEPPass: enable operator [] on pointers
This commit enables to emit accesses with the square bracket array
access operator on pointers.

This is accomplished by adding an additional mandatory argument to
ModelGEP (AND NOT to ModelGEPRef) to represent this case.

MakeModelGEPPass is updated to take this into account, together with all
the other passes that handle ModelGEPs.
2023-06-20 18:15:24 +02:00
Pietro Fezzardi 6bf0de84ce Recompile tests with -Wimplicitly-unsigned-literal
This warning was disabled in the past. This commit handles the cas
properly and re-enables the warning in recompilation tests.
2023-06-14 16:06:11 +02:00
Valentina Sona 8dfd7c2d96 Add custom opcode BooleanNot 2023-06-12 14:17:34 +02:00
Djordje Todorovic f05c08547d ptml: Introduce PTMLBuilder class
By using this class we can create ptml::Tags without
XML tags. It is useful in the revng-c part when we
want to generate Plain C. All PTML Tags, from now on,
should be created via this class only.

In addition, port `Yield` library to be using this.
2023-06-09 17:15:30 +02:00
Djordje Todorovic 286eb4d734 c-backend: Introduce PTMLCBuilder
This will be used to generate plain C.
2023-06-09 15:40:23 +02:00