private OPT_LSTGraph(OPT_IR ir) { OPT_ControlFlowGraph cfg = ir.cfg; OPT_BasicBlock entry = ir.cfg.entry();   cfg.clearDFS(); entry.sortDFS(); int dfn = 0; for (OPT_SpaceEffGraphNode node = entry; node != null; node = node.nextSorted) { node.clearLoopHeader(); node.scratch = dfn++; clearBackEdges(node); } cfg.clearDFS(); findBackEdges(entry, ir.cfg.numberOfNodes());   OPT_LSTNode lstheader = new OPT_LSTNode(entry); rootNode = lstheader; addGraphNode(lstheader);    for (OPT_BasicBlock node = (OPT_BasicBlock)entry.nextSorted; node != null; node = (OPT_BasicBlock)node.nextSorted) { OPT_LSTNode header = null; for (OPT_SpaceEffGraphEdge edge = node.firstInEdge(); edge != null; edge = edge.getNextIn()) { if (edge.backEdge()) { OPT_BitVector loop; if (header == null) { header = new OPT_LSTNode(node); addGraphNode(header); loop = new OPT_BitVector(cfg.numberOfNodes()); loop.set(node.getNumber()); header.loop = loop; if (DEBUG) {  System.out.println("header" + header); } } else { loop = header.loop; } cfg.clearDFS(); node.setDfsVisited(); findNaturalLoop(edge, loop); } } } if (DEBUG) { for (OPT_SpaceEffGraphNode node = _firstNode; node != null; node = node.getNext()) { System.out.println(node); } }   lstloop: for (OPT_LSTNode node = (OPT_LSTNode)_firstNode.getNext(); node != null; node = (OPT_LSTNode)node.getNext()) { int number = node.header.getNumber(); for (OPT_LSTNode prev = (OPT_LSTNode)node.getPrev(); prev != _firstNode; prev = (OPT_LSTNode)prev.getPrev()) { if (prev.loop.get(number)) { prev.insertOut(node); continue  lstloop; } }  _firstNode.insertOut(node); }   ir.resetBasicBlockMap(); setDepth(ir, rootNode, 0);
protected OPT_LSTGraph(OPT_LSTGraph graph) { rootNode = graph.rootNode; loopMap = graph.loopMap;
  private OPT_LSTGraph(OPT_IR ir) {    OPT_ControlFlowGraph cfg = ir.cfg;    OPT_BasicBlock entry = ir.cfg.entry();    // do DFN pass    cfg.clearDFS();    entry.sortDFS();    int dfn = 0;    for (OPT_SpaceEffGraphNode node = entry;          node != null;          node = node.nextSorted) {      node.clearLoopHeader();      node.scratch = dfn++;      clearBackEdges(node);    }    cfg.clearDFS();    findBackEdges(entry, ir.cfg.numberOfNodes());    // entry node is considered the LST head    OPT_LSTNode lstheader = new OPT_LSTNode(entry);    rootNode = lstheader;    addGraphNode(lstheader);    // compute the natural loops for each back edge.     // merge backedges with the same header    for (OPT_BasicBlock node = (OPT_BasicBlock)entry.nextSorted;          node != null;         node = (OPT_BasicBlock)node.nextSorted) {      OPT_LSTNode header = null;      for (OPT_SpaceEffGraphEdge edge = node.firstInEdge();            edge != null;            edge = edge.getNextIn()) {        if (edge.backEdge()) {          OPT_BitVector loop;          if (header == null) {            header = new OPT_LSTNode(node);            addGraphNode(header);            loop = new OPT_BitVector(cfg.numberOfNodes());            loop.set(node.getNumber());            header.loop = loop;            if (DEBUG) {  System.out.println("header" + header); }          } else {            loop = header.loop;          }          cfg.clearDFS();          node.setDfsVisited();          findNaturalLoop(edge, loop);        }      }    }    if (DEBUG) {      for (OPT_SpaceEffGraphNode node = _firstNode;            node != null;            node = node.getNext()) {        System.out.println(node);      }    }    // now build the LST  lstloop:     for (OPT_LSTNode node = (OPT_LSTNode)_firstNode.getNext();                 node != null;                 node = (OPT_LSTNode)node.getNext()) {      int number = node.header.getNumber();      for (OPT_LSTNode prev = (OPT_LSTNode)node.getPrev();            prev != _firstNode;            prev = (OPT_LSTNode)prev.getPrev()) {        if (prev.loop.get(number)) {            // nested          prev.insertOut(node);          continue  lstloop;        }      }      // else the node is considered to be connected to the LST head      _firstNode.insertOut(node);    }    // Set loop nest depth for each node in the LST and initialize LoopMap    ir.resetBasicBlockMap();    setDepth(ir, rootNode, 0);  }