[llvm-branch-commits] [llvm-branch] r276418 - Merging r276181:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jul 22 07:08:45 PDT 2016


Author: hans
Date: Fri Jul 22 09:08:45 2016
New Revision: 276418

URL: http://llvm.org/viewvc/llvm-project?rev=276418&view=rev
Log:
Merging r276181:
------------------------------------------------------------------------
r276181 | majnemer | 2016-07-20 14:05:01 -0700 (Wed, 20 Jul 2016) | 6 lines

[GVNHoist] Don't hoist PHI nodes

We hoisted PHIs without respecting their special insertion point in the
block, leading to verfier errors.

This fixes PR28626.
------------------------------------------------------------------------

Added:
    llvm/branches/release_39/test/Transforms/GVN/pr28626.ll
      - copied unchanged from r276181, llvm/trunk/test/Transforms/GVN/pr28626.ll
Modified:
    llvm/branches/release_39/   (props changed)
    llvm/branches/release_39/lib/Transforms/Scalar/GVNHoist.cpp

Propchange: llvm/branches/release_39/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jul 22 09:08:45 2016
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,275870,275879,275898,275935,275946
+/llvm/trunk:155241,275870,275879,275898,275935,275946,276181

Modified: llvm/branches/release_39/lib/Transforms/Scalar/GVNHoist.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_39/lib/Transforms/Scalar/GVNHoist.cpp?rev=276418&r1=276417&r2=276418&view=diff
==============================================================================
--- llvm/branches/release_39/lib/Transforms/Scalar/GVNHoist.cpp (original)
+++ llvm/branches/release_39/lib/Transforms/Scalar/GVNHoist.cpp Fri Jul 22 09:08:45 2016
@@ -589,16 +589,20 @@ public:
 
   bool makeOperandsAvailable(Instruction *Repl, BasicBlock *HoistPt) const {
     // Check whether the GEP of a ld/st can be synthesized at HoistPt.
-    Instruction *Gep = nullptr;
+    GetElementPtrInst *Gep = nullptr;
     Instruction *Val = nullptr;
     if (auto *Ld = dyn_cast<LoadInst>(Repl))
-      Gep = dyn_cast<Instruction>(Ld->getPointerOperand());
+      Gep = dyn_cast<GetElementPtrInst>(Ld->getPointerOperand());
     if (auto *St = dyn_cast<StoreInst>(Repl)) {
-      Gep = dyn_cast<Instruction>(St->getPointerOperand());
+      Gep = dyn_cast<GetElementPtrInst>(St->getPointerOperand());
       Val = dyn_cast<Instruction>(St->getValueOperand());
     }
 
-    if (!Gep || !isa<GetElementPtrInst>(Gep))
+    if (!Gep)
+      return false;
+
+    // PHIs may only be inserted at the start of a block.
+    if (Val && isa<PHINode>(Val))
       return false;
 
     // Check whether we can compute the Gep at HoistPt.




More information about the llvm-branch-commits mailing list