[llvm] [ARM] Prevent converting virtual register to MCRegister. (PR #122862)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 13 21:47:53 PST 2025
https://github.com/topperc created https://github.com/llvm/llvm-project/pull/122862
MCRegister should only be used for physical reigsters.
>From 4a9dfe20bee2678e573bdea675b385a5ef2fe126 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Mon, 13 Jan 2025 21:11:08 -0800
Subject: [PATCH] [ARM] Prevent converting virtual register to MCRegister.
MCRegister should only be used for physical reigsters.
---
llvm/lib/Target/ARM/ThumbRegisterInfo.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Target/ARM/ThumbRegisterInfo.cpp b/llvm/lib/Target/ARM/ThumbRegisterInfo.cpp
index 381ade5c85a65e..4fe4ed47e0081d 100644
--- a/llvm/lib/Target/ARM/ThumbRegisterInfo.cpp
+++ b/llvm/lib/Target/ARM/ThumbRegisterInfo.cpp
@@ -139,7 +139,7 @@ static void emitThumbRegPlusImmInReg(
return;
}
- bool isHigh = !isARMLowRegister(DestReg) ||
+ bool isHigh = DestReg.isVirtual() || !isARMLowRegister(DestReg) ||
(BaseReg != 0 && !isARMLowRegister(BaseReg));
bool isSub = false;
// Subtract doesn't have high register version. Load the negative value
@@ -153,7 +153,7 @@ static void emitThumbRegPlusImmInReg(
Register LdReg = DestReg;
if (DestReg == ARM::SP)
assert(BaseReg == ARM::SP && "Unexpected!");
- if (!isARMLowRegister(DestReg) && !DestReg.isVirtual())
+ if (!DestReg.isVirtual() && !isARMLowRegister(DestReg))
LdReg = MF.getRegInfo().createVirtualRegister(&ARM::tGPRRegClass);
if (NumBytes <= 255 && NumBytes >= 0 && CanChangeCC) {
More information about the llvm-commits
mailing list