Remove sorting from always/force/never inline sets.
Bug: 132593519
Change-Id: Ie39dae8fadc6605c92bc530b0c27b1ec0a282ff4
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/Inliner.java b/src/main/java/com/android/tools/r8/ir/optimize/Inliner.java
index 9f790ec..945d9fe 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/Inliner.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/Inliner.java
@@ -126,7 +126,7 @@
AppInfoWithLiveness appInfo = appView.appInfo();
DexMethod singleTargetReference = singleTarget.getReference();
if (singleTarget.getDefinition().getOptimizationInfo().forceInline()
- && appInfo.neverInline.contains(singleTargetReference)) {
+ && appInfo.isNeverInlineMethod(singleTargetReference)) {
throw new Unreachable();
}
@@ -143,7 +143,7 @@
return true;
}
- if (appInfo.neverInline.contains(singleTargetReference)) {
+ if (appInfo.isNeverInlineMethod(singleTargetReference)) {
whyAreYouNotInliningReporter.reportMarkedAsNeverInline();
return true;
}
@@ -1091,8 +1091,8 @@
if (inlineeMayHaveInvokeMethod && options.applyInliningToInlinee) {
if (inlineeStack.size() + 1 > options.applyInliningToInlineeMaxDepth
- && appView.appInfo().alwaysInline.isEmpty()
- && appView.appInfo().forceInline.isEmpty()) {
+ && appView.appInfo().hasNoAlwaysInlineMethods()
+ && appView.appInfo().hasNoForceInlineMethods()) {
continue;
}
// Record that we will be inside the inlinee until the next block.
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/inliner/DefaultInliningReasonStrategy.java b/src/main/java/com/android/tools/r8/ir/optimize/inliner/DefaultInliningReasonStrategy.java
index ae543a2..bb270b9 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/inliner/DefaultInliningReasonStrategy.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/inliner/DefaultInliningReasonStrategy.java
@@ -36,12 +36,12 @@
DexMethod targetReference = target.getReference();
if (targetMethod.getOptimizationInfo().forceInline()
|| (appView.appInfo().hasLiveness()
- && appView.withLiveness().appInfo().forceInline.contains(targetReference))) {
- assert !appView.appInfo().neverInline.contains(targetReference);
+ && appView.withLiveness().appInfo().isForceInlineMethod(targetReference))) {
+ assert !appView.appInfo().isNeverInlineMethod(targetReference);
return Reason.FORCE;
}
if (appView.appInfo().hasLiveness()
- && appView.withLiveness().appInfo().alwaysInline.contains(targetReference)) {
+ && appView.withLiveness().appInfo().isAlwaysInlineMethod(targetReference)) {
return Reason.ALWAYS;
}
if (appView.options().disableInliningOfLibraryMethodOverrides
diff --git a/src/main/java/com/android/tools/r8/shaking/AppInfoWithLiveness.java b/src/main/java/com/android/tools/r8/shaking/AppInfoWithLiveness.java
index f656935..4d5a549 100644
--- a/src/main/java/com/android/tools/r8/shaking/AppInfoWithLiveness.java
+++ b/src/main/java/com/android/tools/r8/shaking/AppInfoWithLiveness.java
@@ -142,11 +142,11 @@
/** All items with assumevalues rule. */
public final Map<DexMember<?, ?>, ProguardMemberRule> assumedValues;
/** All methods that should be inlined if possible due to a configuration directive. */
- public final Set<DexMethod> alwaysInline;
+ private final Set<DexMethod> alwaysInline;
/** All methods that *must* be inlined due to a configuration directive (testing only). */
- public final Set<DexMethod> forceInline;
+ private final Set<DexMethod> forceInline;
/** All methods that *must* never be inlined due to a configuration directive (testing only). */
- public final Set<DexMethod> neverInline;
+ private final Set<DexMethod> neverInline;
/** Items for which to print inlining decisions for (testing only). */
public final Set<DexMethod> whyAreYouNotInlining;
/** All methods that may not have any parameters with a constant value removed. */
@@ -655,6 +655,26 @@
return virtualMethodsTargetedByInvokeDirect;
}
+ public boolean isAlwaysInlineMethod(DexMethod method) {
+ return alwaysInline.contains(method);
+ }
+
+ public boolean hasNoAlwaysInlineMethods() {
+ return alwaysInline.isEmpty();
+ }
+
+ public boolean isForceInlineMethod(DexMethod method) {
+ return forceInline.contains(method);
+ }
+
+ public boolean hasNoForceInlineMethods() {
+ return forceInline.isEmpty();
+ }
+
+ public boolean isNeverInlineMethod(DexMethod method) {
+ return neverInline.contains(method);
+ }
+
public Collection<DexClass> computeReachableInterfaces() {
Set<DexClass> interfaces = Sets.newIdentityHashSet();
WorkList<DexType> worklist = WorkList.newIdentityWorkList();
@@ -1062,9 +1082,9 @@
lens.rewriteReferenceKeys(mayHaveSideEffects),
lens.rewriteReferenceKeys(noSideEffects),
lens.rewriteReferenceKeys(assumedValues),
- lens.rewriteMethodsSorted(alwaysInline),
- lens.rewriteMethodsSorted(forceInline),
- lens.rewriteMethodsSorted(neverInline),
+ lens.rewriteMethods(alwaysInline),
+ lens.rewriteMethods(forceInline),
+ lens.rewriteMethods(neverInline),
lens.rewriteMethodsSorted(whyAreYouNotInlining),
lens.rewriteMethodsSorted(keepConstantArguments),
lens.rewriteMethodsSorted(keepUnusedArguments),
diff --git a/src/main/java/com/android/tools/r8/shaking/StaticClassMerger.java b/src/main/java/com/android/tools/r8/shaking/StaticClassMerger.java
index fe5a13a..2a72863 100644
--- a/src/main/java/com/android/tools/r8/shaking/StaticClassMerger.java
+++ b/src/main/java/com/android/tools/r8/shaking/StaticClassMerger.java
@@ -284,7 +284,7 @@
|| appView.appInfo().isPinned(method.method)
// TODO(christofferqa): Remove the invariant that the graph lens should not
// modify any methods from the sets alwaysInline and noSideEffects.
- || appView.appInfo().alwaysInline.contains(method.method)
+ || appView.appInfo().isAlwaysInlineMethod(method.method)
|| appView.appInfo().noSideEffects.keySet().contains(method.method))) {
return MergeGroup.DONT_MERGE;
}