Verify InitClass values have no users
This reverts commit 8eadbf877b3c077ff9515b4c1d9577d3180544f3.
Bug: 192293683
Change-Id: Id150b56756c636b7b75dd44b01d347208162865e
diff --git a/src/main/java/com/android/tools/r8/ir/code/BasicBlock.java b/src/main/java/com/android/tools/r8/ir/code/BasicBlock.java
index 7dbc0ad..5c89899 100644
--- a/src/main/java/com/android/tools/r8/ir/code/BasicBlock.java
+++ b/src/main/java/com/android/tools/r8/ir/code/BasicBlock.java
@@ -62,12 +62,14 @@
private Int2ReferenceMap<DebugLocalInfo> localsAtEntry;
- public boolean consistentBlockInstructions(boolean argumentsAllowed, boolean debug) {
+ public boolean consistentBlockInstructions(boolean argumentsAllowed, boolean debug, boolean ssa) {
for (Instruction instruction : getInstructions()) {
assert instruction.verifyValidPositionInfo(debug);
assert instruction.getBlock() == this;
assert !instruction.isArgument() || argumentsAllowed;
assert !instruction.isDebugLocalRead() || !instruction.getDebugValues().isEmpty();
+ assert !instruction.isInitClass()
+ || consistentInitClassInstruction(instruction.asInitClass(), ssa);
if (instruction.isMoveException()) {
assert instruction == entry();
for (BasicBlock pred : getPredecessors()) {
@@ -82,6 +84,17 @@
return true;
}
+ public boolean consistentInitClassInstruction(InitClass initClass, boolean ssa) {
+ if (!ssa) {
+ return true;
+ }
+ assert initClass.hasOutValue();
+ assert !initClass.outValue().hasDebugUsers();
+ assert !initClass.outValue().hasPhiUsers();
+ assert initClass.outValue().uniqueUsers().stream().allMatch(Instruction::isPop);
+ return true;
+ }
+
public boolean verifyTypes(AppView<?> appView, VerifyTypesHelper verifyTypesHelper) {
assert instructions.stream()
.allMatch(instruction -> instruction.verifyTypes(appView, verifyTypesHelper));
diff --git a/src/main/java/com/android/tools/r8/ir/code/IRCode.java b/src/main/java/com/android/tools/r8/ir/code/IRCode.java
index 202df23..6fa8653 100644
--- a/src/main/java/com/android/tools/r8/ir/code/IRCode.java
+++ b/src/main/java/com/android/tools/r8/ir/code/IRCode.java
@@ -577,7 +577,8 @@
}
public boolean isConsistentSSABeforeTypesAreCorrect() {
- assert isConsistentGraph();
+ assert isConsistentGraph(true);
+ assert consistentBlockInstructions(true);
assert consistentDefUseChains();
assert validThrowingInstructions();
assert noCriticalEdges();
@@ -608,11 +609,15 @@
}
public boolean isConsistentGraph() {
+ return isConsistentGraph(false);
+ }
+
+ public boolean isConsistentGraph(boolean ssa) {
assert noColorsInUse();
assert consistentBlockNumbering();
assert consistentPredecessorSuccessors();
assert consistentCatchHandlers();
- assert consistentBlockInstructions();
+ assert consistentBlockInstructions(ssa);
assert consistentMetadata();
assert !allThrowingInstructionsHavePositions || computeAllThrowingInstructionsHavePositions();
return true;
@@ -804,12 +809,13 @@
return true;
}
- private boolean consistentBlockInstructions() {
+ private boolean consistentBlockInstructions(boolean ssa) {
boolean argumentsAllowed = true;
for (BasicBlock block : blocks) {
assert block.consistentBlockInstructions(
argumentsAllowed,
- options.debug || method().getOptimizationInfo().isReachabilitySensitive());
+ options.debug || method().getOptimizationInfo().isReachabilitySensitive(),
+ ssa);
argumentsAllowed = false;
}
return true;