Commit Graph

13 Commits

Author SHA1 Message Date
Andrea Gussoni ca540399d4 Ensure that no backedges are left
Ensure that no backedges are left after the restructuring of all the
metaregions.

This additional assertion should help ensuring that no entries in the
`Backedges` set are left after the restructuring process, in turn making
it easier to spot bugs if backedges references are not handled correctly
during the steps of the restructuring.
2023-01-31 11:55:52 +01:00
Andrea Gussoni db48424629 Handle Code and Collapsed node in shortest path
Assign a value to cloned and collapsed nodes in terms of shortest path
from entry, which is a criterion we use to elect region entry.
The shortest path is computed at the beginning for the nodes present in
the CFG, but needs to keep updated for additional nodes that we insert
that may become loop entry candidates.
2023-01-20 17:03:24 +00:00
Andrea Gussoni febd4a2777 Remove from Backedges set retreating edges
During the creation of the exit dispatcher, take care of removing from
the `Backedges` set the additional backedge that is collapsed in case
two exiting backedges do target the same destination.

When this is not done, a ghost backedge is left inside the set, making
it not coherent with the state of the graph.

In addition, we add an assertion which ensures that during this phase of
the restructuring dummy nodes are present only as source of retreating
edges, and have one and only one successor.
2023-01-20 17:02:18 +00:00
Pietro Fezzardi 5e12f66ffb Drop old logger, use CombLogger instead 2023-01-18 17:58:09 +01:00
Pietro Fezzardi e9d84264ff Reduce the number of emitted local variables in C
This commit does various things oriented at reducing the number of local
variables emitted in C:
- MarkAssignments now know that @Copy and @Assign involving
  @LocalVariable only have side effects that affect the local variable
  itself; this enables to reduce the number of times we're forced to
  emit a local variable due to interfering side effects
- Drop the @AssignmentMarker FunctionTag; AddAssignmentMarkerPass now
  doesn't emit @AssignmentMarker anymore; instead it emits groups of
  @LocalVariable, @Copy, and @Assign, which benefit from the previous
  point
- Drop 2 MarkAssignments::Reasons: HasManyUses and HasUsesOutsideOfBB;
  both these have now been aggregated into the AlwaysAssign reason for
  simplicity, representing all reasons non involving side effects
- Update BeautifyGHAST and how it reasons about side effects when
  beautifying; before this commit it used @AssignmentMarker, now it
  looks at @Assign
- Simplify ExitSSA; before this commit it was trying hard to be smart on
  where it emitted the store instructions representing the incoming
  values of the PHI that was being destroyed; this seemed smart when we
  originally did it but it generated C code that was not really better
  to read, so this useless complexity is finally gone
2022-12-24 02:47:10 +01:00
Pietro Fezzardi a18cc9078f RestructureCFG.cpp: drop legacy removeFromRPOT
This can be replaced with concise idiomatic llvm::erase_value
2022-12-01 12:15:12 +01:00
Pietro Fezzardi 02bafadce7 RestructureCFG: new election of loop entry points
The new criterion for electing the entry point of a loop is based on the
number of edges that jump to the candidate entry from outside the
region.
2022-12-01 12:15:12 +01:00
Pietro Fezzardi c73b447c60 Use MFP in RegionCFG::inflate for reachable exits 2022-12-01 12:14:37 +01:00
Pietro Fezzardi d9d9294fe5 MarkAssignment: fix taint set and aggregate types 2022-06-28 10:28:08 +02:00
Pietro Fezzardi ad81bc7020 Enable addtional compilation warnings
These warnings are not enabled by default with -Wall nor with -Wextra.
2022-06-14 12:48:54 +02:00
Alvise de Faveri 99b06894c4 GHAST: Fix NotAAnd(Not)B short-circuiting 2022-06-01 11:24:20 +02:00
Pietro Fezzardi 4188b709be Merge BeautifyGHAST back into RestructureCFG
The beautification library was split into a separate library for
historical reason, having to do with LLVM passes, their dependencies,
and dirty hacks we had around.

Now the LLVM passes, and the hacks are gone, so we can merge back
everything together.
2022-05-11 15:19:34 +02:00
Pietro Fezzardi 604d370239 Remove LLVM passes RestructureCFG, BeautifyGHAST
Now that the late stage of the decompilation pipeline is managed with
revng-pipeline, and we have a standalone tool for decompilation, we
have no need to use LLVM passes anymore for those stages.

This commit also renames the directories to avoid the confusing Pass
suffix, not what LLVM passes are gone.
2022-05-11 15:19:34 +02:00