[PATCH] D19810: [scan-build] fix logic error warning in LLVM AMDGPU target code base

Apelete Seketeli via llvm-commits llvm-commits at lists.llvm.org
Mon May 2 09:32:37 PDT 2016


apelete created this revision.
apelete added a reviewer: tstellarAMD.
apelete added a subscriber: llvm-commits.
Herald added a subscriber: arsenm.

This patch fixes a logic error warning of the type "called c++ object
pointer is null" in AMDGPU code base.

Signed-off-by: Apelete Seketeli <apelete at seketeli.net>

http://reviews.llvm.org/D19810

Files:
  lib/Target/AMDGPU/SIInstrInfo.cpp

Index: lib/Target/AMDGPU/SIInstrInfo.cpp
===================================================================
--- lib/Target/AMDGPU/SIInstrInfo.cpp
+++ lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -1848,9 +1848,15 @@
   const MCOperandInfo &OpInfo = InstDesc.OpInfo[OpIdx];
   const TargetRegisterClass *DefinedRC =
       OpInfo.RegClass != -1 ? RI.getRegClass(OpInfo.RegClass) : nullptr;
+
   if (!MO)
     MO = &MI->getOperand(OpIdx);
 
+  if (!DefinedRC) {
+    // This operand expects an immediate.
+    return !MO->isReg();
+  }
+
   if (isVALU(*MI) &&
       usesConstantBus(MRI, *MO, DefinedRC->getSize())) {
 
@@ -1875,15 +1881,9 @@
     return isLegalRegOperand(MRI, OpInfo, *MO);
   }
 
-
   // Handle non-register types that are treated like immediates.
   assert(MO->isImm() || MO->isTargetIndex() || MO->isFI());
 
-  if (!DefinedRC) {
-    // This operand expects an immediate.
-    return true;
-  }
-
   return isImmOperandLegal(MI, OpIdx, *MO);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19810.55833.patch
Type: text/x-patch
Size: 959 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160502/a835c47e/attachment.bin>


More information about the llvm-commits mailing list