[PATCH] D11143: [RFC] Cross Block DSE

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 10 08:47:28 PDT 2015


dberlin added a comment.

I think we should just fix the PDT in a separate patch, and remove this check.

The documentation for getRootNode says:
"  /// getRootNode - This returns the entry node for the CFG of the
function.  If

  /// this tree represents the post-dominance relations for a

function, however,

  /// this root may be a node with the block == NULL.  This is the case when
  /// there are multiple exit nodes from a particular function.  Consumers of
  /// post-dominance information must be capable of dealing with this
  /// possibility."

Note: This may be a node with *block* == NULL, not that the root node
may be null.

The problem here is in PDT building.

GenericDomTreeConstruction does this:
 if (TraitsTy::child_begin(I) == TraitsTy::child_end(I))

  addRoot(I);

This is wrong, obviously, since in the case of an infinite loop like
you've shown, it will have a self-loop, but it is a root because there
is no exit.

This whole mechanism of trying to detect the roots is broken, in fact.
It's essentially trying to determine reachability without a DFS, which
is not possible in general.

The *only* correct way (i'm aware of) to determine which things need
to be children of artificial exit/a root is to DFS from all clear exit
blocks, and then, for anything still unvisited, DFS from each of them,
marking them as children of the artificial exit
(you could also reparent anything you reach  that was marked as a
child of artificial exit , if we want to prefer anything over the
artificial exit as a parent. But this should not be necessary for
correct answers).

Please file a bug with your testcase and cc me, and i'l update the bug
with details.

(I'll see if i can find time to prepare a patch)


http://reviews.llvm.org/D11143





More information about the llvm-commits mailing list