[llvm-commits] [llvm] r151466 - in /llvm/trunk: include/llvm/Analysis/Dominators.h lib/Analysis/InstructionSimplify.cpp
Duncan Sands
baldrick at free.fr
Sun Mar 4 13:27:20 PST 2012
Hi Rafael,
On 04/03/12 22:16, Rafael EspĂndola wrote:
>> I don't think this is the right way round. Domination between basic blocks
>> is the fundamental concept, domination of instructions should be built on
>> top of it. I think the definition of dominates for basic blocks should be:
>> A dominates B iff every path from the entry block to B necessarily passes
>> via A. This results in the right properties wrt instructions too. This
>> definition doesn't change anything for reachable basic blocks, however
>> for unreachable blocks you get:
>> dominates(anything, unreachable) -> true
(so for example an unreachable instruction can always use a reachable one, which
is clearly needed, since otherwise removing an edge in the CFG could create
invalid IR).
>> dominates(unreachable, reachable) -> false
(this implies that a reachable instruction can't use an unreachable one, which
is essential!)
>
> I would probably keep the implementation that way (dominates
> instruction calls to dominates bb). I just find it a bit easier to
> think in term of individual defs and uses because of the peculiar
> point of definition and use that some instructions have. With you
> definition, what would the result be for
>
> * dominates(unreachable, unreachable)
-> true. That was already covered by dominates(anything, unreachable) above.
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.
> 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 example
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.
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 necessarily
passes via A.
Ciao, Duncan.
PS: I'm happy to work on this myself, but you might need to give me a few days.
More information about the llvm-commits
mailing list