Do not add call graph edges to kept methods
Bug: 142385443, 139304307
Change-Id: Ia88e2ac2ad556286d13cfec100da351eaaa8e2a3
diff --git a/src/main/java/com/android/tools/r8/ir/conversion/CallGraphBuilder.java b/src/main/java/com/android/tools/r8/ir/conversion/CallGraphBuilder.java
index d1ca480..8078fe0 100644
--- a/src/main/java/com/android/tools/r8/ir/conversion/CallGraphBuilder.java
+++ b/src/main/java/com/android/tools/r8/ir/conversion/CallGraphBuilder.java
@@ -134,10 +134,18 @@
}
private void addTarget(DexEncodedMethod callee, boolean likelySpuriousCallEdge) {
- if (!callee.accessFlags.isAbstract()) {
- assert callee.isProgramMethod(appView);
- getOrCreateNode(callee).addCallerConcurrently(caller, likelySpuriousCallEdge);
+ if (callee.accessFlags.isAbstract()) {
+ // Not a valid target.
+ return;
}
+ if (appView.appInfo().isPinned(callee.method)) {
+ // Since the callee is kept, we cannot inline it into the caller, and we also cannot collect
+ // any optimization info for the method. Therefore, we drop the call edge to reduce the
+ // total number of call graph edges, which should lead to fewer call graph cycles.
+ return;
+ }
+ assert callee.isProgramMethod(appView);
+ getOrCreateNode(callee).addCallerConcurrently(caller, likelySpuriousCallEdge);
}
private void processInvoke(Type originalType, DexMethod originalMethod) {