Fix misuse of ArenaAllocator.

Allocator must survive its allocations (the pool is not enough).
Spotted by valgrind.

Change-Id: I7104a93e625995f1205710e6d07904b3d315e412
diff --git a/compiler/optimizing/find_loops_test.cc b/compiler/optimizing/find_loops_test.cc
index fab9f7a..c36b143 100644
--- a/compiler/optimizing/find_loops_test.cc
+++ b/compiler/optimizing/find_loops_test.cc
@@ -27,9 +27,8 @@
 
 namespace art {
 
-static HGraph* TestCode(const uint16_t* data, ArenaPool* pool) {
-  ArenaAllocator allocator(pool);
-  HGraphBuilder builder(&allocator);
+static HGraph* TestCode(const uint16_t* data, ArenaAllocator* allocator) {
+  HGraphBuilder builder(allocator);
   const DexFile::CodeItem* item = reinterpret_cast<const DexFile::CodeItem*>(data);
   HGraph* graph = builder.BuildGraph(*item);
   graph->BuildDominatorTree();
@@ -44,7 +43,8 @@
     Instruction::RETURN_VOID);
 
   ArenaPool arena;
-  HGraph* graph = TestCode(data, &arena);
+  ArenaAllocator allocator(&arena);
+  HGraph* graph = TestCode(data, &allocator);
   for (size_t i = 0, e = graph->GetBlocks().Size(); i < e; ++i) {
     ASSERT_EQ(graph->GetBlocks().Get(i)->GetLoopInformation(), nullptr);
   }
@@ -56,7 +56,8 @@
     Instruction::RETURN);
 
   ArenaPool arena;
-  HGraph* graph = TestCode(data, &arena);
+  ArenaAllocator allocator(&arena);
+  HGraph* graph = TestCode(data, &allocator);
   for (size_t i = 0, e = graph->GetBlocks().Size(); i < e; ++i) {
     ASSERT_EQ(graph->GetBlocks().Get(i)->GetLoopInformation(), nullptr);
   }
@@ -71,7 +72,8 @@
     Instruction::RETURN);
 
   ArenaPool arena;
-  HGraph* graph = TestCode(data, &arena);
+  ArenaAllocator allocator(&arena);
+  HGraph* graph = TestCode(data, &allocator);
   for (size_t i = 0, e = graph->GetBlocks().Size(); i < e; ++i) {
     ASSERT_EQ(graph->GetBlocks().Get(i)->GetLoopInformation(), nullptr);
   }
@@ -87,7 +89,8 @@
     Instruction::RETURN | 0 << 8);
 
   ArenaPool arena;
-  HGraph* graph = TestCode(data, &arena);
+  ArenaAllocator allocator(&arena);
+  HGraph* graph = TestCode(data, &allocator);
   for (size_t i = 0, e = graph->GetBlocks().Size(); i < e; ++i) {
     ASSERT_EQ(graph->GetBlocks().Get(i)->GetLoopInformation(), nullptr);
   }
@@ -101,7 +104,8 @@
     Instruction::RETURN | 0 << 8);
 
   ArenaPool arena;
-  HGraph* graph = TestCode(data, &arena);
+  ArenaAllocator allocator(&arena);
+  HGraph* graph = TestCode(data, &allocator);
   for (size_t i = 0, e = graph->GetBlocks().Size(); i < e; ++i) {
     ASSERT_EQ(graph->GetBlocks().Get(i)->GetLoopInformation(), nullptr);
   }
@@ -146,7 +150,8 @@
     Instruction::RETURN_VOID);
 
   ArenaPool arena;
-  HGraph* graph = TestCode(data, &arena);
+  ArenaAllocator allocator(&arena);
+  HGraph* graph = TestCode(data, &allocator);
 
   TestBlock(graph, 0, false, -1);            // entry block
   TestBlock(graph, 1, false, -1);            // pre header
@@ -173,7 +178,8 @@
     Instruction::RETURN | 0 << 8);
 
   ArenaPool arena;
-  HGraph* graph = TestCode(data, &arena);
+  ArenaAllocator allocator(&arena);
+  HGraph* graph = TestCode(data, &allocator);
 
   TestBlock(graph, 0, false, -1);            // entry block
   TestBlock(graph, 1, false, -1);            // goto block
@@ -197,7 +203,8 @@
     Instruction::RETURN | 0 << 8);
 
   ArenaPool arena;
-  HGraph* graph = TestCode(data, &arena);
+  ArenaAllocator allocator(&arena);
+  HGraph* graph = TestCode(data, &allocator);
 
   TestBlock(graph, 0, false, -1);            // entry block
   TestBlock(graph, 1, false, -1);            // goto block
@@ -222,7 +229,8 @@
     Instruction::RETURN | 0 << 8);
 
   ArenaPool arena;
-  HGraph* graph = TestCode(data, &arena);
+  ArenaAllocator allocator(&arena);
+  HGraph* graph = TestCode(data, &allocator);
 
   TestBlock(graph, 0, false, -1);            // entry block
   TestBlock(graph, 1, false, -1);            // pre header
@@ -248,7 +256,8 @@
     Instruction::RETURN | 0 << 8);
 
   ArenaPool arena;
-  HGraph* graph = TestCode(data, &arena);
+  ArenaAllocator allocator(&arena);
+  HGraph* graph = TestCode(data, &allocator);
 
   TestBlock(graph, 0, false, -1);            // entry block
   TestBlock(graph, 1, false, -1);            // pre header
@@ -271,9 +280,9 @@
     Instruction::GOTO | 0xFB00,
     Instruction::RETURN | 0 << 8);
 
-
   ArenaPool arena;
-  HGraph* graph = TestCode(data, &arena);
+  ArenaAllocator allocator(&arena);
+  HGraph* graph = TestCode(data, &allocator);
 
   TestBlock(graph, 0, false, -1);            // entry block
   TestBlock(graph, 1, false, -1);            // pre header of outer loop
@@ -302,9 +311,9 @@
     Instruction::GOTO | 0xFE00,  // second loop
     Instruction::RETURN | 0 << 8);
 
-
   ArenaPool arena;
-  HGraph* graph = TestCode(data, &arena);
+  ArenaAllocator allocator(&arena);
+  HGraph* graph = TestCode(data, &allocator);
 
   TestBlock(graph, 0, false, -1);            // entry block
   TestBlock(graph, 1, false, -1);            // pre header of first loop
@@ -333,7 +342,8 @@
     Instruction::RETURN | 0 << 8);
 
   ArenaPool arena;
-  HGraph* graph = TestCode(data, &arena);
+  ArenaAllocator allocator(&arena);
+  HGraph* graph = TestCode(data, &allocator);
   ASSERT_TRUE(graph->GetBlocks().Get(3)->IsLoopHeader());
   HLoopInformation* info = graph->GetBlocks().Get(3)->GetLoopInformation();
   ASSERT_FALSE(info->GetHeader()->Dominates(info->GetBackEdges().Get(0)));
@@ -347,7 +357,8 @@
     Instruction::RETURN | 0 << 8);
 
   ArenaPool arena;
-  HGraph* graph = TestCode(data, &arena);
+  ArenaAllocator allocator(&arena);
+  HGraph* graph = TestCode(data, &allocator);
 
   TestBlock(graph, 0, false, -1);            // entry block
   TestBlock(graph, 1, false, -1);            // pre header of first loop