diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2014-10-07 14:14:27 +0100 |
---|---|---|
committer | Nicolas Geoffray <ngeoffray@google.com> | 2014-10-07 16:26:48 +0100 |
commit | 191c4b1372aef7c0272f8fa3985b55513029e728 (patch) | |
tree | ea8a2eb84a64b6f808f782ada9ea66ef69e8e764 /compiler/optimizing/nodes.cc | |
parent | 41abdb6ec97978df7c6d79abce4efb664c994ce8 (diff) | |
download | art-191c4b1372aef7c0272f8fa3985b55513029e728.zip art-191c4b1372aef7c0272f8fa3985b55513029e728.tar.gz art-191c4b1372aef7c0272f8fa3985b55513029e728.tar.bz2 |
Inserting a node must also update its inputs users.
Change-Id: I55357564b81efcc0cf52fffdf23289696fe27dd1
Diffstat (limited to 'compiler/optimizing/nodes.cc')
-rw-r--r-- | compiler/optimizing/nodes.cc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index 5c4ab8e..4cac319 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -308,6 +308,14 @@ bool HBasicBlock::Dominates(HBasicBlock* other) const { return false; } +static void UpdateInputsUsers(HInstruction* instruction) { + for (size_t i = 0, e = instruction->InputCount(); i < e; ++i) { + instruction->InputAt(i)->AddUseAt(instruction, i); + } + // Environment should be created later. + DCHECK(!instruction->HasEnvironment()); +} + void HBasicBlock::InsertInstructionBefore(HInstruction* instruction, HInstruction* cursor) { DCHECK(cursor->AsPhi() == nullptr); DCHECK(instruction->AsPhi() == nullptr); @@ -325,6 +333,7 @@ void HBasicBlock::InsertInstructionBefore(HInstruction* instruction, HInstructio } instruction->SetBlock(this); instruction->SetId(GetGraph()->GetNextInstructionId()); + UpdateInputsUsers(instruction); } void HBasicBlock::ReplaceAndRemoveInstructionWith(HInstruction* initial, @@ -342,6 +351,7 @@ static void Add(HInstructionList* instruction_list, DCHECK_EQ(instruction->GetId(), -1); instruction->SetBlock(block); instruction->SetId(block->GetGraph()->GetNextInstructionId()); + UpdateInputsUsers(instruction); instruction_list->AddInstruction(instruction); } @@ -421,9 +431,6 @@ void HInstructionList::AddInstruction(HInstruction* instruction) { instruction->previous_ = last_instruction_; last_instruction_ = instruction; } - for (size_t i = 0; i < instruction->InputCount(); i++) { - instruction->InputAt(i)->AddUseAt(instruction, i); - } } void HInstructionList::RemoveInstruction(HInstruction* instruction) { |