https://github.com/easyonaadit updated https://github.com/llvm/llvm-project/pull/174999
>From 4cbed3bef07f5077dada9f816d1fcece3e2a4601 Mon Sep 17 00:00:00 2001 From: Christudasan Devadasan <[email protected]> Date: Wed, 7 Jan 2026 12:42:45 +0000 Subject: [PATCH] [CodeGen] Enhance createFrom for sub-reg aware cloning Instead of just cloning the virtual register, this function now creates a new virtual register derived from a subregister class of the original value. --- llvm/include/llvm/CodeGen/LiveRangeEdit.h | 7 +++++-- llvm/lib/CodeGen/LiveRangeEdit.cpp | 10 +++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/CodeGen/LiveRangeEdit.h b/llvm/include/llvm/CodeGen/LiveRangeEdit.h index 00e1b6623efb4..c0c16f12eac49 100644 --- a/llvm/include/llvm/CodeGen/LiveRangeEdit.h +++ b/llvm/include/llvm/CodeGen/LiveRangeEdit.h @@ -155,8 +155,11 @@ class LLVM_ABI LiveRangeEdit : private MachineRegisterInfo::Delegate { ArrayRef<Register> regs() const { return ArrayRef(NewRegs).slice(FirstNew); } - /// createFrom - Create a new virtual register based on OldReg. - Register createFrom(Register OldReg); + /// createFrom - Create a new virtual register based on OldReg. If \p RC is + /// non-null, constrain the register class of the new vreg. Partial reloads + /// of tuple regclasses will feed-in a subregclass derived from the regclass + /// of OldReg. + Register createFrom(Register OldReg, const TargetRegisterClass *RC = nullptr); /// create - Create a new register with the same class and original slot as /// parent. diff --git a/llvm/lib/CodeGen/LiveRangeEdit.cpp b/llvm/lib/CodeGen/LiveRangeEdit.cpp index 1d6b835f16468..9e0c6c8558d2c 100644 --- a/llvm/lib/CodeGen/LiveRangeEdit.cpp +++ b/llvm/lib/CodeGen/LiveRangeEdit.cpp @@ -52,8 +52,16 @@ LiveInterval &LiveRangeEdit::createEmptyIntervalFrom(Register OldReg, return LI; } -Register LiveRangeEdit::createFrom(Register OldReg) { +Register LiveRangeEdit::createFrom(Register OldReg, + const TargetRegisterClass *RC) { Register VReg = MRI.cloneVirtualRegister(OldReg); + + // If RC is given, set it now. This is needed for cloning a new VReg with a + // smaller RC from its original virtual register, mainly used for subreg + // reload. The cloning is done first to ensure the vreg flags are preserved. + if (RC) + MRI.setRegClass(VReg, RC); + if (VRM) { VRM->setIsSplitFromReg(VReg, VRM->getOriginal(OldReg)); } _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
