Remove pointless argument analysis
Bug: 147860220
Change-Id: I076cf06819d3c98056a199b13fa6a32c16317b8c
diff --git a/src/main/java/com/android/tools/r8/ir/analysis/type/TypeAnalysis.java b/src/main/java/com/android/tools/r8/ir/analysis/type/TypeAnalysis.java
index 1269d73..0596d7b 100644
--- a/src/main/java/com/android/tools/r8/ir/analysis/type/TypeAnalysis.java
+++ b/src/main/java/com/android/tools/r8/ir/analysis/type/TypeAnalysis.java
@@ -3,13 +3,9 @@
// BSD-style license that can be found in the LICENSE file.
package com.android.tools.r8.ir.analysis.type;
-import static com.android.tools.r8.ir.analysis.type.Nullability.definitelyNotNull;
-import static com.android.tools.r8.ir.analysis.type.Nullability.maybeNull;
-import static com.android.tools.r8.ir.analysis.type.TypeLatticeElement.fromDexType;
import com.android.tools.r8.graph.AppInfoWithSubtyping;
import com.android.tools.r8.graph.AppView;
-import com.android.tools.r8.graph.DexEncodedMethod;
import com.android.tools.r8.graph.DexType;
import com.android.tools.r8.ir.code.BasicBlock;
import com.android.tools.r8.ir.code.IRCode;
@@ -57,10 +53,10 @@
}
}
- public void widening(DexEncodedMethod context, DexEncodedMethod encodedMethod, IRCode code) {
+ public void widening(IRCode code) {
mode = Mode.WIDENING;
assert worklist.isEmpty();
- code.topologicallySortedBlocks().forEach(b -> analyzeBasicBlock(context, encodedMethod, b));
+ code.topologicallySortedBlocks().forEach(this::analyzeBasicBlock);
analyze();
}
@@ -95,32 +91,14 @@
}
}
- private void analyzeBasicBlock(
- DexEncodedMethod context, DexEncodedMethod encodedMethod, BasicBlock block) {
- int argumentsSeen = encodedMethod.accessFlags.isStatic() ? 0 : -1;
+ private void analyzeBasicBlock(BasicBlock block) {
for (Instruction instruction : block.getInstructions()) {
Value outValue = instruction.outValue();
if (outValue == null) {
continue;
}
- // The type for Argument, a quasi instruction, can be inferred from the method signature.
if (instruction.isArgument()) {
- TypeLatticeElement derived;
- if (argumentsSeen < 0) {
- // Receiver
- derived =
- fromDexType(
- encodedMethod.method.holder,
- // Now we try inlining even when the receiver could be null.
- encodedMethod == context ? definitelyNotNull() : maybeNull(),
- appView);
- } else {
- DexType argType = encodedMethod.method.proto.parameters.values[argumentsSeen];
- derived = fromDexType(argType, maybeNull(), appView);
- }
- argumentsSeen++;
- assert outValue.getTypeLattice().equals(derived);
- updateTypeOfValue(outValue, derived);
+ // The type for Argument, a quasi instruction is already set correctly during IR building.
// Note that we don't need to enqueue the out value of arguments here because it's constant.
} else if (instruction.hasInvariantOutType()) {
TypeLatticeElement derived = instruction.evaluate(appView);
diff --git a/src/main/java/com/android/tools/r8/ir/conversion/IRBuilder.java b/src/main/java/com/android/tools/r8/ir/conversion/IRBuilder.java
index 3d0fed3..a39a66b 100644
--- a/src/main/java/com/android/tools/r8/ir/conversion/IRBuilder.java
+++ b/src/main/java/com/android/tools/r8/ir/conversion/IRBuilder.java
@@ -619,9 +619,9 @@
if (hasImpreciseValues || impreciseInstructions != null) {
// In DEX we may need to constrain all values and instructions to precise types.
assert source instanceof DexSourceCode;
- new TypeConstraintResolver(appView, this).resolve(impreciseInstructions, ir, method, context);
+ new TypeConstraintResolver(appView, this).resolve(impreciseInstructions, ir);
} else {
- new TypeAnalysis(appView).widening(context, method, ir);
+ new TypeAnalysis(appView).widening(ir);
}
// Update the IR code if collected call site optimization info has something useful.
diff --git a/src/main/java/com/android/tools/r8/ir/conversion/TypeConstraintResolver.java b/src/main/java/com/android/tools/r8/ir/conversion/TypeConstraintResolver.java
index 2c41a2a..7257d49 100644
--- a/src/main/java/com/android/tools/r8/ir/conversion/TypeConstraintResolver.java
+++ b/src/main/java/com/android/tools/r8/ir/conversion/TypeConstraintResolver.java
@@ -6,7 +6,6 @@
import com.android.tools.r8.errors.CompilationError;
import com.android.tools.r8.errors.Unreachable;
import com.android.tools.r8.graph.AppView;
-import com.android.tools.r8.graph.DexEncodedMethod;
import com.android.tools.r8.ir.analysis.type.ArrayTypeLatticeElement;
import com.android.tools.r8.ir.analysis.type.TypeAnalysis;
import com.android.tools.r8.ir.analysis.type.TypeLatticeElement;
@@ -92,16 +91,12 @@
}
}
- public void resolve(
- List<ImpreciseMemberTypeInstruction> impreciseInstructions,
- IRCode code,
- DexEncodedMethod method,
- DexEncodedMethod context) {
+ public void resolve(List<ImpreciseMemberTypeInstruction> impreciseInstructions, IRCode code) {
// Round one will resolve at least all object vs single types.
List<Value> remainingImpreciseValues = resolveRoundOne(code);
// Round two will resolve any remaining single and wide types. These can depend on the types
// of array instructions, thus we need to complete the type fixed point prior to resolving.
- new TypeAnalysis(appView, true).widening(context, method, code);
+ new TypeAnalysis(appView, true).widening(code);
// Round two resolves any remaining imprecision and finally selects a final precise type for
// any unconstrained imprecise type.
resolveRoundTwo(code, impreciseInstructions, remainingImpreciseValues);