Fix memory corruption due to premature llvm_shutdown().
Under LLVM, multiple compiler-related gtests randomly crashes from time
to time, because common_test.h has code to new multiple compiler
instances. Multiple CompilerLLVM instances may cause crash if one
shuts down LLVM prematurely.
This fix uses static class member. Destructor is where we shut
down LLVM.
Change-Id: Ied371794af7ca9eb2c9fe6b278fd779a61a4a753
diff --git a/src/compiler_llvm/compiler_llvm.h b/src/compiler_llvm/compiler_llvm.h
index 7481c8c..6332fb3 100644
--- a/src/compiler_llvm/compiler_llvm.h
+++ b/src/compiler_llvm/compiler_llvm.h
@@ -107,6 +107,13 @@
std::string bitcode_filename_;
+ class LLVMInitializer {
+ public:
+ LLVMInitializer();
+ ~LLVMInitializer();
+ };
+ static LLVMInitializer llvm_initialize_guard;
+
DISALLOW_COPY_AND_ASSIGN(CompilerLLVM);
};