[DomTree] Make assert more precise

Per asbirlea's comment, assert that only instructions, constants
and arguments are passed to this API. Simplify returning true
would not be correct for special Value subclasses like MemoryAccess.
This commit is contained in:
Nikita Popov 2020-10-22 22:40:06 +02:00
parent 1882568fcb
commit c0e8c94373
1 changed files with 6 additions and 4 deletions

View File

@ -119,8 +119,9 @@ bool DominatorTree::dominates(const Value *DefV,
const Instruction *User) const {
const Instruction *Def = dyn_cast<Instruction>(DefV);
if (!Def) {
assert(!isa<BasicBlock>(DefV) && "Should not be called with basic blocks");
return true; // Arguments, constants, globals dominate everything.
assert((isa<Argument>(DefV) || isa<Constant>(DefV)) &&
"Should be called with an instruction, argument or constant");
return true; // Arguments and constants dominate everything.
}
const BasicBlock *UseBB = User->getParent();
@ -259,8 +260,9 @@ bool DominatorTree::dominates(const BasicBlockEdge &BBE, const Use &U) const {
bool DominatorTree::dominates(const Value *DefV, const Use &U) const {
const Instruction *Def = dyn_cast<Instruction>(DefV);
if (!Def) {
assert(!isa<BasicBlock>(DefV) && "Should not be called with basic blocks");
return true; // Arguments, constants, globals dominate everything.
assert((isa<Argument>(DefV) || isa<Constant>(DefV)) &&
"Should be called with an instruction, argument or constant");
return true; // Arguments and constants dominate everything.
}
Instruction *UserInst = cast<Instruction>(U.getUser());