[PATCH] Add assertion to detect invalid registers in the PowerPC MC instruction lowering

Samuel Antao sfantao at us.ibm.com
Tue Mar 17 11:24:43 PDT 2015


I agree, I didn't notice we had PPC::NUM_TARGET_REGS.

Thanks!
Samuel


http://reviews.llvm.org/D8384

Files:
  lib/Target/PowerPC/PPCMCInstLower.cpp

Index: lib/Target/PowerPC/PPCMCInstLower.cpp
===================================================================
--- lib/Target/PowerPC/PPCMCInstLower.cpp
+++ lib/Target/PowerPC/PPCMCInstLower.cpp
@@ -184,6 +184,9 @@
       llvm_unreachable("unknown operand type");
     case MachineOperand::MO_Register:
       assert(!MO.getSubReg() && "Subregs should be eliminated!");
+      assert(MO.getReg() > PPC::NoRegister &&
+             MO.getReg() < PPC::NUM_TARGET_REGS &&
+             "Invalid register for this target!");
       MCOp = MCOperand::CreateReg(MO.getReg());
       break;
     case MachineOperand::MO_Immediate:

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8384.22108.patch
Type: text/x-patch
Size: 626 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150317/f6b61040/attachment.bin>


More information about the llvm-commits mailing list