[llvm] r230147 - R600/SI: Don't crash when getting immediate operand size

Matt Arsenault Matthew.Arsenault at amd.com
Sat Feb 21 13:29:04 PST 2015


Author: arsenm
Date: Sat Feb 21 15:29:04 2015
New Revision: 230147

URL: http://llvm.org/viewvc/llvm-project?rev=230147&view=rev
Log:
R600/SI: Don't crash when getting immediate operand size

Modified:
    llvm/trunk/lib/Target/R600/SIInstrInfo.h

Modified: llvm/trunk/lib/Target/R600/SIInstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/SIInstrInfo.h?rev=230147&r1=230146&r2=230147&view=diff
==============================================================================
--- llvm/trunk/lib/Target/R600/SIInstrInfo.h (original)
+++ llvm/trunk/lib/Target/R600/SIInstrInfo.h Sat Feb 21 15:29:04 2015
@@ -254,6 +254,13 @@ public:
   // instruction opcode.
   unsigned getOpSize(uint16_t Opcode, unsigned OpNo) const {
     const MCOperandInfo &OpInfo = get(Opcode).OpInfo[OpNo];
+
+    if (OpInfo.RegClass == -1) {
+      // If this is an immediate operand, this must be a 32-bit literal.
+      assert(OpInfo.OperandType == MCOI::OPERAND_IMMEDIATE);
+      return 4;
+    }
+
     return RI.getRegClass(OpInfo.RegClass)->getSize();
   }
 





More information about the llvm-commits mailing list