22 Commits

Author SHA1 Message Date
Pietro Fezzardi a7aa3a0e1a ExitSSA: fix detection of incompatible PHINodes
The previous logic for detection of incompatible PHINodes was broken in
various different ways.
1. `return true` and `return false` were flipped, so it effectively did
   the opposite of what it was expected to do
2. `std::numeri_limits<Value *>::max()` yielded 0, breaking the lookup.

This commit fixes the condition for incompatible PHINodes and adds a lot
of logging.
2026-06-19 11:07:44 +02:00
Pietro Fezzardi a7d4a73d2d ExitSSA: don't exclude PHINodes with non-phi Users
Before this commit, the code never put in the same group two PHINodes if
one of them had a non-phi User. This condition was wrong and was
unnecessarily preventing valig PHINodes to be put in the same group.
This caused the generation of a lot more local variables than necessary.
2026-06-19 11:07:44 +02:00
Pietro Fezzardi 422319f4d8 ExitSSA: fix insertion of undefs
Before this commit we were replacing all uses of a PHI that were not
used by other PHIs with llvm::UndefValue. That was wrong. The
replacement is valid only if the use is used by a PHINode that is in the
same group. This commit fixes the condition for such a replacement to
take place.
2026-06-19 11:07:44 +02:00
Alessandro Di Federico 903617e79e IRHelpers: turn some functions into IRBuilder::* 2026-06-19 09:18:16 +02:00
Alessandro Di Federico 63734b7ca0 Canonicalize: ban pointers
In order to ensure there are no `alloca`s containing pointers, we change
the passes that emit them to emit instead integer scalars of the same
type.
2026-06-19 09:18:16 +02:00
Pietro Fezzardi b4aaf5814f ExitSSAPass.cpp: drop unused #include 2026-06-15 11:46:44 +02:00
Pietro Fezzardi ad18e6695c ExitSSA: make edge-splitting deterministic
Replace the stable_sort that ordered (block, value) entries by raw
BasicBlock* address in getIncomingUsesOfValuesFromBlocks with a
MapVector that groups entries by block in first-encountered
insertion order, and add a per-block stable_sort by use count
(descending). Same-block contiguity is now structural rather than
enforced by a sort, and the order in which the split basic blocks
are created and appended to the function no longer depends on
pointer values that vary across runs. The within-block ordering,
the use-count tie-breaking, and the rest of the edge-splitting
algorithm are preserved.
2026-06-03 16:33:15 +02:00
Pietro Fezzardi 23bd3f6c46 ExitSSA: don't declare to preserve the CFG 2026-04-10 15:27:24 +02:00
Pietro Fezzardi cc441ccd5c ExitSSA: fix insertion point past PHIs
Before this commit, the insertion point for load instructions was being
set before a PHINode, causing the IR to temporarily fail verification.
The effect of this logic bug did not propagate outside the pass, because
all PHINodes are removed at the end of the pass, but it made debugging
harder.

This commit fixes the problem by always setting the insert point after
all the PHINodes.
2026-04-10 15:27:24 +02:00
Alessandro Di Federico c883bed765 Drop Logger's StaticEnabled feature 2025-10-31 17:25:03 +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
Pietro Fezzardi 03e0de9458 Improve debug info propagation in legacy pipeline 2025-09-10 17:44:02 +02:00
Ivan Krysak 6113f7f6eb ExitSSA: preserve debug information 2025-09-10 17:44:01 +02:00
Alessandro Di Federico 8706fd8459 Initialize pointers to nullptr 2024-09-27 10:35:10 +02:00
Alessandro Di Federico e22ea4b2d8 Minor changes 2024-05-29 12:23:32 +02:00
Pietro Fezzardi 37340a91a7 Don't skip non-isolated Function in FunctionPass
Before this commit, many passes in revng-c were skipping over
non-isolated functions.

Now revng-pipeline takes care of removing non-isolated functions so that
check can be omitted everywhere.
2024-03-19 09:44:00 +01:00
Pietro Fezzardi 76739c2811 ExitSSA: better placement for StoreInst
This commits changes the ExitSSAPass to ensure that StoreInst are placed
ASAP, close to the computation of the incoming Values of the replaced
PHINode.
This generates IR that typically yields less local variables in
SwitchToStatements.
2024-03-19 09:44:00 +01:00
Pietro Fezzardi 6b022c9d30 Make ExitSSA deterministic 2024-03-19 09:44:00 +01:00
Alessandro Di Federico 0c212b66d9 Relicense to MIT 2024-02-29 17:03:36 +01:00
Alessandro Di Federico 7a2e315e29 s/IRCanonicalization/Canonicalize/g 2024-02-09 09:03:34 +01:00