Skip to content

Commit

Permalink
8288421: IGV: warn user about all unreachable nodes
Browse files Browse the repository at this point in the history
Reviewed-by: chagedorn, thartmann
  • Loading branch information
robcasloz committed Jun 17, 2022
1 parent 9d4b25e commit f3da7ff
Showing 1 changed file with 12 additions and 80 deletions.
Expand Up @@ -47,13 +47,15 @@ public class ServerCompilerScheduler implements Scheduler {
private static class Node {

public static final String WARNING_BLOCK_PROJECTION_WITH_MULTIPLE_SUCCS = "Block projection with multiple successors";
public static final String WARNING_REGION_WITH_MULTIPLE_SUCCS = "Region with multiple successors";
public static final String WARNING_PHI_INPUT_WITHOUT_REGION = "Phi input without associated region";
public static final String WARNING_REGION_WITHOUT_CONTROL_INPUT = "Region without control input";
public static final String WARNING_PHI_WITH_REGIONLESS_INPUTS = "Phi node with input nodes without associated region";
public static final String WARNING_NOT_MARKED_WITH_BLOCK_START = "Region not marked with is_block_start";
public static final String WARNING_CFG_AND_INPUT_TO_PHI = "CFG node is a phi input";
public static final String WARNING_PHI_NON_DOMINATING_INPUTS = "Phi input that does not dominate the phi's input block";
public static final String WARNING_CONTROL_UNREACHABLE_CFG = "Control-unreachable CFG node";
public static final String WARNING_CFG_WITHOUT_SUCCESSORS = "CFG node without control successors";

public InputNode inputNode;
public Set<Node> succs = new HashSet<>();
Expand Down Expand Up @@ -325,7 +327,6 @@ public Collection<InputBlock> schedule(InputGraph graph) {
}
buildUpGraph();
markCFGNodes();
connectOrphansAndWidows();
buildBlocks();
schedulePinned();
buildDominators();
Expand Down Expand Up @@ -466,9 +467,12 @@ private void scheduleLatest() {

// Mark all nodes reachable in backward traversal from root
Set<Node> reachable = reachableNodes();
// Schedule non-CFG, reachable nodes without block. CFG nodes should
// have been all scheduled by buildBlocks, otherwise it means they are
// control-unreachable and they should remain unscheduled.
Set<Node> unscheduled = new HashSet<>();
for (Node n : this.nodes) {
if (n.block == null && reachable.contains(n)) {
if (n.block == null && reachable.contains(n) && !n.isCFG) {
unscheduled.add(n);
}
}
Expand All @@ -495,17 +499,6 @@ private void scheduleLatest() {
}
}

Set<Node> curReachable = new HashSet<>(reachable);
for (Node n : curReachable) {
if (n.block != null) {
for (Node s : n.succs) {
if (!reachable.contains(s)) {
markWithBlock(s, n.block, reachable);
}
}
}
}

}

// Recompute the input array of the given node, including empty slots.
Expand Down Expand Up @@ -542,36 +535,6 @@ private Set<InputBlock> sourceBlocks(Node in, Node phi) {
return srcBlocks;
}

private void markWithBlock(Node n, InputBlock b, Set<Node> reachable) {
assert !reachable.contains(n);
Stack<Node> stack = new Stack<>();
stack.push(n);
n.block = b;
b.addNode(n.inputNode.getId());
reachable.add(n);

while (!stack.isEmpty()) {
Node cur = stack.pop();
for (Node s : cur.succs) {
if (!reachable.contains(s)) {
reachable.add(s);
s.block = b;
b.addNode(s.inputNode.getId());
stack.push(s);
}
}

for (Node s : cur.preds) {
if (!reachable.contains(s)) {
reachable.add(s);
s.block = b;
b.addNode(s.inputNode.getId());
stack.push(s);
}
}
}
}

public InputBlock getCommonDominator(InputBlock ba, InputBlock bb) {
if (ba == bb) {
return ba;
Expand Down Expand Up @@ -843,43 +806,6 @@ public void markCFGNodes() {
}
}

// Fix ill-formed graphs with orphan/widow control-flow nodes by adding
// edges from/to the Root node. Such edges are assumed by different parts of
// the scheduling algorithm, but are not always present, e.g. for certain
// 'Safepoint' nodes in the 'Before RemoveUseless' phase.
public void connectOrphansAndWidows() {
Node root = findRoot();
if (root == null) {
return;
}
for (Node n : nodes) {
if (n.isCFG) {
boolean orphan = true;
for (Node p : n.preds) {
if (p != n && p.isCFG) {
orphan = false;
}
}
if (orphan) {
// Add edge from root to this node.
root.succs.add(n);
n.preds.add(0, root);
}
boolean widow = true;
for (Node s : n.succs) {
if (s != n && s.isCFG) {
widow = false;
}
}
if (widow) {
// Add edge from this node to root.
root.preds.add(n);
n.succs.add(root);
}
}
}
}

// Check invariants in the input graph and in the output schedule, and add
// warnings to nodes where the invariants do not hold.
public void check() {
Expand All @@ -889,6 +815,12 @@ public void check() {
if (isRegion(n) && !n.isBlockStart) {
n.addWarning(Node.WARNING_NOT_MARKED_WITH_BLOCK_START);
}
if (isRegion(n) && controlSuccs.get(n).size() > 1) {
n.addWarning(Node.WARNING_REGION_WITH_MULTIPLE_SUCCS);
}
if (n.isCFG && controlSuccs.get(n).isEmpty()) {
n.addWarning(Node.WARNING_CFG_WITHOUT_SUCCESSORS);
}
if (n.isCFG && n.block == null) {
n.addWarning(Node.WARNING_CONTROL_UNREACHABLE_CFG);
}
Expand Down

1 comment on commit f3da7ff

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.