AMDGPU/SI: Fix crash on physical registers in SIInstrInfo::isOperandLegal()
authorTom Stellard <thomas.stellard@amd.com>
Thu, 9 Jul 2015 16:30:27 +0000 (16:30 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Thu, 9 Jul 2015 16:30:27 +0000 (16:30 +0000)
No test case for this.  I ran into it while working on some improvements
to SIShrinkInstructions.cpp.

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

lib/Target/AMDGPU/SIInstrInfo.cpp

index eb96bd0227b27611ba0d0f93cd49eadfd7722bd3..288ab7523e3d0de1d0695a60d8285414e6fb09e7 100644 (file)
@@ -1625,7 +1625,10 @@ bool SIInstrInfo::isOperandLegal(const MachineInstr *MI, unsigned OpIdx,
 
   if (MO->isReg()) {
     assert(DefinedRC);
-    const TargetRegisterClass *RC = MRI.getRegClass(MO->getReg());
+    const TargetRegisterClass *RC =
+        TargetRegisterInfo::isVirtualRegister(MO->getReg()) ?
+            MRI.getRegClass(MO->getReg()) :
+            RI.getPhysRegClass(MO->getReg());
 
     // In order to be legal, the common sub-class must be equal to the
     // class of the current operand.  For example: