[ORC] Update JITCompileCallbackManager to support multi-threaded code.

Previously JITCompileCallbackManager only supported single threaded code. This
patch embeds a VSO (see include/llvm/ExecutionEngine/Orc/Core.h) in the callback
manager. The VSO ensures that the compile callback is only executed once and that
the resulting address cached for use by subsequent re-entries.

llvm-svn: 333490
diff --git a/llvm/unittests/ExecutionEngine/Orc/CompileOnDemandLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/CompileOnDemandLayerTest.cpp
index 833b762..0d2a712 100644
--- a/llvm/unittests/ExecutionEngine/Orc/CompileOnDemandLayerTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/CompileOnDemandLayerTest.cpp
@@ -18,7 +18,8 @@
 
 class DummyCallbackManager : public orc::JITCompileCallbackManager {
 public:
-  DummyCallbackManager() : JITCompileCallbackManager(0) {}
+  DummyCallbackManager(ExecutionSession &ES)
+      : JITCompileCallbackManager(ES, 0) {}
 
 public:
   Error grow() override { llvm_unreachable("not implemented"); }
@@ -57,9 +58,9 @@
       return JITSymbol(nullptr);
     };
 
-  DummyCallbackManager CallbackMgr;
 
   ExecutionSession ES(std::make_shared<SymbolStringPool>());
+  DummyCallbackManager CallbackMgr(ES);
 
   auto GetResolver =
       [](orc::VModuleKey) -> std::shared_ptr<llvm::orc::SymbolResolver> {
diff --git a/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h b/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h
index 6b2743b..c4424e0 100644
--- a/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h
+++ b/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h
@@ -71,11 +71,12 @@
       // Use ability to create callback manager to detect whether Orc
       // has indirection support on this platform. This way the test
       // and Orc code do not get out of sync.
-      SupportsIndirection = !!orc::createLocalCompileCallbackManager(TT, 0);
+      SupportsIndirection = !!orc::createLocalCompileCallbackManager(TT, ES, 0);
     }
   };
 
 protected:
+  orc::ExecutionSession ES;
   LLVMContext Context;
   std::unique_ptr<TargetMachine> TM;
   bool SupportsJIT = false;