Avoid applying incomplete call site information
Change-Id: I4bc6de8d7d6529192b514514efc47ce78fba34ca
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 decb915..3911614 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
@@ -741,10 +741,16 @@
// !appView.hasLiveness() (which currently may happen due to the reflective behavior
// handling in the final round of tree shaking).
if (appView.hasLiveness()) {
- ArgumentPropagatorIROptimizer.optimize(
- appView.withLiveness(),
- ir,
- callSiteOptimizationInfo.asConcreteCallSiteOptimizationInfo());
+ if (appView
+ .options()
+ .callSiteOptimizationOptions()
+ .isExperimentalArgumentPropagationEnabled()
+ || appView.callSiteOptimizationInfoPropagator().getMode().isRevisit()) {
+ ArgumentPropagatorIROptimizer.optimize(
+ appView.withLiveness(),
+ ir,
+ callSiteOptimizationInfo.asConcreteCallSiteOptimizationInfo());
+ }
}
}
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/CallSiteOptimizationInfoPropagator.java b/src/main/java/com/android/tools/r8/ir/optimize/CallSiteOptimizationInfoPropagator.java
index 918db59..e58024e 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/CallSiteOptimizationInfoPropagator.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/CallSiteOptimizationInfoPropagator.java
@@ -45,11 +45,17 @@
// For now, before revisiting methods with more precise argument info, we switch the mode.
// Then, revisiting a target at a certain level will not improve call site information of
// callees in lower levels.
- private enum Mode {
- COLLECT, // Set until the end of the 1st round of IR processing. CallSiteOptimizationInfo will
- // be updated in this mode only.
- REVISIT // Set once the all methods are processed. IRBuilder will add other instructions that
- // reflect collected CallSiteOptimizationInfo.
+ public enum Mode {
+ // Set until the end of the 1st round of IR processing. CallSiteOptimizationInfo will be updated
+ // in this mode only.
+ COLLECT,
+ // Set once the all methods are processed. IRBuilder will add other instructions that reflect
+ // collected CallSiteOptimizationInfo.
+ REVISIT;
+
+ public boolean isRevisit() {
+ return this == REVISIT;
+ }
}
private final AppView<AppInfoWithLiveness> appView;
@@ -68,6 +74,10 @@
}
}
+ public Mode getMode() {
+ return mode;
+ }
+
public void logResults() {
assert Log.ENABLED;
if (revisitedMethods != null) {