diff options
author | Vladimir Marko <vmarko@google.com> | 2017-10-11 20:39:54 +0100 |
---|---|---|
committer | Vladimir Marko <vmarko@google.com> | 2017-10-12 10:58:02 +0100 |
commit | bea75ff0835324076fed6ff5d443b9e02c65d223 (patch) | |
tree | 61ae2e8fe552938fcae1e277f51823ba2a4f6e74 /compiler/optimizing/code_generator.cc | |
parent | 567563a9c6ccc06c2c9889d1c3c4feaa3c2b2dab (diff) |
Fix using LiveIntervals beyond their lifetime.
Fixes a bug introduced by
https://android-review.googlesource.com/504041
Test: test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 64312607
Change-Id: I7fd2d55c2a657f736eaed7c94c41d1237ae2ec0b
Diffstat (limited to 'compiler/optimizing/code_generator.cc')
-rw-r--r-- | compiler/optimizing/code_generator.cc | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/compiler/optimizing/code_generator.cc b/compiler/optimizing/code_generator.cc index dd8e3d240f..84f01828b2 100644 --- a/compiler/optimizing/code_generator.cc +++ b/compiler/optimizing/code_generator.cc @@ -935,7 +935,7 @@ void CodeGenerator::RecordCatchBlockInfo() { if (current_phi == nullptr || current_phi->AsPhi()->GetRegNumber() != vreg) { stack_map_stream_.AddDexRegisterEntry(DexRegisterLocation::Kind::kNone, 0); } else { - Location location = current_phi->GetLiveInterval()->ToLocation(); + Location location = current_phi->GetLocations()->Out(); switch (location.GetKind()) { case Location::kStackSlot: { stack_map_stream_.AddDexRegisterEntry( @@ -1202,22 +1202,21 @@ void CodeGenerator::GenerateNullCheck(HNullCheck* instruction) { } } -void CodeGenerator::ClearSpillSlotsFromLoopPhisInStackMap(HSuspendCheck* suspend_check) const { +void CodeGenerator::ClearSpillSlotsFromLoopPhisInStackMap(HSuspendCheck* suspend_check, + HParallelMove* spills) const { LocationSummary* locations = suspend_check->GetLocations(); HBasicBlock* block = suspend_check->GetBlock(); DCHECK(block->GetLoopInformation()->GetSuspendCheck() == suspend_check); DCHECK(block->IsLoopHeader()); - - for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) { - HInstruction* current = it.Current(); - LiveInterval* interval = current->GetLiveInterval(); - // We only need to clear bits of loop phis containing objects and allocated in register. - // Loop phis allocated on stack already have the object in the stack. - if (current->GetType() == DataType::Type::kReference - && interval->HasRegister() - && interval->HasSpillSlot()) { - locations->ClearStackBit(interval->GetSpillSlot() / kVRegSize); - } + DCHECK(block->GetFirstInstruction() == spills); + + for (size_t i = 0, num_moves = spills->NumMoves(); i != num_moves; ++i) { + Location dest = spills->MoveOperandsAt(i)->GetDestination(); + // All parallel moves in loop headers are spills. + DCHECK(dest.IsStackSlot() || dest.IsDoubleStackSlot() || dest.IsSIMDStackSlot()) << dest; + // Clear the stack bit marking a reference. Do not bother to check if the spill is + // actually a reference spill, clearing bits that are already zero is harmless. + locations->ClearStackBit(dest.GetStackIndex() / kVRegSize); } } |