The `Successors` and `Predecessors` field on the `BasicBlockNode` are
now promoted from being a `std::pair` composed by the pointer to the
successor and the set representing the cases, to a pair between the
pointer to the successor and a new struct called `EdgeInfo`.
This struct is used to contain both the information about the cases, the
information representing whether and edge is inlined or not, and
possibly more information in the future.
This commit removes a call to untangle() that was performed before the
whole combing algorithm on the root RegionCFG.
The call was redundant before introducing the weaving, and became
plainly wrong after adding the weaving, because it ended up trying to
untangle the root RegionCFG before weaving (which is supposed to run
first).
Removing the dedicated call fixes the bug, because weaving is performed
first as part of the call to generateAst().
Reorganize attribute `Kind` incorporating it into the `Type` attribute,
by lowering its memory footprint.
Modified the constructors, some accessors and helpers accordingly.
Introduced various untangle algorithm improvements:
- Improve untangle edge reorganization: improve the criterion used for
reorganizing the edges between the old postdominator and the cloned
one, after an inline procedure is attempted during the untangle.
- Untangle counter: introduce two new counters which take into account
the number of times the untangle procedure is attempted and the actual
times it is performed.
- Disable not dominated restriction: disable the criterion which
restricts the untangle opportunities if we do not dominate entirely
at least one of the two branches. This has likely broken the
assumption that the postdominators of nodes do not changes after each
untangle step has been carried out.
- Change dominance criterion: the dominance of the nodes belonging to
the `then` and `else` nodes is now checked not with respect to the
conditional node, but to the `then` and `else` edges of the conditional
node.
- Untangle eager inlining: now, when the untangle procedure finds a
suitable candidate for the inlining, proceed the complete inlining
starting from the selected branch. By default new clones of all the
nodes till the exit are created and attached to the branch, while the
original nodes are detached. An additional pass which removes eventual
dandling nodes (nodes which are not reachable from the entry node of
the graph) is performed after the eager inlining. This means that if
no other incoming edges to this group of nodes is present the original
nodes will be purged.
The post dominator now is updated during the inlining analysis, and
the paths conducting to inlined exits are not taken into account for
the post dominator computation.
- Enable untangle for mixed branches: perform the untangle even if the
`then` and `else` branches share nodes. This was not feasible before
because without the eager inlining we couldn't decide which edge to
attach to the new postdominator clone. This problem is not present
anymore, so we can handle any kind of topology in the untangle.
- Improved also the analysis information serialized by the decompiler.
Add a flag to enable the decompilation of a single function.
In order to have a single flag shared between the `RestructureCFGPass`
and the `CDecompilerPass`, we added a new dedicated decompilation unit
called `TargetFunctionOption`.
`ExprNode` and its child classes use LLVM-style RTTI.
Until now their destruction was not handled properly, causing the
constructor-destructor type mismatch warnings on ASAN.
Despite this all the code was working properly, but just for luck,
because of the fact that these classes are very shallow.
This commit fixes the issue, and allow `ExprNode` and its child classes
to be extended without worrying about wrong destructors being invoked.
Replicate the changes made by this commit
f2a0df309f78e1b5d7c5f81ada5110523644559e perfomed by Pietro on the
branch containing the development fixes for `revng-c`.
Add new headers files (terminating with `BB`, as `BasicBlockNodeBB.h`),
which will be used as the new header files by the users, and which
contain a declaration of the template instantiation, and a `using`
aliasing the instantiation.
This has been made to comply with the `-Wundefined-func-template` flag,
automatically enabled when using `-Weverything`
Enhanced the `findReachableNodes` algorithm, with a new `StackSet`
parallel data structure which is used to quickly check if we are
encountering a node already on the visit stack.
Modified the `findReachableNodes` to include in the returned set of
nodes also nodes which are encountered on self loop paths and that
should consequently be included in this set.
Add a new dummy node as the source of each backedge found in the graph,
during the preprocessing.
This help in the semplification phase of the SCS, since the new dummy
node helps triggering merging of metaregions with have a non empty
intersection.
The new SCS merging criterion, checks that there are no abnormal
retreating nodes between SCS, meaning retreatings which exit from the
current SCS and do not point to the head of another SCS.
This kind of situation, if ignored could cause the introduction of some
cycles between outlined nodes and existing nodes, inserting new cycles
during the restructuring, which is a behavior which we aim to avoid.
When outlining nodes, we now include them in eventual parent metaregions
that included the nodes collapsed.
This should lead to minor duplication (as in the `cp` benchmark), since
we avoid duplicating two times nodes if also the external region causes
the first iteration outlining.
We know keep updated the RPOT during node removals (otherwise we have
situation of pointer clashes) instead of recomputing it at each
metaregion restructuring iteration.
To avoid skeing the results the serialization of `DOT` intermediate file
for both restructuring and AST semplification passes are now serialized
only when the corresponding loggers (`CombLogger` and `BeautifyLogger`)
are enabled.
When a retreating edge involves as source node a `SetNode` belonging to
an internal region (which should be the default `SetNode` that remains
outside the collpased node), move it just after the `CheckNode` that is
being introduced, so that the semantics of the code remains untouched.
Use a `llvm::SmallString` for the `Name` field of `BasicBlockNode`.
This enables us to modify the name of the node, which is very useful
during debugging and manual inspection of the graph serialized in
output.
Fix the metaregion identification phase, in particular the add of the
addditional nodes merged when encountering a node which is the target of
a backedge identifying another metaregion.
The add of the additional nodes must be done in a fixed point fashion,
otherwise in case of dependent insertions the order of the nodes
triggers different behaviours (and bugs).