summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-07-20 21:05:01 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-07-20 21:05:01 +0000
commitbd21012c6c01ea3f46d0533a09c3fc3c182c3759 (patch)
tree23440e6a304894a5cf907e92d0a0880a0337d830 /llvm/lib
parent4c7718d51b743b621d7c215eff78004c5ea40cd8 (diff)
downloadbcm5719-llvm-bd21012c6c01ea3f46d0533a09c3fc3c182c3759.tar.gz
bcm5719-llvm-bd21012c6c01ea3f46d0533a09c3fc3c182c3759.zip
[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. llvm-svn: 276181
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/GVNHoist.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVNHoist.cpp b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
index c40068c5138..494f36bb3a7 100644
--- a/llvm/lib/Transforms/Scalar/GVNHoist.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
@@ -576,16 +576,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.
OpenPOWER on IntegriCloud