[llvm-commits] [llvm] r151466 - in /llvm/trunk: include/llvm/Analysis/Dominators.h lib/Analysis/InstructionSimplify.cpp
rafael.espindola at gmail.com
Sun Mar 4 13:58:59 PST 2012
>> * dominates(unreachable, unreachable)
> -> true. That was already covered by dominates(anything, unreachable)
> Also see comments below.
>> * dominates(BBA,BBA)
> -> true. Either BBA is reachable, in which case it is true, or it is
> unreachable in which case it is true by the above.
OK, so this is the traditional definition where an unreachable block
is dominated by everything and a block dominates itself.
>> My understanding is that we would like to assert on the first one and
>> return false for the second one, right?
> Why assert? The first situation occurs quite naturally if we have for
> the CFG: entry -> A -> B and an instruction in B uses one in A. Suppose the
> edge between entry and A is deleted. Then the IR shouldn't suddenly become
> invalid. Thus the instruction in A should still dominate the instruction in
> B. As for dominates(BBA, BBA), I don't understand why you would want it to
> return false. BBA doesn't properly dominate itself (properly dominates =
> dominates and not the same basic block) of course.
Because with this we have a case where dominates(BBA, BBB) =
dominates(BBB, BBA) = true (if both are unreachable) . I am probably
fine with that, but I think we have the current situation to ensure
that dominates(A,B) != dominates(B, A). Another problem is that we
would still have a difference on the behaviour in dominates(BBA, BBA)
= true vs. dominates(InstA, InstA) = false.
> By the way, all the answers I gave follow directly from the definition:
> A dominates B iff every path in the CFG from the entry block to B
> passes via A.
Sure, it all depends on reading "via" as including the end point or not :-)
> Ciao, Duncan.
> PS: I'm happy to work on this myself, but you might need to give me a few
I started it, so I am happy to finish. We just need an agreement of
the semantics we want. My opinions are that we should make
dominates(BBA, BBA) false, change dominates(instA, InstA) to true or
remane dominate(Inst, Inst) to make it clear it is not exactly the
same thing as the basic block version.
I am fine with dominates(unreachable, unreachable) returning true or asserting.
More information about the llvm-commits