Don't populate the noObfuscation set when not minifying.
Bug: 160605696
Change-Id: I3cd43f255444c1f8199a3d4c5602d4d74a546f2e
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 5b53c1f..5c0f735 100644
--- a/src/main/java/com/android/tools/r8/shaking/Enqueuer.java
+++ b/src/main/java/com/android/tools/r8/shaking/Enqueuer.java
@@ -1884,21 +1884,27 @@
}
}
+ private void shouldNotBeMinified(DexReference reference) {
+ if (options.isMinificationEnabled()) {
+ rootSet.shouldNotBeMinified(reference);
+ }
+ }
+
private void keepClassAndAllMembers(DexProgramClass clazz, KeepReason keepReason) {
KeepReasonWitness keepReasonWitness = graphReporter.registerClass(clazz, keepReason);
markClassAsInstantiatedWithCompatRule(clazz.asProgramClass(), keepReasonWitness);
keepInfo.keepClass(clazz);
- rootSet.shouldNotBeMinified(clazz.toReference());
+ shouldNotBeMinified(clazz.toReference());
clazz.forEachProgramField(
field -> {
keepInfo.keepField(field);
- rootSet.shouldNotBeMinified(field.getReference());
+ shouldNotBeMinified(field.getReference());
markFieldAsKept(field, keepReasonWitness);
});
clazz.forEachProgramMethod(
method -> {
keepInfo.keepMethod(method);
- rootSet.shouldNotBeMinified(method.getReference());
+ shouldNotBeMinified(method.getReference());
markMethodAsKept(method, keepReasonWitness);
});
}
@@ -2594,7 +2600,7 @@
// marking for not renaming it is in the root set.
workList.enqueueMarkMethodKeptAction(new ProgramMethod(clazz, valuesMethod), reason);
keepInfo.keepMethod(clazz, valuesMethod);
- rootSet.shouldNotBeMinified(valuesMethod.toReference());
+ shouldNotBeMinified(valuesMethod.toReference());
}
}
@@ -2673,6 +2679,7 @@
// This is simulating the effect of the "root set" applied rules.
// This is done only in the initial pass, in subsequent passes the "rules" are reapplied
// by iterating the instances.
+ assert appView.options().isMinificationEnabled() || rootSet.noObfuscation.isEmpty();
for (DexReference reference : rootSet.noObfuscation) {
keepInfo.evaluateRule(reference, appInfo, Joiner::disallowMinification);
}
diff --git a/src/main/java/com/android/tools/r8/shaking/RootSetBuilder.java b/src/main/java/com/android/tools/r8/shaking/RootSetBuilder.java
index ec9f101..08830cc 100644
--- a/src/main/java/com/android/tools/r8/shaking/RootSetBuilder.java
+++ b/src/main/java/com/android/tools/r8/shaking/RootSetBuilder.java
@@ -326,6 +326,7 @@
assert Sets.intersection(neverInline, alwaysInline).isEmpty()
&& Sets.intersection(neverInline, forceInline).isEmpty()
: "A method cannot be marked as both -neverinline and -forceinline/-alwaysinline.";
+ assert appView.options().isMinificationEnabled() || noObfuscation.isEmpty();
return new RootSet(
noShrinking,
noObfuscation,
@@ -1035,7 +1036,9 @@
.computeIfAbsent(item.toReference(), x -> new MutableItemsWithRules())
.addClassWithRule(type, context);
// Unconditionally add to no-obfuscation, as that is only checked for surviving items.
- noObfuscation.add(type);
+ if (appView.options().isMinificationEnabled()) {
+ noObfuscation.add(type);
+ }
}
private void includeDescriptorClasses(DexDefinition item, ProguardKeepRuleBase context) {
@@ -1133,7 +1136,7 @@
context.markAsUsed();
}
- if (!modifiers.allowsObfuscation) {
+ if (appView.options().isMinificationEnabled() && !modifiers.allowsObfuscation) {
noObfuscation.add(item.toReference());
context.markAsUsed();
}