[llvm-commits] [llvm] r151466 - in /llvm/trunk: include/llvm/Analysis/Dominators.h lib/Analysis/InstructionSimplify.cpp

Chris Lattner clattner at apple.com
Fri Mar 2 13:18:33 PST 2012


On Mar 2, 2012, at 12:44 PM, Duncan Sands wrote:

> Hi Rafael,
> 
>> Don't call dominates on unreachable instructions.
> 
> why not?  Is there really no sensible definition of domination in this case?

There is no good answer.  The definition of dom(A,B) is "all paths from the entry block to B go through A".  This is vacuously true for unreachable blocks, but it is unlikely that any transformation would be prepared to handle this (because now you can have dom(a,b) = true and dom(b,a) = true and a != b).

> But perhaps you have a different definition of domination in mind?

I think that we're all on the same page, but that doesn't necessarily make it a useful API for the dominators class.

> PS: If you add an assertion about dominates(instruction,instruction) only
> being called for reachable instructions, then shouldn't you have one for
> dominates(basic block, basic block) too?  After all, if you think
> dominates(instruction,instruction) has no sensible meaning, probably
> dominates(basic block, basic block) has no sensible meaning either.

Yes, I think it is worth being consistent here.  For blocks, we return false in this case iirc, which would be better than returning true.

-Chris




More information about the llvm-commits mailing list