Skip to content

[ARM] Prevent converting virtual register to MCRegister. #122862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Jan 14, 2025

MCRegister should only be used for physical reigsters.

MCRegister should only be used for physical reigsters.
@llvmbot
Copy link
Member

llvmbot commented Jan 14, 2025

@llvm/pr-subscribers-backend-arm

Author: Craig Topper (topperc)

Changes

MCRegister should only be used for physical reigsters.


Full diff: https://github.com/llvm/llvm-project/pull/122862.diff

1 Files Affected:

  • (modified) llvm/lib/Target/ARM/ThumbRegisterInfo.cpp (+2-2)
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) {

@topperc topperc merged commit c7fddf5 into llvm:main Jan 14, 2025
10 checks passed
@topperc topperc deleted the pr/arm-mcregister branch January 14, 2025 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants