Optimizing: Run gtests without creating the Runtime.
The only Optimizing test that actually needs a Runtime is
the ReferenceTypePropagationTest, so we make it subclass
CommonCompilerTest explicitly and change OptimizingUnitTest
to subclass CommonArtTest for the other tests.
On host, each test that initializes the Runtime takes ~220ms
more than without initializing the Runtime. For example, the
ConstantFoldingTest that has 10 individual tests previously
took over 2.2s to run but without the Runtime initialization
it takes around 3-5ms. On target, running 32-bit gtests on
taimen with run-gtests.sh (single-threaded) goes from
~28m47s to ~26m13s, a reduction of ~9%.
Test: m test-art-host-gtest
Test: run-gtests.sh
Change-Id: I43e50ed58e52cc0ad04cdb4d39801bfbae840a3d
diff --git a/compiler/optimizing/codegen_test.cc b/compiler/optimizing/codegen_test.cc
index d9b4f79..f4f44a0 100644
--- a/compiler/optimizing/codegen_test.cc
+++ b/compiler/optimizing/codegen_test.cc
@@ -81,8 +81,9 @@
HGraph* graph = CreateCFG(data);
// Remove suspend checks, they cannot be executed in this context.
RemoveSuspendChecks(graph);
- OverrideInstructionSetFeatures(target_config.GetInstructionSet(), "default");
- RunCode(target_config, *compiler_options_, graph, [](HGraph*) {}, has_result, expected);
+ std::unique_ptr<CompilerOptions> compiler_options =
+ CommonCompilerTest::CreateCompilerOptions(target_config.GetInstructionSet(), "default");
+ RunCode(target_config, *compiler_options, graph, [](HGraph*) {}, has_result, expected);
}
}
@@ -93,8 +94,9 @@
HGraph* graph = CreateCFG(data, DataType::Type::kInt64);
// Remove suspend checks, they cannot be executed in this context.
RemoveSuspendChecks(graph);
- OverrideInstructionSetFeatures(target_config.GetInstructionSet(), "default");
- RunCode(target_config, *compiler_options_, graph, [](HGraph*) {}, has_result, expected);
+ std::unique_ptr<CompilerOptions> compiler_options =
+ CommonCompilerTest::CreateCompilerOptions(target_config.GetInstructionSet(), "default");
+ RunCode(target_config, *compiler_options, graph, [](HGraph*) {}, has_result, expected);
}
}
@@ -445,7 +447,9 @@
ASSERT_FALSE(equal->IsEmittedAtUseSite());
graph->BuildDominatorTree();
- PrepareForRegisterAllocation(graph, *compiler_options_).Run();
+ std::unique_ptr<CompilerOptions> compiler_options =
+ CommonCompilerTest::CreateCompilerOptions(target_config.GetInstructionSet(), "default");
+ PrepareForRegisterAllocation(graph, *compiler_options).Run();
ASSERT_TRUE(equal->IsEmittedAtUseSite());
auto hook_before_codegen = [](HGraph* graph_in) {
@@ -454,8 +458,7 @@
block->InsertInstructionBefore(move, block->GetLastInstruction());
};
- OverrideInstructionSetFeatures(target_config.GetInstructionSet(), "default");
- RunCode(target_config, *compiler_options_, graph, hook_before_codegen, true, 0);
+ RunCode(target_config, *compiler_options, graph, hook_before_codegen, true, 0);
}
}
@@ -501,8 +504,9 @@
new (graph_in->GetAllocator()) HParallelMove(graph_in->GetAllocator());
block->InsertInstructionBefore(move, block->GetLastInstruction());
};
- OverrideInstructionSetFeatures(target_config.GetInstructionSet(), "default");
- RunCode(target_config, *compiler_options_, graph, hook_before_codegen, true, lhs[i] < rhs[i]);
+ std::unique_ptr<CompilerOptions> compiler_options =
+ CommonCompilerTest::CreateCompilerOptions(target_config.GetInstructionSet(), "default");
+ RunCode(target_config, *compiler_options, graph, hook_before_codegen, true, lhs[i] < rhs[i]);
}
}
}
@@ -569,8 +573,9 @@
new (graph_in->GetAllocator()) HParallelMove(graph_in->GetAllocator());
block->InsertInstructionBefore(move, block->GetLastInstruction());
};
- OverrideInstructionSetFeatures(target_config.GetInstructionSet(), "default");
- RunCode(target_config, *compiler_options_, graph, hook_before_codegen, true, lhs[i] < rhs[i]);
+ std::unique_ptr<CompilerOptions> compiler_options =
+ CommonCompilerTest::CreateCompilerOptions(target_config.GetInstructionSet(), "default");
+ RunCode(target_config, *compiler_options, graph, hook_before_codegen, true, lhs[i] < rhs[i]);
}
}
}
@@ -679,8 +684,9 @@
block->AddInstruction(new (GetAllocator()) HReturn(comparison));
graph->BuildDominatorTree();
- OverrideInstructionSetFeatures(target_config.GetInstructionSet(), "default");
- RunCode(target_config, *compiler_options_, graph, [](HGraph*) {}, true, expected_result);
+ std::unique_ptr<CompilerOptions> compiler_options =
+ CommonCompilerTest::CreateCompilerOptions(target_config.GetInstructionSet(), "default");
+ RunCode(target_config, *compiler_options, graph, [](HGraph*) {}, true, expected_result);
}
TEST_F(CodegenTest, ComparisonsInt) {
@@ -711,9 +717,10 @@
#ifdef ART_ENABLE_CODEGEN_arm
TEST_F(CodegenTest, ARMVIXLParallelMoveResolver) {
- OverrideInstructionSetFeatures(InstructionSet::kThumb2, "default");
+ std::unique_ptr<CompilerOptions> compiler_options =
+ CommonCompilerTest::CreateCompilerOptions(InstructionSet::kThumb2, "default");
HGraph* graph = CreateGraph();
- arm::CodeGeneratorARMVIXL codegen(graph, *compiler_options_);
+ arm::CodeGeneratorARMVIXL codegen(graph, *compiler_options);
codegen.Initialize();
@@ -734,9 +741,10 @@
#ifdef ART_ENABLE_CODEGEN_arm64
// Regression test for b/34760542.
TEST_F(CodegenTest, ARM64ParallelMoveResolverB34760542) {
- OverrideInstructionSetFeatures(InstructionSet::kArm64, "default");
+ std::unique_ptr<CompilerOptions> compiler_options =
+ CommonCompilerTest::CreateCompilerOptions(InstructionSet::kArm64, "default");
HGraph* graph = CreateGraph();
- arm64::CodeGeneratorARM64 codegen(graph, *compiler_options_);
+ arm64::CodeGeneratorARM64 codegen(graph, *compiler_options);
codegen.Initialize();
@@ -783,9 +791,10 @@
// Check that ParallelMoveResolver works fine for ARM64 for both cases when SIMD is on and off.
TEST_F(CodegenTest, ARM64ParallelMoveResolverSIMD) {
- OverrideInstructionSetFeatures(InstructionSet::kArm64, "default");
+ std::unique_ptr<CompilerOptions> compiler_options =
+ CommonCompilerTest::CreateCompilerOptions(InstructionSet::kArm64, "default");
HGraph* graph = CreateGraph();
- arm64::CodeGeneratorARM64 codegen(graph, *compiler_options_);
+ arm64::CodeGeneratorARM64 codegen(graph, *compiler_options);
codegen.Initialize();
@@ -818,9 +827,10 @@
// Check that ART ISA Features are propagated to VIXL for arm64 (using cortex-a75 as example).
TEST_F(CodegenTest, ARM64IsaVIXLFeaturesA75) {
- OverrideInstructionSetFeatures(InstructionSet::kArm64, "cortex-a75");
+ std::unique_ptr<CompilerOptions> compiler_options =
+ CommonCompilerTest::CreateCompilerOptions(InstructionSet::kArm64, "cortex-a75");
HGraph* graph = CreateGraph();
- arm64::CodeGeneratorARM64 codegen(graph, *compiler_options_);
+ arm64::CodeGeneratorARM64 codegen(graph, *compiler_options);
vixl::CPUFeatures* features = codegen.GetVIXLAssembler()->GetCPUFeatures();
EXPECT_TRUE(features->Has(vixl::CPUFeatures::kCRC32));
@@ -832,9 +842,10 @@
// Check that ART ISA Features are propagated to VIXL for arm64 (using cortex-a53 as example).
TEST_F(CodegenTest, ARM64IsaVIXLFeaturesA53) {
- OverrideInstructionSetFeatures(InstructionSet::kArm64, "cortex-a53");
+ std::unique_ptr<CompilerOptions> compiler_options =
+ CommonCompilerTest::CreateCompilerOptions(InstructionSet::kArm64, "cortex-a53");
HGraph* graph = CreateGraph();
- arm64::CodeGeneratorARM64 codegen(graph, *compiler_options_);
+ arm64::CodeGeneratorARM64 codegen(graph, *compiler_options);
vixl::CPUFeatures* features = codegen.GetVIXLAssembler()->GetCPUFeatures();
EXPECT_TRUE(features->Has(vixl::CPUFeatures::kCRC32));
@@ -850,9 +861,10 @@
// allocated on stack per callee-saved FP register to be preserved in the frame entry as
// ABI states.
TEST_F(CodegenTest, ARM64FrameSizeSIMD) {
- OverrideInstructionSetFeatures(InstructionSet::kArm64, "default");
+ std::unique_ptr<CompilerOptions> compiler_options =
+ CommonCompilerTest::CreateCompilerOptions(InstructionSet::kArm64, "default");
HGraph* graph = CreateGraph();
- arm64::CodeGeneratorARM64 codegen(graph, *compiler_options_);
+ arm64::CodeGeneratorARM64 codegen(graph, *compiler_options);
codegen.Initialize();
graph->SetHasSIMD(true);
@@ -869,9 +881,10 @@
}
TEST_F(CodegenTest, ARM64FrameSizeNoSIMD) {
- OverrideInstructionSetFeatures(InstructionSet::kArm64, "default");
+ std::unique_ptr<CompilerOptions> compiler_options =
+ CommonCompilerTest::CreateCompilerOptions(InstructionSet::kArm64, "default");
HGraph* graph = CreateGraph();
- arm64::CodeGeneratorARM64 codegen(graph, *compiler_options_);
+ arm64::CodeGeneratorARM64 codegen(graph, *compiler_options);
codegen.Initialize();
graph->SetHasSIMD(false);