# HG changeset patch # User Lukas Stadler # Date 1347365294 -7200 # Node ID b76534871d06c140077a77504da9abc79da2bbf3 # Parent c5024000ff0fd5b9a7fa263319c09a6a19fca280 determine offending use blocks for liveIn - violations diff -r c5024000ff0f -r b76534871d06 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java --- 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 definedIn = new ArrayDeque<>(); + HashSet 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(); } } }