Esempio n. 1
0
 public static boolean tryKillUnused(Node node) {
   if (node.isAlive() && isFloatingNode().apply(node) && node.usages().isEmpty()) {
     killWithUnusedFloatingInputs(node);
     return true;
   }
   return false;
 }
Esempio n. 2
0
  public static void killWithUnusedFloatingInputs(Node node) {
    List<Node> floatingInputs = node.inputs().filter(isFloatingNode()).snapshot();
    node.safeDelete();

    for (Node in : floatingInputs) {
      if (in.isAlive() && in.usages().isEmpty()) {
        killWithUnusedFloatingInputs(in);
      }
    }
  }
Esempio n. 3
0
  public static void propagateKill(Node node) {
    if (node != null && node.isAlive()) {
      List<Node> usagesSnapshot = node.usages().filter(isFloatingNode()).snapshot();

      // null out remaining usages
      node.replaceAtUsages(null);
      node.replaceAtPredecessor(null);
      killWithUnusedFloatingInputs(node);

      for (Node usage : usagesSnapshot) {
        if (!usage.isDeleted()) {
          if (usage instanceof PhiNode) {
            usage.replaceFirstInput(node, null);
          } else {
            propagateKill(usage);
          }
        }
      }
    }
  }