diff options
| author | 2012-03-07 08:51:44 -0800 | |
|---|---|---|
| committer | 2012-03-07 09:18:56 -0800 | |
| commit | fc34adb0c40e336c4d0582698fd6d4bf3b3de5e1 (patch) | |
| tree | 7ad6793be3c7c90c0e698fa77814e4edd05389a3 /src/compiler_llvm/compiler_llvm.cc | |
| parent | 720fc19a1602ca1ee06cd7936979c2c30422a739 (diff) | |
Use llvm_shutdown_obj to fix "static initialization order fiasco."
Yesterday we added a static guard, which is removed from this commit.
Using llvm_shutdown_obj will avoid the ordering problem.
Change-Id: Iaa2e4293373c849f6b07082fb70b49ff0e805033
Diffstat (limited to 'src/compiler_llvm/compiler_llvm.cc')
| -rw-r--r-- | src/compiler_llvm/compiler_llvm.cc | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/compiler_llvm/compiler_llvm.cc b/src/compiler_llvm/compiler_llvm.cc index 6646b196ca..67b3f4d50c 100644 --- a/src/compiler_llvm/compiler_llvm.cc +++ b/src/compiler_llvm/compiler_llvm.cc @@ -41,10 +41,11 @@ extern llvm::cl::opt<bool> EnableARMLongCalls; // ARMISelLowering.cpp, however, it is not in the llvm namespace. -namespace art { -namespace compiler_llvm { +namespace { + +pthread_once_t llvm_initialized = PTHREAD_ONCE_INIT; -CompilerLLVM::LLVMInitializer::LLVMInitializer() { +void InitializeLLVM() { // NOTE: Uncomment following line to show the time consumption of LLVM passes //llvm::TimePassesIsEnabled = true; @@ -75,13 +76,15 @@ CompilerLLVM::LLVMInitializer::LLVMInitializer() { llvm::llvm_start_multithreaded(); } -CompilerLLVM::LLVMInitializer::~LLVMInitializer() { - llvm::llvm_shutdown(); -} - // Singleton. Otherwise, multiple CompilerLLVM instances may cause crashes if // one shuts down prematurely. -CompilerLLVM::LLVMInitializer CompilerLLVM::llvm_initialize_guard; +llvm::llvm_shutdown_obj llvm_guard; + +} // anonymous namespace + + +namespace art { +namespace compiler_llvm { llvm::Module* makeLLVMModuleContents(llvm::Module* module); @@ -90,6 +93,10 @@ llvm::Module* makeLLVMModuleContents(llvm::Module* module); CompilerLLVM::CompilerLLVM(Compiler* compiler, InstructionSet insn_set) : compiler_(compiler), compiler_lock_("llvm_compiler_lock"), insn_set_(insn_set), curr_cunit_(NULL) { + + + // Initialize LLVM libraries + pthread_once(&llvm_initialized, InitializeLLVM); } |