changeset 3488:66e8bde93b6d

print graph upon exceptions in emitLIR, swallow more loop-code-exceptions during graph output, fixed handling of dead loop ends in DeadCodeEliminationPhase
author Lukas Stadler <lukas.stadler@jku.at>
date Fri, 05 Aug 2011 15:14:03 +0200
parents b9ed7199f6fb
children e04e88087e98
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DeadCodeEliminationPhase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java
diffstat 4 files changed, 43 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java	Thu Aug 04 18:52:50 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java	Fri Aug 05 15:14:03 2011 +0200
@@ -230,28 +230,40 @@
     }
 
     private void emitLIR() {
-        if (GraalOptions.GenLIR) {
-            if (GraalOptions.Time) {
-                GraalTimers.LIR_CREATE.start();
-            }
+        try {
+            if (GraalOptions.GenLIR) {
+                if (GraalOptions.Time) {
+                    GraalTimers.LIR_CREATE.start();
+                }
 
-            initFrameMap(hir.maxLocks());
+                initFrameMap(hir.maxLocks());
+
+                lirGenerator = compiler.backend.newLIRGenerator(this);
 
-            lirGenerator = compiler.backend.newLIRGenerator(this);
+                for (LIRBlock b : hir.linearScanOrder()) {
+                    lirGenerator.doBlock(b);
+                }
 
-            for (LIRBlock b : hir.linearScanOrder()) {
-                lirGenerator.doBlock(b);
-            }
+                if (GraalOptions.Time) {
+                    GraalTimers.LIR_CREATE.stop();
+                }
 
-            if (GraalOptions.Time) {
-                GraalTimers.LIR_CREATE.stop();
+                if (GraalOptions.PrintLIR && !TTY.isSuppressed()) {
+                    LIRList.printLIR(hir.linearScanOrder());
+                }
+
+                new LinearScan(this, hir, lirGenerator, frameMap()).allocate();
             }
-
-            if (GraalOptions.PrintLIR && !TTY.isSuppressed()) {
-                LIRList.printLIR(hir.linearScanOrder());
+        } catch (AssertionError e) {
+            if (compiler.isObserved() && GraalOptions.PlotOnError) {
+                compiler.fireCompilationEvent(new CompilationEvent(this, "AssertionError in emitLIR", graph, true, false, true));
             }
-
-            new LinearScan(this, hir, lirGenerator, frameMap()).allocate();
+            throw e;
+        } catch (RuntimeException e) {
+            if (compiler.isObserved() && GraalOptions.PlotOnError) {
+                compiler.fireCompilationEvent(new CompilationEvent(this, "RuntimeException in emitLIR", graph, true, false, true));
+            }
+            throw e;
         }
     }
 
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java	Thu Aug 04 18:52:50 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java	Fri Aug 05 15:14:03 2011 +0200
@@ -141,8 +141,15 @@
         List<Loop> loops = null;
         try {
             loops = LoopUtil.computeLoops(graph);
+            // loop.nodes() does some more calculations which may fail, so execute this here as well
+            if (loops != null) {
+                for (Loop loop : loops) {
+                    loop.nodes();
+                }
+            }
         } catch (Throwable t) {
             t.printStackTrace();
+            loops = null;
         }
 
         stream.println("  <nodes>");
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DeadCodeEliminationPhase.java	Thu Aug 04 18:52:50 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DeadCodeEliminationPhase.java	Fri Aug 05 15:14:03 2011 +0200
@@ -93,14 +93,17 @@
                     LoopBegin loop = ((LoopEnd) node).loopBegin();
                     if (flood.isMarked(loop)) {
                         if (GraalOptions.TraceDeadCodeElimination) {
-                            TTY.println("Building loop begin node back: " + loop);
+                            TTY.println("Removing loop with unreachable end: " + loop);
                         }
                         ((LoopEnd) node).setLoopBegin(null);
                         EndNode endNode = loop.endAt(0);
                         assert endNode.predecessor() != null;
-                        // replacePhis(loop);
+                        replacePhis(loop);
+                        loop.removeEnd(endNode);
 
-                        endNode.replaceAndDelete(loop.next());
+                        FixedNode next = loop.next();
+                        loop.setNext(null);
+                        endNode.replaceAndDelete(next);
                         loop.delete();
                     }
                 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java	Thu Aug 04 18:52:50 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java	Fri Aug 05 15:14:03 2011 +0200
@@ -125,7 +125,7 @@
     }
 
     public static boolean isFixed(Node n) {
-        return n != null && ((n instanceof FixedNode) || n == n.graph().start());
+        return n != null && ((n instanceof FixedNode) || n == n.graph().start()) && !(n instanceof AccessNode && n.predecessor() == null);
     }
 
     public static boolean isBlockEnd(Node n) {
@@ -170,6 +170,7 @@
                     }
                     Node prev = currentNode;
                     currentNode = currentNode.predecessor();
+                    assert !(currentNode instanceof AccessNode && ((AccessNode) currentNode).next() != prev) : currentNode;
                     assert !currentNode.isDeleted() : prev + " " + currentNode;
                 }
             }