Process callees before callers in second optimization pass

Change-Id: Ibbe3fecbc50bc2958f9e6b00ca10a58d96e49492
diff --git a/src/main/java/com/android/tools/r8/ir/conversion/PostMethodProcessor.java b/src/main/java/com/android/tools/r8/ir/conversion/PostMethodProcessor.java
index 06ddf34..4623428 100644
--- a/src/main/java/com/android/tools/r8/ir/conversion/PostMethodProcessor.java
+++ b/src/main/java/com/android/tools/r8/ir/conversion/PostMethodProcessor.java
@@ -149,7 +149,7 @@
     Deque<SortedProgramMethodSet> waves = new ArrayDeque<>();
     int waveCount = 1;
     while (!callGraph.isEmpty()) {
-      SortedProgramMethodSet wave = callGraph.extractRoots();
+      SortedProgramMethodSet wave = callGraph.extractLeaves();
       waves.addLast(wave);
       if (Log.ENABLED && Log.isLoggingEnabledFor(PostMethodProcessor.class)) {
         Log.info(getClass(), "Wave #%d: %d", waveCount++, wave.size());
diff --git a/src/test/java/com/android/tools/r8/internal/proto/Proto2ShrinkingTest.java b/src/test/java/com/android/tools/r8/internal/proto/Proto2ShrinkingTest.java
index 348a7f5..04cdea9 100644
--- a/src/test/java/com/android/tools/r8/internal/proto/Proto2ShrinkingTest.java
+++ b/src/test/java/com/android/tools/r8/internal/proto/Proto2ShrinkingTest.java
@@ -233,7 +233,10 @@
     }
 
     // Verify that the registry methods are still present in the output.
-    // TODO(b/112437944): Should they be optimized into a single findLiteExtensionByNumber() method?
+    //
+    // We expect findLiteExtensionByNumber2() to be inlined into findLiteExtensionByNumber1(). The
+    // method findLiteExtensionByNumber1() has two call sites from findLiteExtensionByNumber(),
+    // which prevents it from being single-caller inlined.
     {
       ClassSubject generatedExtensionRegistryLoader = outputInspector.clazz(extensionRegistryName);
       assertThat(generatedExtensionRegistryLoader, isPresent());
@@ -245,7 +248,7 @@
           isPresent());
       assertThat(
           generatedExtensionRegistryLoader.uniqueMethodWithName("findLiteExtensionByNumber2"),
-          isPresent());
+          not(isPresent()));
     }
 
     // Verify that unused extensions have been removed with -allowaccessmodification.