From c6b5627c25ff5653e97ccff8c5ccf6ac967b6f83 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Wed, 20 Apr 2016 18:45:25 +0100 Subject: Fix HInstruction::ReplaceInput(), allow no-op. Allow HInstruction::ReplaceInput() to be called with a `replacement` being the same as the old input and do nothing in that case. This is a follow-up to https://android-review.googlesource.com/216923 where I erroneously assumed that it never happens. Also adhere to the standard C++ std::forward_list<> semantics in the single-element overload of `IntrusiveForwardList<>::splice_after()`. Bug: 28173563 Change-Id: I5cea14c212b1083f90ffe6b5b53324ad663d57d8 --- compiler/optimizing/nodes.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'compiler/optimizing/nodes.cc') diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index 7c6e9318fb..fe75451ad2 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -1022,8 +1022,11 @@ void HInstruction::ReplaceWith(HInstruction* other) { void HInstruction::ReplaceInput(HInstruction* replacement, size_t index) { HUserRecord input_use = InputRecordAt(index); + if (input_use.GetInstruction() == replacement) { + // Nothing to do. + return; + } HUseList::iterator before_use_node = input_use.GetBeforeUseNode(); - DCHECK(input_use.GetInstruction() != replacement); // Note: fixup_end remains valid across splice_after(). auto fixup_end = replacement->uses_.empty() ? replacement->uses_.begin() : ++replacement->uses_.begin(); -- cgit v1.2.3-59-g8ed1b