[llvm-commits] [llvm] r151466 - in /llvm/trunk: include/llvm/Analysis/Dominators.h lib/Analysis/InstructionSimplify.cpp
Rafael Espíndola
rafael.espindola at gmail.com
Sun Mar 4 04:49:43 PST 2012
On 2 March 2012 17:44, Duncan Sands <baldrick at free.fr> wrote:
> Hi Rafael,
>
>> Don't call dominates on unreachable instructions.
>
> why not? Is there really no sensible definition of domination in this case?
The textbook book one that I know is that (at least at the BB level),
an unreachable BB is dominated by anything. Chris points out that it
is handy to have an API where dominates(A, B) != dominates(B, A), and
that would be false if we used that definition.
Do you know of an alternative one that would fit better?
> For example, consider dominates(A, B). Suppose the definition is: every path
> from the entry block to B passes through A. Then if B is unreachable then
> dominates should return 'true'. After all, every path from the entry block to
> B passes through A. (If you don't agree, show me a path from the entry block
> to B that doesn't pass through A). If B is reachable and A is unreachable,
> then dominates should return 'true' since there is a path from the entry
> block to B that doesn't pass through A. But perhaps you have a different
> definition of domination in mind?
I had that one, and it looks like it makes most of the dominates uses
simpler, but I have not tried changing them all.
> Ciao, Duncan.
>
> 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.
The functions are a bit different, that is why I used a different name
for dominates(inst, inst) in the first patch. While dominates(bb,bb)
is the classical textbook one, the (inst, inst) version is about
dominating uses.
Cheers,
Rafael
More information about the llvm-commits
mailing list