[ORC] Re-apply r327566 with a fix for test-global-ctors.ll.

Also clang-formats the patch, which I should have done the first time around.

llvm-svn: 327594
diff --git a/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp b/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp
index ca445b4..f053407 100644
--- a/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp
@@ -73,9 +73,8 @@
     CompileContext *CCtx = static_cast<CompileContext*>(Ctx);
     auto *ET = CCtx->APIExecTest;
     CCtx->M = ET->createTestModule(ET->TM->getTargetTriple());
-    LLVMSharedModuleRef SM = LLVMOrcMakeSharedModule(wrap(CCtx->M.release()));
-    LLVMOrcAddEagerlyCompiledIR(JITStack, &CCtx->H, SM, myResolver, nullptr);
-    LLVMOrcDisposeSharedModuleRef(SM);
+    LLVMOrcAddEagerlyCompiledIR(JITStack, &CCtx->H, wrap(CCtx->M.release()),
+                                myResolver, nullptr);
     CCtx->Compiled = true;
     LLVMOrcTargetAddress MainAddr;
     LLVMOrcGetSymbolAddress(JITStack, &MainAddr, "main");
@@ -97,10 +96,8 @@
 
   LLVMOrcGetMangledSymbol(JIT, &testFuncName, "testFunc");
 
-  LLVMSharedModuleRef SM = LLVMOrcMakeSharedModule(wrap(M.release()));
   LLVMOrcModuleHandle H;
-  LLVMOrcAddEagerlyCompiledIR(JIT, &H, SM, myResolver, nullptr);
-  LLVMOrcDisposeSharedModuleRef(SM);
+  LLVMOrcAddEagerlyCompiledIR(JIT, &H, wrap(M.release()), myResolver, nullptr);
   LLVMOrcTargetAddress MainAddr;
   LLVMOrcGetSymbolAddress(JIT, &MainAddr, "main");
   MainFnTy MainFn = (MainFnTy)MainAddr;
@@ -125,10 +122,8 @@
 
   LLVMOrcGetMangledSymbol(JIT, &testFuncName, "testFunc");
 
-  LLVMSharedModuleRef SM = LLVMOrcMakeSharedModule(wrap(M.release()));
   LLVMOrcModuleHandle H;
-  LLVMOrcAddLazilyCompiledIR(JIT, &H, SM, myResolver, nullptr);
-  LLVMOrcDisposeSharedModuleRef(SM);
+  LLVMOrcAddLazilyCompiledIR(JIT, &H, wrap(M.release()), myResolver, nullptr);
   LLVMOrcTargetAddress MainAddr;
   LLVMOrcGetSymbolAddress(JIT, &MainAddr, "main");
   MainFnTy MainFn = (MainFnTy)MainAddr;