Commit Graph

16 Commits

Author SHA1 Message Date
Ivan Krysak f494ae5f5f Standardize comment formatting
Use `*something*` instead of `_something_` when adding emphasis.
2025-02-13 13:09:50 +02:00
Alessandro Di Federico 143c315196 Merge revng-c into revng 2024-11-21 10:50:55 +01:00
Alessandro Di Federico 2e4f4d09b9 Remaining FunctionTags have been moved to revng 2024-11-04 15:09:56 +01:00
Alessandro Di Federico 36e2faad3d Introduce -Wunreachable-code-break 2024-10-31 17:19:55 +01:00
Andrea Gussoni 3763d781d3 InlineDispatcherSwitch: improve function signature 2024-05-07 14:17:05 +02:00
Andrea Gussoni 8d7beaf332 InlineDispatcherSwitch: remove SetNodes
During the `SwitchBreakSimplify` pass, we also remove the `SetNode`s
associated to `case` simplified.
2024-05-07 14:17:05 +02:00
Andrea Gussoni 6b5b2ee5f5 InlineDispatcherSwitch: do not inline non local CF
Do not inline loop related `break` and `continue` statements.
Indeed, inlining them would mean moving from the scope of a cycle, to an
inner one, non-local control flow statements, and this would break the
semantics.
2024-05-07 14:16:45 +02:00
Andrea Gussoni e926a80e1c InlineDispatcherSwitch: remove non-exercised code 2024-05-07 14:01:56 +02:00
Andrea Gussoni 55959f3fe5 InlineDispatcherSwitch: simplifySwitchBreak
Implement a new beautify pass which simplifies away `SwitchBreakNode`s
that constitute the entire body of `case`s in `switch`es, that do not,
have a `default` case. In such situations indeed, the semantics is,
preserved by removing the `SwitchBreakNode`s.
2024-03-15 14:50:42 +01:00
Andrea Gussoni a13c7677cf InlineDispatcherSwitch: generic weaved switches
We drop the assumption that each weaved `switch` must be nested inside
its related main `switch`, as a consequence of having generalized the
tiling algorithm in order to be able to emit a weaved `switch` as a AST
successors of the related main `switch`.
2024-03-15 14:27:00 +01:00
Andrea Gussoni 3defc2d431 InlineDispatcherSwitch: remove empty cases
Remove `switch` cases that may be simplified during the
`InlineDispatcherSwitch` beautify.
2024-03-15 14:27:00 +01:00
Alessandro Di Federico 0c212b66d9 Relicense to MIT 2024-02-29 17:03:36 +01:00
Andrea Gussoni d4d5e1a966 GenerateAst: rewrite SwitchNode tiling
Perform a complete rewrite of the `SwitchNode` tiling routine.
The tiling now works in the following way:
- When encountering a node which will produce a `SwitchNode` (either a
  standard `switch` or a dispatcher `switch`), we look for the following
  situations:
  1) We have a node, a successor (case) of the `switch`, which in turn
     is the successor of all the other successors (cases) of the
     `switch`.
  2) We have a node, not a successor (case) of the `switch`, which is
     the successor of all the successors (cases) of the `switch`.
- If we find such candidate node, this node will be the fallthrough of
  the `switch`. In addition, depending on whether the `switch` dominates
  the candidate fallthrough, we can incorporate it as the immediate
  successor of the `SwitchNode` we are building.
- There is currently an exception to the above, due to how we currently
  handle weaved `switch`es. In such cases, we mandate that the weaved
  `switch` is nested inside the main corresponding `switch`. For this
  reason, we have a special casing handling the "all inlined but one"
  situation in the new code, while this part could in theory be merged
  in the common criterion below, at the cost of dropping the invariant
  of the nesting of weaved switch`es.
2024-02-16 15:42:27 +01:00
Andrea Gussoni 2542833bd7 InlineDispatcherSwitch: simplify empty cases
Simplify `switch` cases that are simplified away during the dispatcher
`switch` inlining beautify.
Usually, we can simplify ast nodes by replacing them with `nullptr`s,
but due to how the `switch` cases work, we need to handle them in a
custom way.
2024-02-15 14:28:28 +01:00
Andrea Gussoni 4f642f0e71 InlineDispatcherSwitch: SwitchBreak inlining
Support the situation where we want to inline a `SwitchBreak` node,
which is represented with passing `nullptr` as `InlinedBody`.
2024-02-15 14:28:28 +01:00
Andrea Gussoni 078cc1222a InlineDispatcherSwitch: introduce beautify pass
We introduce the `InlineDispatcherSwitch` beautify pass. Its goal is to
try and inline the body of some of the `case`s of a exit dispatcher, in
place of the `SetNode` corresponding to that `case`, if this doesn't
introduce duplication in the code (i.e., a single `SetNode` for that
specific case value is present).

Additionally, if the inlining procedure is able to completely remove the
necessity of an exit dispatcher altogether, the pass removes it.

The pass is able to handle chains of weaved dispatcher `switch`es
referring to the same original dispatcher `switch`, by handling the
inline operation and the possible simplification level-wise.

The inlining procedure, cannot take place if a `SetNode` is contained in
the body of the case we are trying to inline, since this can possibly
break the semantics of the state variable of a loop, by placing a
`SetNode` in a more internal loop.
2023-11-28 16:19:08 +01:00