Fix initializing the allocator before creating empty vector.

MSVC's implementation of the STL allocates memory even for an empty
vector. Since we're using a custom thread-local allocator, it should
be initialized before any STL member containers get initialized.

BUG=swiftshader:7

Change-Id: I4bd977e7ee8eb87006fe08b051cbcfc9bc62342b
Reviewed-on: https://chromium-review.googlesource.com/381531
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Jim Stichnoth <stichnot@chromium.org>
diff --git a/src/IceMemory.cpp b/src/IceMemory.cpp
index 57c969e..0026661 100644
--- a/src/IceMemory.cpp
+++ b/src/IceMemory.cpp
@@ -31,9 +31,17 @@
 void CfgAllocatorTraits::set_current(const manager_type *Manager) {
   ArenaAllocator *Allocator =
       Manager == nullptr ? nullptr : Manager->Allocator.get();
+  set_current(Allocator);
+}
+
+void CfgAllocatorTraits::set_current(ArenaAllocator *Allocator) {
   ICE_TLS_SET_FIELD(CfgAllocator, Allocator);
 }
 
+void CfgAllocatorTraits::set_current(nullptr_t) {
+  ICE_TLS_SET_FIELD(CfgAllocator, nullptr);
+}
+
 ICE_TLS_DEFINE_FIELD(ArenaAllocator *, LivenessAllocatorTraits,
                      LivenessAllocator);