HStringBuilderAppend cannot be null.
Fix DCHECK() failure where we replaced an instruction
with non-null result (HInvoke StringBuilder.toString())
with an instruction that did not report that the result
cannot be null (HStringBuilderAppend) and then used the
result as both receiver and argument for String.equals().
The fix is to preserve the "cannot be null" invariant.
Test: Additional test in 697-checker-string-append.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 151107293
Bug: 19575890
Change-Id: I205f002bf8d2dfee6079ea0e14786ca0ab2e2e9c
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index 817ff67..84297ec 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -2619,6 +2619,8 @@
append->SetArgumentAt(i, args[num_args - 1u - i]);
}
block->InsertInstructionBefore(append, invoke);
+ DCHECK(!invoke->CanBeNull());
+ DCHECK(!append->CanBeNull());
invoke->ReplaceWith(append);
// Copy environment, except for the StringBuilder uses.
for (HEnvironment* env = invoke->GetEnvironment(); env != nullptr; env = env->GetParent()) {