diff options
author | Ian Zerny <zerny@google.com> | 2017-07-05 10:56:32 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-07-05 10:56:32 +0000 |
commit | ac25c3d3e8f287fe118e5b98d9ca012881df67ef (patch) | |
tree | 37ea24b90b58a01207b0006a1d63d73737e2bc68 /src/main/java/com/android/tools/r8 | |
parent | 0581415584cc9bcd8a6119ecca430821201d803e (diff) | |
parent | e652e6a181f59a0fc1af30e54982426b779e1a5b (diff) | |
download | r8-ac25c3d3e8f287fe118e5b98d9ca012881df67ef.tar.gz |
Merge "Don't consider debug-value uses as actual uses."
Diffstat (limited to 'src/main/java/com/android/tools/r8')
3 files changed, 23 insertions, 26 deletions
diff --git a/src/main/java/com/android/tools/r8/ir/regalloc/LinearScanRegisterAllocator.java b/src/main/java/com/android/tools/r8/ir/regalloc/LinearScanRegisterAllocator.java index 631f8b2a9..eb0aa77f5 100644 --- a/src/main/java/com/android/tools/r8/ir/regalloc/LinearScanRegisterAllocator.java +++ b/src/main/java/com/android/tools/r8/ir/regalloc/LinearScanRegisterAllocator.java @@ -1808,7 +1808,7 @@ public class LinearScanRegisterAllocator implements RegisterAllocator { addLiveRange(use, block, number); } LiveIntervals useIntervals = use.getLiveIntervals(); - useIntervals.addUse(new LiveIntervalsUse(number, Constants.U16BIT_MAX)); + useIntervals.addUse(new LiveIntervalsUse(number, Constants.U16BIT_MAX, true)); } Value use = instruction.getPreviousLocalValue(); if (use != null) { @@ -1818,7 +1818,7 @@ public class LinearScanRegisterAllocator implements RegisterAllocator { addLiveRange(use, block, number); } LiveIntervals useIntervals = use.getLiveIntervals(); - useIntervals.addUse(new LiveIntervalsUse(number, Constants.U16BIT_MAX)); + useIntervals.addUse(new LiveIntervalsUse(number, Constants.U16BIT_MAX, true)); } } } @@ -1850,27 +1850,14 @@ public class LinearScanRegisterAllocator implements RegisterAllocator { Value previous = null; for (int i = 0; i < arguments.size(); i++) { Value argument = arguments.get(i); - Value newArgument = argument; - // In debug mode, we have debug instructions that are also moves. Do not generate another - // move if there already is a move instruction that we can use. We generate moves if: - // - // 1. the argument is not defined by a move, - // - // 2. the argument is already linked or would cause a cycle if linked, or - // - // 3. the argument has a register constraint (the argument moves are there to make the - // input value to a ranged invoke unconstrained.) - if (argument.definition == null || - !argument.definition.isMove() || - argument.isLinked() || - argument == previous || - argument.hasRegisterConstraint()) { - newArgument = createValue(argument.outType()); - Move move = new Move(newArgument, argument); - move.setBlock(invoke.getBlock()); - replaceArgument(invoke, i, newArgument); - insertAt.add(move); - } + // TODO(ager): Conditionally create a new argument if it is not already a move. + // Reverted optimization from CL: https://r8-review.googlesource.com/c/1985/ + // Not considering debug-uses causes a unlinked/non-consecutive register in some cases. + Value newArgument = createValue(argument.outType()); + Move move = new Move(newArgument, argument); + move.setBlock(invoke.getBlock()); + replaceArgument(invoke, i, newArgument); + insertAt.add(move); if (previous != null) { previous.linkTo(newArgument); } diff --git a/src/main/java/com/android/tools/r8/ir/regalloc/LiveIntervals.java b/src/main/java/com/android/tools/r8/ir/regalloc/LiveIntervals.java index 06b33f473..9c28724a7 100644 --- a/src/main/java/com/android/tools/r8/ir/regalloc/LiveIntervals.java +++ b/src/main/java/com/android/tools/r8/ir/regalloc/LiveIntervals.java @@ -319,7 +319,7 @@ public class LiveIntervals { public int firstUseAfter(int unhandledStart) { for (LiveIntervalsUse use : uses) { - if (use.getPosition() >= unhandledStart) { + if (use.getPosition() >= unhandledStart && !use.isDebugUse()) { return use.getPosition(); } } diff --git a/src/main/java/com/android/tools/r8/ir/regalloc/LiveIntervalsUse.java b/src/main/java/com/android/tools/r8/ir/regalloc/LiveIntervalsUse.java index a60213453..edf876ded 100644 --- a/src/main/java/com/android/tools/r8/ir/regalloc/LiveIntervalsUse.java +++ b/src/main/java/com/android/tools/r8/ir/regalloc/LiveIntervalsUse.java @@ -6,12 +6,18 @@ package com.android.tools.r8.ir.regalloc; import static com.android.tools.r8.dex.Constants.U16BIT_MAX; public class LiveIntervalsUse implements Comparable<LiveIntervalsUse> { - private int position; - private int limit; + private final int position; + private final int limit; + private final boolean debugUse; public LiveIntervalsUse(int position, int limit) { + this(position, limit, false); + } + + public LiveIntervalsUse(int position, int limit, boolean debugUse) { this.position = position; this.limit = limit; + this.debugUse = debugUse; } public int getPosition() { @@ -47,4 +53,8 @@ public class LiveIntervalsUse implements Comparable<LiveIntervalsUse> { public boolean hasConstraint() { return limit < U16BIT_MAX; } + + public boolean isDebugUse() { + return debugUse; + } } |