diff options
Diffstat (limited to 'compiler/optimizing/instruction_simplifier_test.cc')
-rw-r--r-- | compiler/optimizing/instruction_simplifier_test.cc | 65 |
1 files changed, 19 insertions, 46 deletions
diff --git a/compiler/optimizing/instruction_simplifier_test.cc b/compiler/optimizing/instruction_simplifier_test.cc index 3f49492938..e140c4d058 100644 --- a/compiler/optimizing/instruction_simplifier_test.cc +++ b/compiler/optimizing/instruction_simplifier_test.cc @@ -52,16 +52,16 @@ class InstructionSimplifierTestBase : public SuperClass, public OptimizingUnitTe gLogVerbosity.compiler = false; } - void PerformSimplification(const AdjacencyListGraph& blks) { + void PerformSimplification() { if (kDebugSimplifierTests) { - LOG(INFO) << "Pre simplification " << blks; + graph_->Dump(LOG_STREAM(INFO) << "Pre simplification ", /* codegen_= */ nullptr); } graph_->ClearDominanceInformation(); graph_->BuildDominatorTree(); InstructionSimplifier simp(graph_, /*codegen=*/nullptr); simp.Run(); if (kDebugSimplifierTests) { - LOG(INFO) << "Post simplify " << blks; + graph_->Dump(LOG_STREAM(INFO) << "Post simplify ", /* codegen_= */ nullptr); } } }; @@ -104,9 +104,9 @@ class InstanceOfInstructionSimplifierTestGroup } std::pair<HLoadClass*, HLoadClass*> GetLoadClasses(HBasicBlock* block, - VariableSizedHandleScope* vshs) { + VariableSizedHandleScope* vshs) + REQUIRES_SHARED(Locks::mutator_lock_) { InstanceOfKind kind = GetParam(); - ScopedObjectAccess soa(Thread::Current()); // New inst always needs to have a valid rti since we dcheck that. HLoadClass* new_inst = MakeLoadClass( block, @@ -150,27 +150,14 @@ class InstanceOfInstructionSimplifierTestGroup TEST_P(InstanceOfInstructionSimplifierTestGroup, ExactClassInstanceOfOther) { ScopedObjectAccess soa(Thread::Current()); VariableSizedHandleScope vshs(soa.Self()); - InitGraph(/*handles=*/&vshs); - - AdjacencyListGraph blks(SetupFromAdjacencyList("entry", - "exit", - {{"entry", "left"}, - {"entry", "right"}, - {"left", "breturn"}, - {"right", "breturn"}, - {"breturn", "exit"}})); -#define GET_BLOCK(name) HBasicBlock* name = blks.Get(#name) - GET_BLOCK(entry); - GET_BLOCK(exit); - GET_BLOCK(breturn); - GET_BLOCK(left); - GET_BLOCK(right); -#undef GET_BLOCK + HBasicBlock* breturn = InitEntryMainExitGraph(/*handles=*/&vshs); + auto [if_block, left, right] = CreateDiamondPattern(breturn); EnsurePredecessorOrder(breturn, {left, right}); + HInstruction* test_res = graph_->GetIntConstant(GetConstantResult() ? 1 : 0); - auto [new_inst_klass, target_klass] = GetLoadClasses(entry, &vshs); - HInstruction* new_inst = MakeNewInstance(entry, new_inst_klass); + auto [new_inst_klass, target_klass] = GetLoadClasses(if_block, &vshs); + HInstruction* new_inst = MakeNewInstance(if_block, new_inst_klass); new_inst->SetReferenceTypeInfo( ReferenceTypeInfo::Create(new_inst_klass->GetClass(), /*is_exact=*/true)); HInstanceOf* instance_of = new (GetAllocator()) HInstanceOf(new_inst, @@ -184,25 +171,19 @@ TEST_P(InstanceOfInstructionSimplifierTestGroup, ExactClassInstanceOfOther) { if (target_klass->GetLoadedClassRTI().IsValid()) { instance_of->SetValidTargetClassRTI(); } - entry->AddInstruction(instance_of); - HIf* if_inst = MakeIf(entry, instance_of); + if_block->AddInstruction(instance_of); + HIf* if_inst = MakeIf(if_block, instance_of); ManuallyBuildEnvFor(new_inst_klass, {}); if (new_inst_klass != target_klass) { target_klass->CopyEnvironmentFrom(new_inst_klass->GetEnvironment()); } new_inst->CopyEnvironmentFrom(new_inst_klass->GetEnvironment()); - MakeGoto(left); - - MakeGoto(right); - HInstruction* read_bottom = MakeIFieldGet(breturn, new_inst, DataType::Type::kInt32, MemberOffset(32)); MakeReturn(breturn, read_bottom); - MakeExit(exit); - - PerformSimplification(blks); + PerformSimplification(); if (!GetConstantResult() || GetParam() == InstanceOfKind::kSelf) { EXPECT_INS_RETAINED(target_klass); @@ -222,16 +203,10 @@ TEST_P(InstanceOfInstructionSimplifierTestGroup, ExactClassInstanceOfOther) { TEST_P(InstanceOfInstructionSimplifierTestGroup, ExactClassCheckCastOther) { ScopedObjectAccess soa(Thread::Current()); VariableSizedHandleScope vshs(soa.Self()); - InitGraph(/*handles=*/&vshs); - - AdjacencyListGraph blks(SetupFromAdjacencyList("entry", "exit", {{"entry", "exit"}})); -#define GET_BLOCK(name) HBasicBlock* name = blks.Get(#name) - GET_BLOCK(entry); - GET_BLOCK(exit); -#undef GET_BLOCK + HBasicBlock* main = InitEntryMainExitGraph(/*handles=*/&vshs); - auto [new_inst_klass, target_klass] = GetLoadClasses(entry, &vshs); - HInstruction* new_inst = MakeNewInstance(entry, new_inst_klass); + auto [new_inst_klass, target_klass] = GetLoadClasses(main, &vshs); + HInstruction* new_inst = MakeNewInstance(main, new_inst_klass); new_inst->SetReferenceTypeInfo( ReferenceTypeInfo::Create(new_inst_klass->GetClass(), /*is_exact=*/true)); HCheckCast* check_cast = new (GetAllocator()) HCheckCast(new_inst, @@ -245,17 +220,15 @@ TEST_P(InstanceOfInstructionSimplifierTestGroup, ExactClassCheckCastOther) { if (target_klass->GetLoadedClassRTI().IsValid()) { check_cast->SetValidTargetClassRTI(); } - entry->AddInstruction(check_cast); - MakeReturn(entry, new_inst); + main->AddInstruction(check_cast); + MakeReturn(main, new_inst); ManuallyBuildEnvFor(new_inst_klass, {}); if (new_inst_klass != target_klass) { target_klass->CopyEnvironmentFrom(new_inst_klass->GetEnvironment()); } new_inst->CopyEnvironmentFrom(new_inst_klass->GetEnvironment()); - MakeExit(exit); - - PerformSimplification(blks); + PerformSimplification(); if (!GetConstantResult() || GetParam() == InstanceOfKind::kSelf) { EXPECT_INS_RETAINED(target_klass); |