[llvm] [CodeGen] Move rollback capabilities outside of the rematerializer (PR #184341)
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 1 16:55:03 PDT 2026
================
@@ -361,27 +355,26 @@ class Rematerializer {
MachineBasicBlock::iterator InsertPos,
DependencyReuseInfo &DRI);
- /// Rolls back all rematerializations of original register \p RootIdx,
- /// transfering all their users back to it and permanently deleting them from
- /// the MIR. The root register is revived if it was fully rematerialized (this
- /// requires that rollback support was set at that time). Transitive
- /// dependencies of the root register that were fully rematerialized are
- /// re-vived at their original positions; this requires that rollback support
- /// was set when they were rematerialized.
- void rollbackRematsOf(RegisterIdx RootIdx);
-
- /// Rolls back register \p RematIdx (which must be a rematerialization)
- /// transfering all its users back to its origin. The latter is revived if it
- /// was fully rematerialized (this requires that rollback support was set at
- /// that time).
- void rollback(RegisterIdx RematIdx);
-
- /// Revives original register \p RootIdx at its original position in the MIR
- /// if it was fully rematerialized with rollback support set. Transitive
- /// dependencies of the root register that were fully rematerialized are
- /// revived at their original positions; this requires that rollback support
- /// was set when they were themselves rematerialized.
- void reviveRegIfDead(RegisterIdx RootIdx);
+ /// Rematerializes register \p RegIdx at \p InsertPos in \p UseRegion, adding
+ /// the new rematerializable register to the backing vector \ref Regs and
+ /// returning its index inside the vector. Sets the new register's
+ /// rematerializable dependencies to \p Dependencies (these are assumed to
+ /// already exist in the MIR) and its unrematerializable dependencies to the
+ /// same as \p RegIdx. The new register initially has no user. Since the
+ /// method appends to \ref Regs, references to elements within it should be
+ /// considered invalidated across calls to this method unless the vector can
+ /// be guaranteed to have enough space for an extra element.
+ RegisterIdx rematerializeReg(RegisterIdx RegIdx, unsigned UseRegion,
+ MachineBasicBlock::iterator InsertPos,
+ SmallVectorImpl<Reg::Dependency> &&Dependencies);
+
+ /// Re-creates a previously deleted register \p RegIdx at \p InsertPos in \p
----------------
qcolombet wrote:
Same question on the InsertPos? Before or after?
https://github.com/llvm/llvm-project/pull/184341
More information about the llvm-commits
mailing list