Could a gatekeeper please review this patch?
https://bugs.open64.net/show_bug.cgi?id=748

When turn on nystrom alias analyzer, SPEC2006 base 445.gobmk assertion in
ConstraintGraph::buildCGipa, constraint_graph.cxx:444
      if (pNode->checkFlags(CG_NODE_FLAGS_COLLAPSED)) {
        FmtAssert(pNode != pNode->parent(), ("Expecting a distinct parent "
                  "for COLLAPSED node: %d\n", pNode->id()));
This assertion means Node is collapsed but its parent field still point to
itself which means it's not collapsed yet.
Because collapsed node means it’s merged into its collapse parent, it will
not show in any other nodes’ points to set.

This bug related with three constraint graph node.
CGNodeId: 2 is <677377, 408>
CGNodeId: 3 is <677377, 0>
CGNodeId: 4 is <677377, 416>

ConstraintGraph::buildCGipa construct each PU's local constraint graph and
merge global constraint graph node into ConstraintGraph ::GlobalCG. So their
maybe complicated cases when different PU's IPL constraint graph has
inconsistent parent relationship between nodes.

This assertion happens with following steps when processing each individual
PU's local constraint graph.
1.  Process first function Node<4>'s parent is Node<3> in local constraint
graph.
2.  Process second function Node<4>'s parent is Node<2> in local constraint
graph. Current implmentation is mergeing original parent Node<3> to new
parent Node<2>. Then Node<2> becomes Node<3>'s parent.
3.  Porcess third function Node<2>'s parent is Node<3> in local constraint
graph. Current handling doesn't change Node<2>'s parent to Node<3>, because
there will be a cyclic repParent chain.

This is like break the parent cycle by letting Node<2> be top level parent
node, without consider if Node<2> is collapsed or not. This trigger the
assertion, that Node<2> is collapsed while has no repParent.

Fix is breaking the parent cycle in another way when find cgNode has
collapsed flag.
Put the collapsed node at bottom of repParent chain, merge its edges and
points_to to its parent.
This makes collapsed node keep align with its definition.

Index: osprey/ipa/main/analyze/ipa_nystrom_alias_analyzer.cxx
===================================================================
--- osprey/ipa/main/analyze/ipa_nystrom_alias_analyzer.cxx      (revision
3534)
+++ osprey/ipa/main/analyze/ipa_nystrom_alias_analyzer.cxx      (working
copy)
@@ -370,8 +370,27 @@
         repPNodeParent->merge(cgNode);
         cgNode->repParent(repPNodeParent);
       }
+      else if (repPNode != cgNode &&
cgNode->checkFlags(CG_NODE_FLAGS_COLLAPSED)) {
+        // summNode parent is not cgNode, and cgNode is summNode parent's
+        // parent. Here is a cyclic repParent chain.
+        // if cgNode is collapsed node(means it will not used in points
to),
+        // break the chain and make cgNode not top repParent.
+        repPNodeParent = repPNode;
+        while (true) {
+          if (repPNodeParent->repParent() == cgNode) {
+            repPNodeParent->repParent(NULL);
+            break;
+          }
+          repPNodeParent = repPNodeParent->repParent();
+        }
+        repPNodeParent->clearFlags(CG_NODE_FLAGS_MERGED);
+        repPNodeParent->merge(cgNode);
+        cgNode->repParent(repPNode);
+      }
+      else {
+        // here it is break the chain, and let cgNode be top repParent.
+      }
     }
-
     // Set the collapsed parent
     if (cgNode->checkFlags(CG_NODE_FLAGS_COLLAPSED)) {
       if (summNode.collapsedParent() != 0) {
------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to