ART: Use ScopedArenaAllocator for pass-local data.

Passes using local ArenaAllocator were hiding their memory
usage from the allocation counting, making it difficult to
track down where memory was used. Using ScopedArenaAllocator
reveals the memory usage.

This changes the HGraph constructor which requires a lot of
changes in tests. Refactor these tests to limit the amount
of work needed the next time we change that constructor.

Test: m test-art-host-gtest
Test: testrunner.py --host
Test: Build with kArenaAllocatorCountAllocations = true.
Bug: 64312607
Change-Id: I34939e4086b500d6e827ff3ef2211d1a421ac91a
diff --git a/compiler/optimizing/linear_order.h b/compiler/optimizing/linear_order.h
index 7122d67..151db00 100644
--- a/compiler/optimizing/linear_order.h
+++ b/compiler/optimizing/linear_order.h
@@ -17,10 +17,14 @@
 #ifndef ART_COMPILER_OPTIMIZING_LINEAR_ORDER_H_
 #define ART_COMPILER_OPTIMIZING_LINEAR_ORDER_H_
 
+#include <type_traits>
+
 #include "nodes.h"
 
 namespace art {
 
+void LinearizeGraphInternal(const HGraph* graph, ArrayRef<HBasicBlock*> linear_order);
+
 // Linearizes the 'graph' such that:
 // (1): a block is always after its dominator,
 // (2): blocks of loops are contiguous.
@@ -32,9 +36,15 @@
 //
 // for (HBasicBlock* block : ReverseRange(linear_order))     // linear post order
 //
-void LinearizeGraph(const HGraph* graph,
-                    ArenaAllocator* allocator,
-                    ArenaVector<HBasicBlock*>* linear_order);
+template <typename Vector>
+void LinearizeGraph(const HGraph* graph, Vector* linear_order) {
+  static_assert(std::is_same<HBasicBlock*, typename Vector::value_type>::value,
+                "Vector::value_type must be HBasicBlock*.");
+  // Resize the vector and pass an ArrayRef<> to internal implementation which is shared
+  // for all kinds of vectors, i.e. ArenaVector<> or ScopedArenaVector<>.
+  linear_order->resize(graph->GetReversePostOrder().size());
+  LinearizeGraphInternal(graph, ArrayRef<HBasicBlock*>(*linear_order));
+}
 
 }  // namespace art