[polly] r250627 - Return nullptr if MemoryAccess list is empty

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 17 15:11:07 PDT 2015


Author: meinersbur
Date: Sat Oct 17 17:11:07 2015
New Revision: 250627

URL: http://llvm.org/viewvc/llvm-project?rev=250627&view=rev
Log:
Return nullptr if MemoryAccess list is empty

Other places (e.g. hoistInvariantLoads) assume that an empty lookup
will return nullptr. The situation can currently not arise because
MemoryAccesses are not removed before hoistInvariantLoads.


Modified:
    polly/trunk/include/polly/ScopInfo.h

Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=250627&r1=250626&r2=250627&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Sat Oct 17 17:11:07 2015
@@ -886,7 +886,9 @@ public:
   /// @brief Return the (scalar) memory accesses for @p Inst if any.
   MemoryAccessList *lookupAccessesFor(const Instruction *Inst) const {
     auto It = InstructionToAccess.find(Inst);
-    return It == InstructionToAccess.end() ? nullptr : It->getSecond();
+    if (It == InstructionToAccess.end())
+      return nullptr;
+    return It->getSecond()->empty() ? nullptr : It->getSecond();
   }
 
   /// @brief Return the __first__ (scalar) memory access for @p Inst.
@@ -899,7 +901,9 @@ public:
   /// @brief Return the __first__ (scalar) memory access for @p Inst if any.
   MemoryAccess *lookupAccessFor(const Instruction *Inst) const {
     auto It = InstructionToAccess.find(Inst);
-    return It == InstructionToAccess.end() ? nullptr : It->getSecond()->front();
+    if (It == InstructionToAccess.end())
+      return nullptr;
+    return It->getSecond()->empty() ? nullptr : It->getSecond()->front();
   }
 
   void setBasicBlock(BasicBlock *Block) {




More information about the llvm-commits mailing list