Fix a case where GVN was failing to return true when it had, in fact, modified
authorOwen Anderson <resistor@mac.com>
Tue, 14 Aug 2007 17:59:48 +0000 (17:59 +0000)
committerOwen Anderson <resistor@mac.com>
Tue, 14 Aug 2007 17:59:48 +0000 (17:59 +0000)
the function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41077 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/GVN.cpp

index edd11e8e493b0dff793a18e7c4c49f80e1799925..1e9b177ea0bc8b74cf2bcf20b4c16dd1a350ac5f 100644 (file)
@@ -856,10 +856,19 @@ bool GVN::processLoad(LoadInst* L,
   
   // ... to a pointer that has been loaded from before...
   MemoryDependenceAnalysis& MD = getAnalysis<MemoryDependenceAnalysis>();
+  bool removedNonLocal = false;
   Instruction* dep = MD.getDependency(L);
   if (dep == MemoryDependenceAnalysis::NonLocal &&
-      L->getParent() != &L->getParent()->getParent()->getEntryBlock())
-    processNonLocalLoad(L, toErase);
+      L->getParent() != &L->getParent()->getParent()->getEntryBlock()) {
+    removedNonLocal = processNonLocalLoad(L, toErase);
+    
+    if (!removedNonLocal)
+      last = L;
+    
+    return removedNonLocal;
+  }
+  
+  
   bool deletedLoad = false;
   
   while (dep != MemoryDependenceAnalysis::None &&