summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDaniel Berlin <dberlin@dberlin.org>2017-03-18 15:41:36 +0000
committerDaniel Berlin <dberlin@dberlin.org>2017-03-18 15:41:36 +0000
commit41b39169e2d2c6dddb94e9e546b840f8b1295142 (patch)
treeba118fbaa0ab7752eb5f103001c3451345da377f /llvm/lib/Transforms
parent182771f6202d70add2e9862cfd694766f0c9fe26 (diff)
downloadbcm5719-llvm-41b39169e2d2c6dddb94e9e546b840f8b1295142.tar.gz
bcm5719-llvm-41b39169e2d2c6dddb94e9e546b840f8b1295142.zip
NewGVN: Fix PHI evaluation bug exposed by new verifier. We were checking whether the incoming block was reachable instead of whether the specific edge was reachable
llvm-svn: 298187
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/NewGVN.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index a637160b8e6..0fa9b1d714a 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -444,7 +444,7 @@ PHIExpression *NewGVN::createPHIExpression(Instruction *I) {
// Filter out unreachable phi operands.
auto Filtered = make_filter_range(PN->operands(), [&](const Use &U) {
- return ReachableBlocks.count(PN->getIncomingBlock(U));
+ return ReachableEdges.count({PN->getIncomingBlock(U), PHIBlock});
});
std::transform(Filtered.begin(), Filtered.end(), op_inserter(E),
@@ -1740,10 +1740,11 @@ void NewGVN::valueNumberMemoryPhi(MemoryPhi *MP) {
// If all the arguments are the same, the MemoryPhi has the same value as the
// argument.
// Filter out unreachable blocks and self phis from our operands.
+ const BasicBlock *PHIBlock = MP->getBlock();
auto Filtered = make_filter_range(MP->operands(), [&](const Use &U) {
return lookupMemoryAccessEquiv(cast<MemoryAccess>(U)) != MP &&
!isMemoryAccessTop(cast<MemoryAccess>(U)) &&
- ReachableBlocks.count(MP->getIncomingBlock(U));
+ ReachableEdges.count({MP->getIncomingBlock(U), PHIBlock});
});
// If all that is left is nothing, our memoryphi is undef. We keep it as
// InitialClass. Note: The only case this should happen is if we have at
@@ -1822,7 +1823,7 @@ bool NewGVN::singleReachablePHIPath(const MemoryAccess *First,
} else {
auto *MP = cast<MemoryPhi>(First);
auto ReachableOperandPred = [&](const Use &U) {
- return ReachableBlocks.count(MP->getIncomingBlock(U));
+ return ReachableEdges.count({MP->getIncomingBlock(U), MP->getBlock()});
};
auto FilteredPhiArgs =
make_filter_range(MP->operands(), ReachableOperandPred);
@@ -1879,7 +1880,8 @@ void NewGVN::verifyMemoryCongruency() const {
// We can only sanely verify that MemoryDefs in the operand list all have
// the same class.
auto ReachableOperandPred = [&](const Use &U) {
- return ReachableBlocks.count(FirstMP->getIncomingBlock(U)) &&
+ return ReachableEdges.count(
+ {FirstMP->getIncomingBlock(U), FirstMP->getBlock()}) &&
isa<MemoryDef>(U);
};
OpenPOWER on IntegriCloud