[llvm] r303840 - [SelectionDAG] Fix off by one in a compare in getOperationAction.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed May 24 22:38:40 PDT 2017


Author: ctopper
Date: Thu May 25 00:38:40 2017
New Revision: 303840

URL: http://llvm.org/viewvc/llvm-project?rev=303840&view=rev
Log:
[SelectionDAG] Fix off by one in a compare in getOperationAction.

If Op is equal to array_lengthof, the lookup would be out of bounds, but we were only checking for greater than. I suspect nothing ever passes in the equal value because its a sentinel to mark the end of the builtin opcodes and not a real opcode.

So really this fix is just so that the code looks right and makes sense.

Modified:
    llvm/trunk/include/llvm/Target/TargetLowering.h

Modified: llvm/trunk/include/llvm/Target/TargetLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=303840&r1=303839&r2=303840&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetLowering.h (original)
+++ llvm/trunk/include/llvm/Target/TargetLowering.h Thu May 25 00:38:40 2017
@@ -738,7 +738,7 @@ public:
     if (VT.isExtended()) return Expand;
     // If a target-specific SDNode requires legalization, require the target
     // to provide custom legalization for it.
-    if (Op > array_lengthof(OpActions[0])) return Custom;
+    if (Op >= array_lengthof(OpActions[0])) return Custom;
     return OpActions[(unsigned)VT.getSimpleVT().SimpleTy][Op];
   }
 




More information about the llvm-commits mailing list