Clean up LSE gtests.
Unify graph logging and put verbose logging under
a compile-time flag. Silence the logging by default.
Test: m test-art-host-gtest
Change-Id: Ifd02b88fd8bbef69fd835c84af817d66d074ce7b
diff --git a/compiler/optimizing/load_store_elimination_test.cc b/compiler/optimizing/load_store_elimination_test.cc
index a7a97f6..f0c2541 100644
--- a/compiler/optimizing/load_store_elimination_test.cc
+++ b/compiler/optimizing/load_store_elimination_test.cc
@@ -38,6 +38,8 @@
namespace art HIDDEN {
+static constexpr bool kDebugLseTests = false;
+
#define CHECK_SUBROUTINE_FAILURE() \
do { \
if (HasFatalFailure()) { \
@@ -54,12 +56,16 @@
void SetUp() override {
SuperTest::SetUp();
- gLogVerbosity.compiler = true;
+ if (kDebugLseTests) {
+ gLogVerbosity.compiler = true;
+ }
}
void TearDown() override {
SuperTest::TearDown();
- gLogVerbosity.compiler = false;
+ if (kDebugLseTests) {
+ gLogVerbosity.compiler = false;
+ }
}
void PerformLSE(bool with_partial = true) {
@@ -70,12 +76,37 @@
EXPECT_TRUE(CheckGraphSkipRefTypeInfoChecks(oss)) << oss.str();
}
- void PerformLSEWithPartial() {
- PerformLSE(true);
+ void PerformLSEWithPartial(const AdjacencyListGraph& blks) {
+ // PerformLSE expects this to be empty.
+ graph_->ClearDominanceInformation();
+ if (kDebugLseTests) {
+ LOG(INFO) << "Pre LSE " << blks;
+ }
+ PerformLSE(/*with_partial=*/ true);
+ if (kDebugLseTests) {
+ LOG(INFO) << "Post LSE " << blks;
+ }
}
- void PerformLSENoPartial() {
- PerformLSE(false);
+ void PerformLSENoPartial(const AdjacencyListGraph& blks) {
+ // PerformLSE expects this to be empty.
+ graph_->ClearDominanceInformation();
+ if (kDebugLseTests) {
+ LOG(INFO) << "Pre LSE " << blks;
+ }
+ PerformLSE(/*with_partial=*/ false);
+ if (kDebugLseTests) {
+ LOG(INFO) << "Post LSE " << blks;
+ }
+ }
+
+ void PerformSimplifications(const AdjacencyListGraph& blks) {
+ InstructionSimplifier simp(graph_, /*codegen=*/nullptr);
+ simp.Run();
+
+ if (kDebugLseTests) {
+ LOG(INFO) << "Post simplification " << blks;
+ }
}
// Create instructions shared among tests.
@@ -2038,10 +2069,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSENoPartial();
+ PerformLSENoPartial(blks);
EXPECT_INS_RETAINED(read_bottom);
EXPECT_INS_RETAINED(write_c1);
@@ -2188,9 +2216,8 @@
HInstruction* return_exit = new (GetAllocator()) HReturn(read_bottom);
exit->AddInstruction(read_bottom);
exit->AddInstruction(return_exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- PerformLSENoPartial();
+
+ PerformLSENoPartial(blks);
EXPECT_INS_RETAINED(read_bottom) << *read_bottom;
EXPECT_INS_RETAINED(write_right) << *write_right;
@@ -2280,9 +2307,8 @@
HInstruction* return_exit = new (GetAllocator()) HReturn(read_bottom);
exit->AddInstruction(read_bottom);
exit->AddInstruction(return_exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- PerformLSENoPartial();
+
+ PerformLSENoPartial(blks);
EXPECT_INS_RETAINED(read_bottom);
EXPECT_INS_RETAINED(write_right_first);
@@ -2513,11 +2539,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
HPredicatedInstanceFieldGet* pred_get =
FindSingleInstruction<HPredicatedInstanceFieldGet>(graph_);
@@ -2670,11 +2692,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
EXPECT_INS_RETAINED(call_left_left);
EXPECT_INS_REMOVED(read1);
@@ -2828,11 +2846,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
HNewInstance* moved_new_inst1;
HInstanceFieldSet* moved_set1;
@@ -2968,11 +2982,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
EXPECT_INS_REMOVED(write_entry1);
EXPECT_INS_REMOVED(write_entry2);
@@ -3129,11 +3139,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
EXPECT_INS_REMOVED(new_inst1);
EXPECT_INS_REMOVED(new_inst2);
@@ -3219,11 +3225,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
HNewInstance* moved_new_inst = nullptr;
HInstanceFieldSet* moved_set = nullptr;
@@ -3334,11 +3336,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
HNewInstance* moved_new_inst = nullptr;
HInstanceFieldSet* moved_set = nullptr;
@@ -3511,11 +3509,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
HNewInstance* moved_new_inst = nullptr;
HInstanceFieldSet* moved_set = nullptr;
@@ -3653,11 +3647,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
HNewInstance* moved_new_inst;
HInstanceFieldSet* moved_set;
@@ -3760,11 +3750,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
// Each escaping switch path gets its own materialization block.
// Blocks:
@@ -3891,11 +3877,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
EXPECT_INS_REMOVED(read_early);
EXPECT_EQ(return_early->InputAt(0), c0);
@@ -4027,11 +4009,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
// Normal LSE can get rid of these two.
EXPECT_INS_REMOVED(store_one);
@@ -4518,9 +4496,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- PerformLSENoPartial();
+ PerformLSENoPartial(blks);
EXPECT_INS_RETAINED(write_left_pre) << *write_left_pre;
EXPECT_INS_RETAINED(read_return) << *read_return;
@@ -4626,9 +4602,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- PerformLSENoPartial();
+ PerformLSENoPartial(blks);
EXPECT_INS_RETAINED(read_return);
EXPECT_INS_RETAINED(write_right);
@@ -4714,9 +4688,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- PerformLSENoPartial();
+ PerformLSENoPartial(blks);
EXPECT_INS_RETAINED(read_bottom);
EXPECT_INS_RETAINED(write_right);
@@ -4799,12 +4771,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
-
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSENoPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSENoPartial(blks);
EXPECT_INS_REMOVED(read_bottom);
EXPECT_INS_REMOVED(write_right);
@@ -4912,12 +4879,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
-
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
std::vector<HPhi*> merges;
HPredicatedInstanceFieldGet* pred_get;
@@ -5041,11 +5003,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
std::vector<HPhi*> merges;
HInstanceFieldSet* init_set =
@@ -5172,11 +5130,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
std::vector<HPhi*> merges;
HInstanceFieldSet* init_set =
@@ -5305,12 +5259,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
-
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
std::vector<HPhi*> merges;
std::vector<HInstanceFieldSet*> sets;
@@ -5439,12 +5388,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
-
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
EXPECT_INS_RETAINED(write_bottom);
EXPECT_TRUE(write_bottom->AsInstanceFieldSet()->GetIsPredicatedSet());
@@ -5554,11 +5498,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
EXPECT_INS_RETAINED(write_bottom);
EXPECT_TRUE(write_bottom->AsInstanceFieldSet()->GetIsPredicatedSet()) << *write_bottom;
@@ -5642,11 +5582,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
EXPECT_INS_REMOVED(read_bottom);
EXPECT_INS_REMOVED(write_right);
@@ -5763,11 +5699,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
EXPECT_INS_REMOVED(read_bottom1);
EXPECT_INS_REMOVED(read_bottom2);
@@ -5916,11 +5848,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
EXPECT_INS_REMOVED(read_bottom1);
EXPECT_INS_REMOVED(read_bottom2);
@@ -6093,11 +6021,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
EXPECT_INS_REMOVED(early_exit_left_read);
EXPECT_INS_REMOVED(early_exit_right_read);
@@ -6227,11 +6151,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
EXPECT_INS_REMOVED(read_bottom);
EXPECT_INS_REMOVED(read_right);
@@ -6349,11 +6269,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
EXPECT_INS_REMOVED(read_bottom);
EXPECT_INS_REMOVED(read_early_return);
@@ -6462,11 +6378,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
EXPECT_INS_REMOVED(read_bottom);
EXPECT_INS_REMOVED(write_right);
@@ -6600,11 +6512,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
EXPECT_INS_REMOVED(read_bottom);
EXPECT_INS_REMOVED(write_right);
@@ -6703,11 +6611,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
EXPECT_INS_REMOVED(read_bottom);
EXPECT_INS_RETAINED(write_left);
@@ -6876,11 +6780,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
HPredicatedInstanceFieldGet* pred_get =
FindSingleInstruction<HPredicatedInstanceFieldGet>(graph_, breturn);
@@ -7060,11 +6960,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
HPredicatedInstanceFieldGet* pred_get =
FindSingleInstruction<HPredicatedInstanceFieldGet>(graph_, breturn);
@@ -7211,11 +7107,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
HPredicatedInstanceFieldGet* pred_get =
FindSingleInstruction<HPredicatedInstanceFieldGet>(graph_, breturn);
@@ -7359,11 +7251,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
HPredicatedInstanceFieldGet* pred_get =
FindSingleInstruction<HPredicatedInstanceFieldGet>(graph_, breturn);
@@ -7507,11 +7395,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
HPredicatedInstanceFieldGet* pred_get =
FindSingleInstruction<HPredicatedInstanceFieldGet>(graph_, breturn);
@@ -7672,11 +7556,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSEWithPartial();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
HPredicatedInstanceFieldGet* pred_get =
FindSingleInstruction<HPredicatedInstanceFieldGet>(graph_, breturn);
@@ -7772,17 +7652,10 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSE();
+ PerformLSEWithPartial(blks);
// Run the code-simplifier too
- LOG(INFO) << "Pre simplification " << blks;
- InstructionSimplifier simp(graph_, /*codegen=*/nullptr);
- simp.Run();
-
- LOG(INFO) << "Post LSE " << blks;
+ PerformSimplifications(blks);
EXPECT_INS_REMOVED(write_right);
EXPECT_INS_REMOVED(write_start);
@@ -7866,17 +7739,10 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSE();
+ PerformLSEWithPartial(blks);
// Run the code-simplifier too
- LOG(INFO) << "Pre simplification " << blks;
- InstructionSimplifier simp(graph_, /*codegen=*/nullptr);
- simp.Run();
-
- LOG(INFO) << "Post LSE " << blks;
+ PerformSimplifications(blks);
EXPECT_INS_REMOVED(write_right);
EXPECT_INS_REMOVED(write_start);
@@ -7976,17 +7842,10 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSE();
+ PerformLSEWithPartial(blks);
// Run the code-simplifier too
- LOG(INFO) << "Pre simplification " << blks;
- InstructionSimplifier simp(graph_, /*codegen=*/nullptr);
- simp.Run();
-
- LOG(INFO) << "Post LSE " << blks;
+ PerformSimplifications(blks);
EXPECT_INS_REMOVED(write_case2);
EXPECT_INS_REMOVED(write_case3);
@@ -8084,17 +7943,10 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSE();
+ PerformLSEWithPartial(blks);
// Run the code-simplifier too
- LOG(INFO) << "Pre simplification " << blks;
- InstructionSimplifier simp(graph_, /*codegen=*/nullptr);
- simp.Run();
-
- LOG(INFO) << "Post LSE " << blks;
+ PerformSimplifications(blks);
EXPECT_INS_REMOVED(write_case2);
EXPECT_INS_REMOVED(write_case3);
@@ -8240,11 +8092,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSE();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
EXPECT_TRUE(loop_header->IsLoopHeader());
EXPECT_TRUE(loop_header->GetLoopInformation()->IsIrreducible());
@@ -8397,11 +8245,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSE();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
EXPECT_INS_RETAINED(cls);
EXPECT_INS_REMOVED(new_inst);
@@ -8559,11 +8403,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSE();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
EXPECT_INS_RETAINED(cls);
EXPECT_INS_REMOVED(new_inst);
@@ -8767,11 +8607,7 @@
SetupExit(exit);
- // PerformLSE expects this to be empty.
- graph_->ClearDominanceInformation();
- LOG(INFO) << "Pre LSE " << blks;
- PerformLSE();
- LOG(INFO) << "Post LSE " << blks;
+ PerformLSEWithPartial(blks);
EXPECT_INS_RETAINED(cls);
EXPECT_INS_REMOVED(new_inst);