Handle regmasks in Thumb1RegisterInfo::saveScavengerRegister().
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Thu, 1 Mar 2012 22:57:32 +0000 (22:57 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Thu, 1 Mar 2012 22:57:32 +0000 (22:57 +0000)
This function could have r12 live across a function call when compiling
thumb1 code.

The test case for this is not included because it is very long. It must
provoke emergency spilling near a function call. The behavior is
provoked by MultiSource/Applications/JM/lencod, and it triggers an
assertion in the scavenger.

<rdar://problem/10963642>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151855 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/Thumb1RegisterInfo.cpp

index 1613acd7a6029e9590005ee20359bbd3680df372..6b8bf0e63986b6861ade532ec03bf976f683b49e 100644 (file)
@@ -571,6 +571,11 @@ Thumb1RegisterInfo::saveScavengerRegister(MachineBasicBlock &MBB,
     // If this instruction affects R12, adjust our restore point.
     for (unsigned i = 0, e = II->getNumOperands(); i != e; ++i) {
       const MachineOperand &MO = II->getOperand(i);
+      if (MO.isRegMask() && MO.clobbersPhysReg(ARM::R12)) {
+        UseMI = II;
+        done = true;
+        break;
+      }
       if (!MO.isReg() || MO.isUndef() || !MO.getReg() ||
           TargetRegisterInfo::isVirtualRegister(MO.getReg()))
         continue;