[llvm-commits] [llvm] r162113 - in /llvm/trunk: lib/VMCore/Dominators.cpp lib/VMCore/Verifier.cpp test/Verifier/invoke.ll
Rafael Espindola
rafael.espindola at gmail.com
Fri Aug 17 11:21:28 PDT 2012
Author: rafael
Date: Fri Aug 17 13:21:28 2012
New Revision: 162113
URL: http://llvm.org/viewvc/llvm-project?rev=162113&view=rev
Log:
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.
Modified:
llvm/trunk/lib/VMCore/Dominators.cpp
llvm/trunk/lib/VMCore/Verifier.cpp
llvm/trunk/test/Verifier/invoke.ll
Modified: llvm/trunk/lib/VMCore/Dominators.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Dominators.cpp?rev=162113&r1=162112&r2=162113&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Dominators.cpp (original)
+++ llvm/trunk/lib/VMCore/Dominators.cpp Fri Aug 17 13:21:28 2012
@@ -161,6 +161,11 @@
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,
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);
Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=162113&r1=162112&r2=162113&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Fri Aug 17 13:21:28 2012
@@ -1575,6 +1575,13 @@
void Verifier::verifyDominatesUse(Instruction &I, unsigned i) {
Instruction *Op = cast<Instruction>(I.getOperand(i));
+ // If the we have an invalid invoke, don't try to compute the dominance.
+ // We already reject it in the invoke specific checks and the dominance
+ // computation doesn't handle multiple edges.
+ if (InvokeInst *II = dyn_cast<InvokeInst>(Op)) {
+ if (II->getNormalDest() == II->getUnwindDest())
+ return;
+ }
const Use &U = I.getOperandUse(i);
Assert2(InstsInThisBlock.count(Op) || DT->dominates(Op, U),
Modified: llvm/trunk/test/Verifier/invoke.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/invoke.ll?rev=162113&r1=162112&r2=162113&view=diff
==============================================================================
--- llvm/trunk/test/Verifier/invoke.ll (original)
+++ llvm/trunk/test/Verifier/invoke.ll Fri Aug 17 13:21:28 2012
@@ -19,7 +19,6 @@
br label %L
L: ; preds = %L2, %L1, %L1
; CHECK: The unwind destination does not have a landingpad instruction
-; CHECK: Instruction does not dominate all uses
ret i32 %A
}
More information about the llvm-commits
mailing list