Commit Graph

6256 Commits

Author SHA1 Message Date
Andrea Gussoni f45b706972 RestructureCFG: fail when retreating not to head
Introduce decompilation failure when not all the retreatings of a
`Region` point to the elected head node.
2025-06-19 11:36:49 +02:00
Andrea Gussoni 2ed4bffc53 DecompileFunction: early return failure handling 2025-06-19 11:36:49 +02:00
Andrea Gussoni da31adc83c ASTTree: clear internal fields on constructor 2025-06-19 09:48:39 +02:00
Andrea Gussoni 3b76bbb3e7 RestructureCFG: fix exit dispatcher deduplication
Fix the deduplication of dummy nodes in exit dispatcher creation,
checking that no other path using them exists before their removal.
2025-06-18 18:18:11 +02:00
Andrea Gussoni 4a2594f0ed RestructureCFG: log MetaRegions after update 2025-06-18 18:18:11 +02:00
Pietro Fezzardi b5115fd35a Merge branch 'feature/fix-csaa-constant-unknown' 2025-06-18 14:39:30 +02:00
Pietro Fezzardi 38c6fa6368 CSAA: fix unknown CSVOffset for constants 2025-06-18 14:38:38 +02:00
Pietro Fezzardi b0bb497911 CSAA: improve logging 2025-06-18 13:25:40 +02:00
Pietro Fezzardi 3afe53075e CSAA: fix return value on changes
Before this commit, `forceEmptyMetadata` did not return a bool to notify
when it changed something.
This in turn caused the pass to return the wrong value when the only
change applied was to force the empty metadata.

This commit fixes the issue, letting `forceEmptyMetadata` return a bool,
and propagating that until where it matters.
2025-06-18 13:23:15 +02:00
Pietro Fezzardi 2ce8b081c3 Merge branch 'feature/ids-all-at-once' 2025-06-12 15:34:24 +02:00
Andrea Gussoni be72da8b48 IDS: improve collection restart criterion
We now reduce the number of cases in which we restart the collection of
the `DivergenceDescriptor`s after a IDS modification on the `ScopeGraph`
is performed.

We previously restarted the collection after each IDS transformation.

Now, restart is only performed after IDS is applied on a `Conditional`
node whose all successors are divergent exits which are `goto` exits.
After such `Conditional` is processed, it may happen that a new `goto`
exit becomes divergent for another `Conditional` upwards in the
`ScopeGraph`.
Therefore, if we do not restart, it may happen that a non-`goto` exit is
processed before a `goto` exit, which may lead to suboptimal situations
in the emitted number of `goto`s, due to how IDS interacts with
`MaterializeTrivialGotos`.
2025-06-12 15:31:38 +02:00
Andrea Gussoni b786a657bf IDS: collect multiple divergent successors
When performing the IDS procedure for a divergence which is entered
through multiple `Successor`s of the `Conditional`, we insert a `Head`
header which collects the entry to the scope, in order to maintain
decidedness if there is a common post-dominator to all the `Successor`s
(similar to what weaving did).
2025-06-12 15:31:38 +02:00
Andrea Gussoni 3527291bd9 IDS: multiple divergence implementation
Perform the IDS transformation, by taking into account possible multiple
divergent scopes for a certain conditional node at the same time.

This reduces the run times, since it reduces the number of time IDS is
called on a conditional, but mostly proceduce a more _compact_
`ScopeGraph`, where all the divergent scopes for a certain conditional
node rejoing the path toward the one true exit in a single point,
instead of having a chain of IDS resulting regions.

Make IDS unit tests compliant with the new multiple divergence
implementation.
2025-06-12 15:31:38 +02:00
Andrea Gussoni 349192d404 SelectScope: single ScopeGraphBuilder instance 2025-06-12 15:31:38 +02:00
Andrea Gussoni 458ca46b02 ESE: single ScopeGraphBuilder instance 2025-06-12 15:31:38 +02:00
Andrea Gussoni cf7fba7beb DAGify: single ScopeGraphBuilder instance 2025-06-12 15:31:38 +02:00
Andrea Gussoni 9ddb7465ba ScopeGraph: optimize ScopeGraphBuilder 2025-06-12 15:31:38 +02:00
Andrea Gussoni 333903e86e ScopeGraph: ScopeGraphBuilder const methods 2025-06-12 15:31:38 +02:00
Pietro Fezzardi f00184d8af Merge branch 'feature/dla-fix-merged-ptr-scalars' 2025-06-11 16:37:52 +02:00
Pietro Fezzardi ff747c069d DLA: fix erased ptr in MergePointeesOfPointerUnion
This commit adds handling for a corner case of
MergePointeesOfPointerUnion, that wasn't handled before.
Said corner case happens when one of the scalars that gets merged as
part of the DLAStep operations is also itself a pointer to another
scalar that gets merged.
This wasn't accounted for before this commit, but it's actually a valid
scenario that can happen on some inputs.
2025-06-11 16:37:19 +02:00
Pietro Fezzardi 62c5cfc09d DLA: improve MergePointeesOfPointerUnion logging 2025-06-11 11:18:42 +02:00
Pietro Fezzardi 2583f9ea9a InitModelTypes: fix addOperandType return value
Before this commit it occasionally returned true even when it did not
add any new operand type.
2025-06-09 15:39:28 +02:00
Pietro Fezzardi 805b13de28 DLA: fix assertion in MakeModelTypes.cpp 2025-06-05 18:24:46 +02:00
Pietro Fezzardi b73ce1b17c Merge branch 'feature/clift-changes-2' 2025-06-04 15:14:06 +02:00
Lauri Vasama 03a21855ab Require Clift module attribute in MLIRContainer 2025-06-04 15:13:47 +02:00
Lauri Vasama 4bf1d8fe99 Remove Clift backend transform and model option 2025-06-04 15:13:47 +02:00
Lauri Vasama c956904b8e Add Clift backend pipe and update tests 2025-06-04 15:13:47 +02:00
Lauri Vasama 73ca618c4d Simplify import-clift-types pipe and tests 2025-06-04 15:13:47 +02:00
Lauri Vasama 7c9031bd98 Change MLIRContainer to focus on Clift, rename 2025-06-04 15:13:47 +02:00
Lauri Vasama cd827d6a14 Remove import-clift-types pipe 2025-06-04 15:13:47 +02:00
Lauri Vasama d21325ef55 Remove model dependency in CliftTypes.cpp 2025-06-04 15:13:47 +02:00
Lauri Vasama 13b554d64a Remove unused include in CliftOps.cpp 2025-06-04 15:13:47 +02:00
Lauri Vasama cc94e2d290 Constrain returnable types 2025-06-04 15:13:47 +02:00
Lauri Vasama 047511b1ed Remove Clift break and continue ops 2025-06-04 15:13:47 +02:00
Lauri Vasama 3e065cb23d Remove local and label names 2025-06-04 15:13:47 +02:00
Lauri Vasama fdbc7b57fb Add SwitchOp::getCaseRegions 2025-06-04 15:13:47 +02:00
Lauri Vasama e24c881559 Remove DLTI and LLVMIR dialects from MLIRContainer 2025-06-04 15:13:47 +02:00
Lauri Vasama a0ec1305f1 Move ReturnOp type verification to FunctionOp 2025-06-04 15:13:47 +02:00
Lauri Vasama f0091e699f Remove clift::ModuleOp
A new dialect attribute is instead used to verify mlir::ModuleOp:

```
module attributes {clift.module} {
}
```
2025-06-04 15:13:47 +02:00
Lauri Vasama 51c4ed8201 Make Clift.td formatting more consistent 2025-06-04 15:13:47 +02:00
Lauri Vasama 206de51c69 Add API for helper PTML references by name
The Clift backend does not have access to any llvm::Function objects so
the helper C identifiers must be derived from the helper name alone.
2025-06-04 15:13:47 +02:00
Lauri Vasama 6f3c8ee418 Add PrimitiveType builder with default const=false 2025-06-04 15:13:47 +02:00
Lauri Vasama a7eb86174b Add revng/Support/Identifier.h for id validation 2025-06-04 15:13:47 +02:00
Lauri Vasama d1dfbc4b01 Emit implicit switch breaks from Clift 2025-06-04 15:13:47 +02:00
Lauri Vasama 137bb6f95b Fix register set member access emission 2025-06-04 15:13:47 +02:00
Lauri Vasama f94b28b7e4 Add missing newline after if without else 2025-06-04 15:13:47 +02:00
Lauri Vasama d17d23b8fc Add getHandle on GlobalOpInterface 2025-06-04 15:13:47 +02:00
Lauri Vasama a3ee0349a6 Inherit GlobalOpInterface from Symbol 2025-06-04 15:13:47 +02:00
Lauri Vasama c44df5d591 Improve CliftOpInterfaces formatting consistency 2025-06-04 15:13:47 +02:00
Lauri Vasama 81dcea49e4 Fix printing of CallOp on function pointer 2025-06-04 15:13:47 +02:00