188 Commits

Author SHA1 Message Date
Alessandro Di Federico 903617e79e IRHelpers: turn some functions into IRBuilder::* 2026-06-19 09:18:16 +02:00
Pietro Fezzardi 74e3a6873e BeautifyGHAST: use mayHaveSideEffects() method 2026-04-10 15:27:24 +02:00
Alessandro Di Federico 5820908675 Remove and ban \file 2025-12-16 17:41:55 +01:00
Andrea Gussoni 646ad4f97a GenericRegion: improve Head election
The `Head` election now works in a bottom-up fashion (child regions are
processed before the parent ones), and ensures that the `Head` election
process is coherent across multiple nested regions.
This means that:
1) The late entries are coherent between the nested regions. If a node
   is selected as a late entry for a region, the parent region must
   follow this decision too.
2) If a node which is a `Head` candidate for a parent region, is
   selected as the `Head` for a child region, the same choice must be
   performed for the parent region too.
2025-12-03 16:37:17 +01:00
Pietro Fezzardi 48749974f0 IDS: simplifyTerminator doesn't merge default
With this commit, the `simplifyTerminator` helper function used by IDS
stops trying to merge the default cases with one of the other cases
arbitrarily.
Now, if the `UnreachableSuccessor` was reached via the default case, the
default case is still arbitrarily redirected to an arbitrary case
successor, but the case and the default do not get merged.
This keeps the logic of the transform simpler, and also allows for
easier successive manipulation by planned upcoming transforms.
2025-11-06 13:32:56 +01:00
Pietro Fezzardi 1480a3f0aa Move simplifyTerminator into IDS source file
The implementation of `simplifyTerminator` is very specific to the
operations of IDS, can be easily misused, and is not currently used
anywhere else in the codebase.
2025-11-06 13:32:56 +01:00
Pietro Fezzardi ff3ab1183d ScopeGraphUtils: improve simplifyTerminator docs 2025-11-06 13:32:56 +01:00
Alessandro Di Federico c883bed765 Drop Logger's StaticEnabled feature 2025-10-31 17:25:03 +01:00
Ivan Krysak 5b419540cc Disable IRBuilder checks in some additional places 2025-10-31 09:04:59 +01:00
Alessandro Di Federico f8bd4c3bac Move around some files in preparation for libtcg
* Make the following private headers public:
  * Lift/CPUStateAccessAnalysisPass.h
  * Lift/CSVOffsets.h
  * Lift/PTCDump.h
  * Lift/VariableManager.h
* Move from revngSupport to revngLift:
  * IRAnnotators.{h,cpp}
  * SelfReferencingDbgAnnotationWriter.{h,cpp}
* Move from revngSupport to revngModel:
  * FunctionTags.{h,cpp}
  * ProgramCounterHandler.{h,cpp}
* Move from revngSupport to revngRecompile:
  * OriginalAssemblyAnnotationWriter.{h,cpp}
2025-10-24 15:34:11 +02:00
Ivan Krysak 2ba5ca3e3d Suppress selected IRBuilder checks 2025-10-21 19:17:37 +03:00
Ivan Krysak 3561c2b907 Adopt IRBuilder wrapper 2025-10-21 19:17:01 +03:00
Ivan Krysak 77ea07c364 Minor improvements 2025-10-08 12:22:30 +03:00
Andrea Gussoni 855a9309ec MaterializeLoopScopes: drop pass
Drop the `MaterializeLoopScopes` pass after the re-design the loop
matching stage to work entirely on `clift`, without the need to insert a
`scope_closer` edge to guide the emission.

Simultaneously, drop the DAGify `Head` metadata insertion, since it will
not be checked anymore during the `MaterializeLoopScopes` pass.
2025-09-26 10:39:09 +02:00
Andrea Gussoni 92e8ec3982 ScopeGraphUtils: improve isDAG check
We now ensure that even in case of blocks disconnected from the entry,
the `isDAG` function still search for loops in such parts of the graph.

This is achieved by instantiating multiple `scc_iterator` on the blocks
composing the underlying `Graph`.
2025-09-26 10:39:09 +02:00
Andrea Gussoni e34b6db644 SelectScope: assert no disconnected blocks 2025-09-24 15:51:06 +02:00
Andrea Gussoni b679c8c611 MTGoTo: assert no disconnected blocks 2025-09-24 15:51:06 +02:00
Andrea Gussoni b18cd59d31 ESE: assert no disconnected blocks 2025-09-24 15:51:06 +02:00
Andrea Gussoni a5c1fdb3fe IDS: assert no disconnected blocks 2025-09-24 15:51:06 +02:00
Andrea Gussoni 46fe7415ca DAGify: assert no disconnected blocks 2025-09-24 15:51:06 +02:00
Andrea Gussoni 2ba365bc45 DAGify: fix Head election
During the `Head` election phase, we now introduce the following
additional criterion:
When processing a `GenericRegion` nested into an outer one (its
`ParentRegion`), if the inner `Region` contains the block that has been
elected as `Head` of the `ParentRegion`, we also force that block to be
the `Head` of the inner `GenericRegion`.

We add a unit test to check this behavior.
2025-09-24 15:51:06 +02:00
Andrea Gussoni d010ab806d MLoopScopes: introduce pass
The `MaterializeLoopScopes` is a scope-inducing transformation, with the
goal of inserting a `scope_closer` edge targeting the immediate post
dominator, outside each `GenericRegion`, in order to materialize the
scope representing the body of each `GenericRegion` on the `ScopeGraph`.
2025-09-10 13:36:09 +02:00
Andrea Gussoni 0281dbe040 DAGify: insert Head metadata 2025-09-10 13:36:09 +02:00
Andrea Gussoni 7965fa3039 DAGify: implement abnormal entry normalization
Perform the abnormal (late) entries normalization in the DAGify pass.

In this way, we are exploiting the information computed by
`GenericRegionInfo` as close as possible to where it is computed the
first time (in DAGify).

Actualize the unit tests to reflect these changes.
2025-09-10 13:36:09 +02:00
Andrea Gussoni fbd8c827e1 ScopeGraph: move helper functions
Move the `replaceSuccessors` and `simplifyTerminator` helper in the
`ScopeGraphUtils` library.
2025-09-10 13:36:08 +02:00
Andrea Gussoni 0332fda68d SelectScope: improve logging 2025-09-10 13:36:08 +02:00
Andrea Gussoni 53b756d169 GenericRegionPass: run on the ScopeGraph 2025-09-10 13:36:08 +02:00
Andrea Gussoni c0b9e3b425 DAGify: rename Logger 2025-09-10 13:36:08 +02:00
Andrea Gussoni 4143187942 DAGify: Logger typo 2025-09-10 13:36:08 +02:00
Andrea Gussoni 95ecd2d519 DAGify: compute GenericRegionInfo on raw CFG
Compute the `GenericRegionInfo` analysis on the raw CFG and not on the
`ScopeGraph`.
2025-09-10 13:36:08 +02:00
Andrea Gussoni 4b4fe388cb DAGify: improve variable name 2025-09-10 13:36:08 +02:00
Andrea Gussoni 0f85e5263c ScopeGraph: assert when moving scope_closer
Assert if we try to make a `scope_closer` edge a `goto` edge, since we
do not support this possibility.
2025-09-10 13:36:07 +02:00
Andrea Gussoni 4bfef217b6 IDS: preserve dbg metadata 2025-09-10 13:36:07 +02:00
Andrea Gussoni 70d7901648 ScopeGraph: preserve dbg for scope_closer 2025-09-10 13:36:07 +02:00
Andrea Gussoni bdb58a3b98 ScopeGraph: preserve dbg metadata for goto 2025-09-10 13:36:07 +02:00
Andrea Gussoni ba7ee595b5 BeautifyGHAST: introduce soft failure
Introduce an additional consistency check for loops having an empty body
at the beginning of the `beautify` pipeline.
2025-07-23 13:39:30 +02:00
Ivan Krysak a285ad2785 IRHelperRegister: get a comment from Description 2025-07-23 11:38:53 +02:00
Andrea Gussoni 6a90277db2 ScopeGraph: rename scope-graph-dumper 2025-07-23 11:34:13 +02:00
Andrea Gussoni c060f07ecd ScopeGraph: add scope-graph-output cl::opt 2025-07-23 11:34:13 +02:00
Andrea Gussoni 1ccce1c76a ScopeGraph: remove the ScopeGraphLogger library 2025-07-23 11:34:13 +02:00
Andrea Gussoni 1faa781e6a CommandLine: drop pathToStream
Remove `pathToStream` in favour of `llvm::ToolOutputFile`.
2025-07-23 11:34:13 +02:00
Andrea Gussoni 137a9384af BeautifyGHAST: introduce soft failure
Introduce a consistency check for ensuring that all the `ASTNode`s in
the `ASTTree` have a valid `Kind`. If this is not true, we soft fail.
2025-06-26 12:02:38 +02:00
Andrea Gussoni 506fdaabeb InlineDispatcherSwitch: soft fail
Relax assumption for `simplifySwitchBreak`.
2025-06-26 12:02:38 +02:00
Andrea Gussoni ecb823b120 InlineDispatcherSwitch: do not inspect empty loop
Do not inspect a loop with an empty `Body` (a `do-while` can legally
have it).
2025-06-26 12:02:38 +02:00
Andrea Gussoni c05ed14d23 BeautifyGHAST: introduce soft failure
Introduce a consistency check for loops having an empty body and not
being `DoWhile`s (the only type of empty loops admitted) before they
reach the serialization backend.
2025-06-26 12:02:26 +02:00
Andrea Gussoni 9ed971ab75 ASTTree: introduce soft failure
Soft fail for `copyASTNodesFrom`.
2025-06-26 09:34:26 +02:00
Andrea Gussoni 93b1205a5a BeautifyGHAST: drop matchSwitch
Remove the dead `matchSwitch` beautify pass.
2025-06-25 09:05:19 +02:00
Andrea Gussoni 0308a881ed BeautifyGHAST: introduce soft failure
Soft fail for `simplifyShortCircuit` and `simplifyTrivialShortCircuit`.
2025-06-23 12:00:59 +02:00
Andrea Gussoni 82c66fd4ca BeautifyGHAST: early return failure handling 2025-06-23 12:00:59 +02:00
Andrea Gussoni a5100a32ce RestructureCFG: introduce soft failure
Soft fail for `ContinueBackedges` size.
2025-06-20 14:04:51 +02:00