llvm.org GIT mirror
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162113 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 8 years ago
3 changed file(s) with 17 addition(s) and 1 deletion(s).
 160 160 161 161 bool DominatorTree::dominates(const BasicBlockEdge &BBE, 162 162 const BasicBlock *UseBB) const { 163 // Assert that we have a single edge. We could handle them by simply 164 // returning false, but since isSingleEdge is linear on the number of 165 // edges, the callers can normally handle them more efficiently. 166 assert(BBE.isSingleEdge()); 167 163 168 // If the BB the edge ends in doesn't dominate the use BB, then the 164 169 // edge also doesn't. 165 170 const BasicBlock *Start = BBE.getStart(); 206 211 207 212 bool DominatorTree::dominates(const BasicBlockEdge &BBE, 208 213 const Use &U) const { 214 // Assert that we have a single edge. We could handle them by simply 215 // returning false, but since isSingleEdge is linear on the number of 216 // edges, the callers can normally handle them more efficiently. 217 assert(BBE.isSingleEdge()); 218 209 219 Instruction *UserInst = cast(U.getUser()); 210 220 // A PHI in the end of the edge is dominated by it. 211 221 PHINode *PN = dyn_cast(UserInst);
 1574 1574 1575 1575 void Verifier::verifyDominatesUse(Instruction &I, unsigned i) { 1576 1576 Instruction *Op = cast(I.getOperand(i)); 1577 // If the we have an invalid invoke, don't try to compute the dominance. 1578 // We already reject it in the invoke specific checks and the dominance 1579 // computation doesn't handle multiple edges. 1580 if (InvokeInst *II = dyn_cast(Op)) { 1581 if (II->getNormalDest() == II->getUnwindDest()) 1582 return; 1583 } 1577 1584 1578 1585 const Use &U = I.getOperandUse(i); 1579 1586 Assert2(InstsInThisBlock.count(Op) || DT->dominates(Op, U),
 18 18 br label %L 19 19 L: ; preds = %L2, %L1, %L1 20 20 ; CHECK: The unwind destination does not have a landingpad instruction 21 ; CHECK: Instruction does not dominate all uses 22 21 ret i32 %A 23 22 } 24 23