changeset 6352:b76534871d06

determine offending use blocks for liveIn - violations
author Lukas Stadler <lukas.stadler@jku.at>
date Tue, 11 Sep 2012 14:08:14 +0200
parents c5024000ff0f
children 2590d9cc3b6d
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java
diffstat 1 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java	Tue Sep 11 12:10:45 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java	Tue Sep 11 14:08:14 2012 +0200
@@ -861,15 +861,19 @@
         TTY.print("affected registers:");
         TTY.println(blockData.get(ir.cfg.getStartBlock()).liveIn.toString());
 
+
         // print some additional information to simplify debugging
         for (int operandNum = 0; operandNum < blockData.get(ir.cfg.getStartBlock()).liveIn.size(); operandNum++) {
             if (blockData.get(ir.cfg.getStartBlock()).liveIn.get(operandNum)) {
                 Value operand = operandFor(operandNum);
                 TTY.println(" var %d; operand=%s; node=%s", operandNum, operand.toString(), gen.valueForOperand(operand));
 
+                Deque<Block> definedIn = new ArrayDeque<>();
+                HashSet<Block> usedIn = new HashSet<>();
                 for (int j = 0; j < numBlocks; j++) {
                     Block block = blockAt(j);
                     if (blockData.get(block).liveGen.get(operandNum)) {
+                        usedIn.add(block);
                         TTY.println("  used in block B%d", block.getId());
                         for (LIRInstruction ins : block.lir) {
                             TTY.println(ins.id() + ": " + ins.toString());
@@ -883,12 +887,36 @@
                         }
                     }
                     if (blockData.get(block).liveKill.get(operandNum)) {
+                        definedIn.add(block);
                         TTY.println("  defined in block B%d", block.getId());
                         for (LIRInstruction ins : block.lir) {
                             TTY.println(ins.id() + ": " + ins.toString());
                         }
                     }
                 }
+
+                int[] hitCount = new int[numBlocks];
+
+                while (!definedIn.isEmpty()) {
+                    Block block = definedIn.removeFirst();
+                    usedIn.remove(block);
+                    for (Block successor : block.getSuccessors()) {
+                        if (successor.isLoopHeader()) {
+                            if (!block.isLoopEnd()) {
+                                definedIn.add(successor);
+                            }
+                        } else {
+                            if (++hitCount[successor.getId()] == successor.getPredecessors().size()) {
+                                definedIn.add(successor);
+                            }
+                        }
+                    }
+                }
+                TTY.print("  offending usages are in: ");
+                for (Block block : usedIn) {
+                    TTY.print("B%d ", block.getId());
+                }
+                TTY.println();
             }
         }
     }