[llvm] r289337 - AMDGPU: Fix asan errors when folding operands

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 10 11:58:01 PST 2016


Author: arsenm
Date: Sat Dec 10 13:58:00 2016
New Revision: 289337

URL: http://llvm.org/viewvc/llvm-project?rev=289337&view=rev
Log:
AMDGPU: Fix asan errors when folding operands

This was failing when trying to fold immediates into operand 1 of a
phi, which only has one statically known operand.

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

Modified: llvm/trunk/lib/Target/AMDGPU/SIInstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIInstrInfo.h?rev=289337&r1=289336&r2=289337&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIInstrInfo.h (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIInstrInfo.h Sat Dec 10 13:58:00 2016
@@ -500,7 +500,7 @@ public:
                         const MachineOperand &DefMO) const {
     assert(UseMO.getParent() == &MI);
     int OpIdx = MI.getOperandNo(&UseMO);
-    if (!MI.getDesc().OpInfo || OpIdx > MI.getDesc().NumOperands) {
+    if (!MI.getDesc().OpInfo || OpIdx >= MI.getDesc().NumOperands) {
       return false;
     }
 
@@ -516,7 +516,7 @@ public:
 
   bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx,
                         const MachineOperand &MO) const {
-    if (!MI.getDesc().OpInfo || OpIdx > MI.getDesc().NumOperands)
+    if (!MI.getDesc().OpInfo || OpIdx >= MI.getDesc().NumOperands)
       return false;
 
     if (MI.isCopy()) {




More information about the llvm-commits mailing list