From 564ffff5b472f3a2dc38c2ab51a78f2d0e3f7ea8 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Fri, 17 Jan 2025 11:52:54 +0000 Subject: Optimizing: Fix `InsertInputAt()`. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I500faee42b02dbc72474e30fa2a3c0388ae86674 --- compiler/optimizing/nodes.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'compiler/optimizing/nodes.cc') diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index fc7d0a52ab..ece11435db 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -1541,12 +1541,14 @@ void HVariableInputSizeInstruction::AddInput(HInstruction* input) { void HVariableInputSizeInstruction::InsertInputAt(size_t index, HInstruction* input) { inputs_.insert(inputs_.begin() + index, HUserRecord(input)); - input->AddUseAt(this, index); // Update indexes in use nodes of inputs that have been pushed further back by the insert(). for (size_t i = index + 1u, e = inputs_.size(); i < e; ++i) { DCHECK_EQ(inputs_[i].GetUseNode()->GetIndex(), i - 1u); inputs_[i].GetUseNode()->SetIndex(i); } + // Add the use after updating the indexes. If the `input` is already used by `this`, + // the fixup after use insertion can use those indexes. + input->AddUseAt(this, index); } void HVariableInputSizeInstruction::RemoveInputAt(size_t index) { -- cgit v1.2.3-59-g8ed1b