[llvm] r371975 - [VPlanSLP] Don't dereference a cast_or_null<VPInstruction> result. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 16 04:22:45 PDT 2019


Author: rksimon
Date: Mon Sep 16 04:22:44 2019
New Revision: 371975

URL: http://llvm.org/viewvc/llvm-project?rev=371975&view=rev
Log:
[VPlanSLP] Don't dereference a cast_or_null<VPInstruction> result. NFCI.

The static analyzer is warning about a potential null dereference of the cast_or_null result, I've split the cast_or_null check from the ->getUnderlyingInstr() call to avoid this, but it appears that we weren't seeing any null pointers in the dumped bundles in the first place.

Modified:
    llvm/trunk/lib/Transforms/Vectorize/VPlanSLP.cpp

Modified: llvm/trunk/lib/Transforms/Vectorize/VPlanSLP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/VPlanSLP.cpp?rev=371975&r1=371974&r2=371975&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/VPlanSLP.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/VPlanSLP.cpp Mon Sep 16 04:22:44 2019
@@ -346,11 +346,14 @@ SmallVector<VPlanSlp::MultiNodeOpTy, 4>
 
 void VPlanSlp::dumpBundle(ArrayRef<VPValue *> Values) {
   dbgs() << " Ops: ";
-  for (auto Op : Values)
-    if (auto *Instr = cast_or_null<VPInstruction>(Op)->getUnderlyingInstr())
-      dbgs() << *Instr << " | ";
-    else
-      dbgs() << " nullptr | ";
+  for (auto Op : Values) {
+    if (auto *VPInstr = cast_or_null<VPInstruction>(Op))
+      if (auto *Instr = VPInstr->getUnderlyingInstr()) {
+        dbgs() << *Instr << " | ";
+        continue;
+      }
+    dbgs() << " nullptr | ";
+  }
   dbgs() << "\n";
 }
 




More information about the llvm-commits mailing list