# HG changeset patch # User Lukas Stadler # Date 1312550043 -7200 # Node ID 66e8bde93b6d20c6efcd61ba8c05f01a5e0b41c6 # Parent b9ed7199f6fb483a941372b4c04175fe51834d22 print graph upon exceptions in emitLIR, swallow more loop-code-exceptions during graph output, fixed handling of dead loop ends in DeadCodeEliminationPhase diff -r b9ed7199f6fb -r 66e8bde93b6d graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java --- 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; } } diff -r b9ed7199f6fb -r 66e8bde93b6d graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java --- 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 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(" "); diff -r b9ed7199f6fb -r 66e8bde93b6d graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DeadCodeEliminationPhase.java --- 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(); } } diff -r b9ed7199f6fb -r 66e8bde93b6d graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java --- 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; } }