summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Dominators.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2012-08-17 18:21:28 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2012-08-17 18:21:28 +0000
commit9a16735e2292236b3d795f8b2e3042b75bafae1a (patch)
treec3b36839202ee875580f1b9f7b6a3460c5e64b65 /llvm/lib/VMCore/Dominators.cpp
parente2b5b5c4accf7eb9ceea8b88a47411a455811210 (diff)
downloadbcm5719-llvm-9a16735e2292236b3d795f8b2e3042b75bafae1a.tar.gz
bcm5719-llvm-9a16735e2292236b3d795f8b2e3042b75bafae1a.zip
Assert that dominates is not given a multiple edge. Finding out if we have
multiple edges between two blocks is linear. If the caller is iterating all edges leaving a BB that would be a square time algorithm. It is more efficient to have the callers handle that case. Currently the only callers are: * GVN: already avoids the multiple edge case. * Verifier: could only hit this assert when looking at an invalid invoke. Since it already rejects the invoke, just avoid computing the dominance for it. llvm-svn: 162113
Diffstat (limited to 'llvm/lib/VMCore/Dominators.cpp')
-rw-r--r--llvm/lib/VMCore/Dominators.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Dominators.cpp b/llvm/lib/VMCore/Dominators.cpp
index 60bdeac16b3..77b2403d87d 100644
--- a/llvm/lib/VMCore/Dominators.cpp
+++ b/llvm/lib/VMCore/Dominators.cpp
@@ -161,6 +161,11 @@ bool DominatorTree::dominates(const Instruction *Def,
bool DominatorTree::dominates(const BasicBlockEdge &BBE,
const BasicBlock *UseBB) const {
+ // Assert that we have a single edge. We could handle them by simply
+ // returning false, but since isSingleEdge is linear on the number of
+ // edges, the callers can normally handle them more efficiently.
+ assert(BBE.isSingleEdge());
+
// If the BB the edge ends in doesn't dominate the use BB, then the
// edge also doesn't.
const BasicBlock *Start = BBE.getStart();
@@ -207,6 +212,11 @@ bool DominatorTree::dominates(const BasicBlockEdge &BBE,
bool DominatorTree::dominates(const BasicBlockEdge &BBE,
const Use &U) const {
+ // Assert that we have a single edge. We could handle them by simply
+ // returning false, but since isSingleEdge is linear on the number of
+ // edges, the callers can normally handle them more efficiently.
+ assert(BBE.isSingleEdge());
+
Instruction *UserInst = cast<Instruction>(U.getUser());
// A PHI in the end of the edge is dominated by it.
PHINode *PN = dyn_cast<PHINode>(UserInst);
OpenPOWER on IntegriCloud