Version 2.0.44

Cherry pick: Always mark synthesized interface bridges as pinned
CL: https://r8-review.googlesource.com/c/r8/+/49321

Cherry pick: Remove redundant accessibility checks from inlining constraint computation
CL: https://r8-review.googlesource.com/c/r8/+/49320

Cherry pick: Do not compute inlining constraint for pinned methods
CL: https://r8-review.googlesource.com/c/r8/+/49324

Cherry pick: Fix NPE arising from the absence of synthesized type
CL: https://r8-review.googlesource.com/c/r8/+/49325

Bug: 150508871, 150443272, 150442580, 150454980, 150269949, 150347755
Change-Id: I4e70015213861acadb62beede6b411783030050c
diff --git a/src/main/java/com/android/tools/r8/R8.java b/src/main/java/com/android/tools/r8/R8.java
index 06fb565..462a4ae 100644
--- a/src/main/java/com/android/tools/r8/R8.java
+++ b/src/main/java/com/android/tools/r8/R8.java
@@ -320,6 +320,7 @@
         assert appView.rootSet().verifyKeptFieldsAreAccessedAndLive(appViewWithLiveness.appInfo());
         assert appView.rootSet().verifyKeptMethodsAreTargetedAndLive(appViewWithLiveness.appInfo());
         assert appView.rootSet().verifyKeptTypesAreLive(appViewWithLiveness.appInfo());
+        assert appView.rootSet().verifyKeptItemsAreKept(appView.appInfo().app(), appView.appInfo());
 
         appView.rootSet().checkAllRulesAreUsed(options);
 
diff --git a/src/main/java/com/android/tools/r8/Version.java b/src/main/java/com/android/tools/r8/Version.java
index 993d66a..01ba053 100644
--- a/src/main/java/com/android/tools/r8/Version.java
+++ b/src/main/java/com/android/tools/r8/Version.java
@@ -11,7 +11,7 @@
 
   // This field is accessed from release scripts using simple pattern matching.
   // Therefore, changing this field could break our release scripts.
-  public static final String LABEL = "2.0.43";
+  public static final String LABEL = "2.0.44";
 
   private Version() {
   }
diff --git a/src/main/java/com/android/tools/r8/ir/conversion/IRConverter.java b/src/main/java/com/android/tools/r8/ir/conversion/IRConverter.java
index 7b6df447..650c757 100644
--- a/src/main/java/com/android/tools/r8/ir/conversion/IRConverter.java
+++ b/src/main/java/com/android/tools/r8/ir/conversion/IRConverter.java
@@ -734,6 +734,7 @@
     generateDesugaredLibraryAPIWrappers(builder, executorService);
 
     if (serviceLoaderRewriter != null && serviceLoaderRewriter.getSynthesizedClass() != null) {
+      appView.appInfo().addSynthesizedClass(serviceLoaderRewriter.getSynthesizedClass());
       processSynthesizedServiceLoaderMethods(
           serviceLoaderRewriter.getSynthesizedClass(), executorService);
       builder.addSynthesizedClass(serviceLoaderRewriter.getSynthesizedClass(), true);
@@ -1520,17 +1521,27 @@
 
   private void markProcessed(DexEncodedMethod method, IRCode code, OptimizationFeedback feedback) {
     // After all the optimizations have take place, we compute whether method should be inlined.
-    ConstraintWithTarget state;
-    if (!options.enableInlining
-        || inliner == null
-        || method.getOptimizationInfo().isReachabilitySensitive()) {
-      state = ConstraintWithTarget.NEVER;
-    } else {
-      state = inliner.computeInliningConstraint(code, method);
-    }
+    ConstraintWithTarget state =
+        shouldComputeInliningConstraint(method)
+            ? inliner.computeInliningConstraint(code, method)
+            : ConstraintWithTarget.NEVER;
     feedback.markProcessed(method, state);
   }
 
+  private boolean shouldComputeInliningConstraint(DexEncodedMethod method) {
+    if (!options.enableInlining || inliner == null) {
+      return false;
+    }
+    if (method.isClassInitializer() || method.getOptimizationInfo().isReachabilitySensitive()) {
+      return false;
+    }
+    if (appView.appInfo().hasLiveness()
+        && appView.appInfo().withLiveness().isPinned(method.method)) {
+      return false;
+    }
+    return true;
+  }
+
   private synchronized void updateHighestSortingStrings(DexEncodedMethod method) {
     DexString highestSortingReferencedString = method.getCode().asDexCode().highestSortingString;
     if (highestSortingReferencedString != null) {
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/InliningConstraints.java b/src/main/java/com/android/tools/r8/ir/optimize/InliningConstraints.java
index b95f69e..db48576 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/InliningConstraints.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/InliningConstraints.java
@@ -19,7 +19,6 @@
 import com.android.tools.r8.ir.optimize.Inliner.Constraint;
 import com.android.tools.r8.ir.optimize.Inliner.ConstraintWithTarget;
 import com.android.tools.r8.shaking.AppInfoWithLiveness;
-import java.util.Collection;
 
 // Computes the inlining constraint for a given instruction.
 public class InliningConstraints {
@@ -376,28 +375,7 @@
     ConstraintWithTarget classConstraintWithTarget =
         ConstraintWithTarget.deriveConstraint(
             invocationContext, methodHolder, methodClass.accessFlags, appView);
-    ConstraintWithTarget result =
-        ConstraintWithTarget.meet(methodConstraintWithTarget, classConstraintWithTarget, appView);
-    if (result == ConstraintWithTarget.NEVER) {
-      return result;
-    }
-
-    // For each of the actual potential targets, derive constraints based on the accessibility
-    // of the method itself.
-    Collection<DexEncodedMethod> targets =
-        resolutionResult.lookupVirtualDispatchTargets(isInterface, appView.appInfo());
-    for (DexEncodedMethod target : targets) {
-      methodHolder = graphLense.lookupType(target.method.holder);
-      assert appView.definitionFor(methodHolder) != null;
-      methodConstraintWithTarget =
-          ConstraintWithTarget.deriveConstraint(
-              invocationContext, methodHolder, target.accessFlags, appView);
-      result = ConstraintWithTarget.meet(result, methodConstraintWithTarget, appView);
-      if (result == ConstraintWithTarget.NEVER) {
-        return result;
-      }
-    }
-
-    return result;
+    return ConstraintWithTarget.meet(
+        methodConstraintWithTarget, classConstraintWithTarget, appView);
   }
 }
diff --git a/src/main/java/com/android/tools/r8/shaking/Enqueuer.java b/src/main/java/com/android/tools/r8/shaking/Enqueuer.java
index 1a0bc08..6b687c8 100644
--- a/src/main/java/com/android/tools/r8/shaking/Enqueuer.java
+++ b/src/main/java/com/android/tools/r8/shaking/Enqueuer.java
@@ -2296,10 +2296,13 @@
     assert fieldAccessInfoCollection.verifyMappingIsOneToOne();
 
     for (ProgramMethod bridge : syntheticInterfaceMethodBridges.values()) {
-      appView.appInfo().invalidateTypeCacheFor(bridge.holder.type);
-      bridge.holder.appendVirtualMethod(bridge.method);
-      targetedMethods.add(bridge.method, graphReporter.fakeReportShouldNotBeUsed());
-      liveMethods.add(bridge.holder, bridge.method, graphReporter.fakeReportShouldNotBeUsed());
+      DexProgramClass holder = bridge.holder;
+      DexEncodedMethod method = bridge.method;
+      appView.appInfo().invalidateTypeCacheFor(holder.type);
+      holder.appendVirtualMethod(method);
+      targetedMethods.add(method, graphReporter.fakeReportShouldNotBeUsed());
+      liveMethods.add(holder, method, graphReporter.fakeReportShouldNotBeUsed());
+      pinnedItems.add(method.method);
     }
 
     AppInfoWithLiveness appInfoWithLiveness =