Remove TypeBuilder.h, and fix the few locations using it.

This shortcut mechanism for creating types was added 10 years ago, but
has seen almost no uptake since then, neither internally nor in
external projects.

The very small number of characters saved by using it does not seem
worth the mental overhead of an additional type-creation API, so,
delete it.

Differential Revision: https://reviews.llvm.org/D56573

llvm-svn: 351020
diff --git a/llvm/unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp b/llvm/unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp
index 1226bba..856ae45 100644
--- a/llvm/unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp
+++ b/llvm/unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp
@@ -175,7 +175,7 @@
   std::unique_ptr<Module> A, B;
   Function *FA1, *FA2, *FB;
   createTwoModuleExternCase(A, FA1, B, FB);
-  FA2 = insertSimpleCallFunction<int32_t(int32_t, int32_t)>(A.get(), FA1);
+  FA2 = insertSimpleCallFunction(A.get(), FA1);
 
   createJIT(std::move(A));
   TheJIT->addModule(std::move(B));
@@ -203,15 +203,18 @@
   std::unique_ptr<Module> A, B;
   Function *FA, *FB;
   GlobalVariable *GVA, *GVB, *GVC;
+
   A.reset(createEmptyModule("A"));
   B.reset(createEmptyModule("B"));
 
   int32_t initialNum = 7;
   GVA = insertGlobalInt32(A.get(), "GVA", initialNum);
   GVB = insertGlobalInt32(B.get(), "GVB", initialNum);
-  FA = startFunction<int32_t(void)>(A.get(), "FA");
+  FA = startFunction(A.get(),
+                     FunctionType::get(Builder.getInt32Ty(), {}, false), "FA");
   endFunctionWithRet(FA, Builder.CreateLoad(GVA));
-  FB = startFunction<int32_t(void)>(B.get(), "FB");
+  FB = startFunction(B.get(),
+                     FunctionType::get(Builder.getInt32Ty(), {}, false), "FB");
   endFunctionWithRet(FB, Builder.CreateLoad(GVB));
 
   GVC = insertGlobalInt32(B.get(), "GVC", initialNum);
diff --git a/llvm/unittests/ExecutionEngine/MCJIT/MCJITTest.cpp b/llvm/unittests/ExecutionEngine/MCJIT/MCJITTest.cpp
index e7da75a..8972fb6 100644
--- a/llvm/unittests/ExecutionEngine/MCJIT/MCJITTest.cpp
+++ b/llvm/unittests/ExecutionEngine/MCJIT/MCJITTest.cpp
@@ -99,8 +99,9 @@
   int32_t initialNum = 7;
   GlobalVariable *GV = insertGlobalInt32(M.get(), "myglob", initialNum);
 
-  Function *ReturnGlobal = startFunction<int32_t(void)>(M.get(),
-                                                        "ReturnGlobal");
+  Function *ReturnGlobal =
+      startFunction(M.get(), FunctionType::get(Builder.getInt32Ty(), {}, false),
+                    "ReturnGlobal");
   Value *ReadGlobal = Builder.CreateLoad(GV);
   endFunctionWithRet(ReturnGlobal, ReadGlobal);
 
@@ -126,7 +127,10 @@
   SKIP_UNSUPPORTED_PLATFORM;
 
   int32_t initialNum = 5;
-  Function *IncrementGlobal = startFunction<int32_t(void)>(M.get(), "IncrementGlobal");
+  Function *IncrementGlobal = startFunction(
+      M.get(),
+      FunctionType::get(Builder.getInt32Ty(), {}, false),
+      "IncrementGlobal");
   GlobalVariable *GV = insertGlobalInt32(M.get(), "my_global", initialNum);
   Value *DerefGV = Builder.CreateLoad(GV);
   Value *AddResult = Builder.CreateAdd(DerefGV,
@@ -161,14 +165,17 @@
   unsigned int numLevels = 23;
   int32_t innerRetVal= 5;
 
-  Function *Inner = startFunction<int32_t(void)>(M.get(), "Inner");
+  Function *Inner = startFunction(
+      M.get(), FunctionType::get(Builder.getInt32Ty(), {}, false), "Inner");
   endFunctionWithRet(Inner, ConstantInt::get(Context, APInt(32, innerRetVal)));
 
   Function *Outer;
   for (unsigned int i = 0; i < numLevels; ++i) {
     std::stringstream funcName;
     funcName << "level_" << i;
-    Outer = startFunction<int32_t(void)>(M.get(), funcName.str());
+    Outer = startFunction(M.get(),
+                          FunctionType::get(Builder.getInt32Ty(), {}, false),
+                          funcName.str());
     Value *innerResult = Builder.CreateCall(Inner, {});
     endFunctionWithRet(Outer, innerResult);
 
@@ -190,7 +197,8 @@
 TEST_F(MCJITTest, multiple_decl_lookups) {
   SKIP_UNSUPPORTED_PLATFORM;
 
-  Function *Foo = insertExternalReferenceToFunction<void(void)>(M.get(), "_exit");
+  Function *Foo = insertExternalReferenceToFunction(
+      M.get(), FunctionType::get(Builder.getVoidTy(), {}, false), "_exit");
   createJIT(std::move(M));
   void *A = TheJIT->getPointerToFunction(Foo);
   void *B = TheJIT->getPointerToFunction(Foo);
@@ -203,10 +211,12 @@
 
 TEST_F(MCJITTest, lazy_function_creator_pointer) {
   SKIP_UNSUPPORTED_PLATFORM;
-  
-  Function *Foo = insertExternalReferenceToFunction<int32_t(void)>(M.get(),
-                                                                   "\1Foo");
-  startFunction<int32_t(void)>(M.get(), "Parent");
+
+  Function *Foo = insertExternalReferenceToFunction(
+      M.get(), FunctionType::get(Builder.getInt32Ty(), {}, false),
+      "\1Foo");
+  startFunction(M.get(), FunctionType::get(Builder.getInt32Ty(), {}, false),
+                "Parent");
   CallInst *Call = Builder.CreateCall(Foo, {});
   Builder.CreateRet(Call);
   
@@ -240,12 +250,14 @@
 
 TEST_F(MCJITTest, lazy_function_creator_lambda) {
   SKIP_UNSUPPORTED_PLATFORM;
-  
-  Function *Foo1 = insertExternalReferenceToFunction<int32_t(void)>(M.get(),
-                                                                   "\1Foo1");
-  Function *Foo2 = insertExternalReferenceToFunction<int32_t(void)>(M.get(),
-                                                                   "\1Foo2");
-  startFunction<int32_t(void)>(M.get(), "Parent");
+
+  FunctionType *Int32VoidFnTy =
+      FunctionType::get(Builder.getInt32Ty(), {}, false);
+  Function *Foo1 =
+      insertExternalReferenceToFunction(M.get(), Int32VoidFnTy, "\1Foo1");
+  Function *Foo2 =
+      insertExternalReferenceToFunction(M.get(), Int32VoidFnTy, "\1Foo2");
+  startFunction(M.get(), Int32VoidFnTy, "Parent");
   CallInst *Call1 = Builder.CreateCall(Foo1, {});
   CallInst *Call2 = Builder.CreateCall(Foo2, {});
   Value *Result = Builder.CreateAdd(Call1, Call2);
diff --git a/llvm/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h b/llvm/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h
index a768920..50a57f1 100644
--- a/llvm/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h
+++ b/llvm/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h
@@ -24,7 +24,7 @@
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
-#include "llvm/IR/TypeBuilder.h"
+#include "llvm/IR/Type.h"
 #include "llvm/Support/CodeGen.h"
 
 namespace llvm {
@@ -45,11 +45,9 @@
     return M;
   }
 
-  template<typename FuncType>
-  Function *startFunction(Module *M, StringRef Name) {
-    Function *Result = Function::Create(
-      TypeBuilder<FuncType, false>::get(Context),
-      GlobalValue::ExternalLinkage, Name, M);
+  Function *startFunction(Module *M, FunctionType *FT, StringRef Name) {
+    Function *Result =
+        Function::Create(FT, GlobalValue::ExternalLinkage, Name, M);
 
     BasicBlock *BB = BasicBlock::Create(Context, Name, Result);
     Builder.SetInsertPoint(BB);
@@ -63,9 +61,8 @@
 
   // Inserts a simple function that invokes Callee and takes the same arguments:
   //    int Caller(...) { return Callee(...); }
-  template<typename Signature>
   Function *insertSimpleCallFunction(Module *M, Function *Callee) {
-    Function *Result = startFunction<Signature>(M, "caller");
+    Function *Result = startFunction(M, Callee->getFunctionType(), "caller");
 
     SmallVector<Value*, 1> CallArgs;
 
@@ -81,7 +78,8 @@
   //    int32_t main() { return X; }
   // where X is given by returnCode
   Function *insertMainFunction(Module *M, uint32_t returnCode) {
-    Function *Result = startFunction<int32_t(void)>(M, "main");
+    Function *Result = startFunction(
+        M, FunctionType::get(Type::getInt32Ty(Context), {}, false), "main");
 
     Value *ReturnVal = ConstantInt::get(Context, APInt(32, returnCode));
     endFunctionWithRet(Result, ReturnVal);
@@ -93,7 +91,12 @@
   //    int32_t add(int32_t a, int32_t b) { return a + b; }
   // in the current module and returns a pointer to it.
   Function *insertAddFunction(Module *M, StringRef Name = "add") {
-    Function *Result = startFunction<int32_t(int32_t, int32_t)>(M, Name);
+    Function *Result = startFunction(
+        M,
+        FunctionType::get(
+            Type::getInt32Ty(Context),
+            {Type::getInt32Ty(Context), Type::getInt32Ty(Context)}, false),
+        Name);
 
     Function::arg_iterator args = Result->arg_begin();
     Value *Arg1 = &*args;
@@ -106,20 +109,10 @@
   }
 
   // Inserts a declaration to a function defined elsewhere
-  template <typename FuncType>
-  Function *insertExternalReferenceToFunction(Module *M, StringRef Name) {
-    Function *Result = Function::Create(
-                         TypeBuilder<FuncType, false>::get(Context),
-                         GlobalValue::ExternalLinkage, Name, M);
-    return Result;
-  }
-
-  // Inserts an declaration to a function defined elsewhere
-  Function *insertExternalReferenceToFunction(Module *M, StringRef Name,
-                                              FunctionType *FuncTy) {
-    Function *Result = Function::Create(FuncTy,
-                                        GlobalValue::ExternalLinkage,
-                                        Name, M);
+  Function *insertExternalReferenceToFunction(Module *M, FunctionType *FTy,
+                                              StringRef Name) {
+    Function *Result =
+        Function::Create(FTy, GlobalValue::ExternalLinkage, Name, M);
     return Result;
   }
 
@@ -136,7 +129,7 @@
   GlobalVariable *insertGlobalInt32(Module *M,
                                     StringRef name,
                                     int32_t InitialValue) {
-    Type *GlobalTy = TypeBuilder<types::i<32>, true>::get(Context);
+    Type *GlobalTy = Type::getInt32Ty(Context);
     Constant *IV = ConstantInt::get(Context, APInt(32, InitialValue));
     GlobalVariable *Global = new GlobalVariable(*M,
                                                 GlobalTy,
@@ -160,7 +153,11 @@
   Function *insertAccumulateFunction(Module *M,
                                      Function *Helper = nullptr,
                                      StringRef Name = "accumulate") {
-    Function *Result = startFunction<int32_t(int32_t)>(M, Name);
+    Function *Result =
+        startFunction(M,
+                      FunctionType::get(Type::getInt32Ty(Context),
+                                        {Type::getInt32Ty(Context)}, false),
+                      Name);
     if (!Helper)
       Helper = Result;
 
@@ -225,11 +222,11 @@
 
     B.reset(createEmptyModule("B"));
     Function *FAExtern_in_B = insertExternalReferenceToFunction(B.get(), FA);
-    FB = insertSimpleCallFunction<int32_t(int32_t, int32_t)>(B.get(), FAExtern_in_B);
+    FB = insertSimpleCallFunction(B.get(), FAExtern_in_B);
 
     C.reset(createEmptyModule("C"));
     Function *FBExtern_in_C = insertExternalReferenceToFunction(C.get(), FB);
-    FC = insertSimpleCallFunction<int32_t(int32_t, int32_t)>(C.get(), FBExtern_in_C);
+    FC = insertSimpleCallFunction(C.get(), FBExtern_in_C);
   }
 
   // Module A { Function FA },
@@ -253,8 +250,7 @@
 
     B.reset(createEmptyModule("B"));
     Function *FAExtern_in_B = insertExternalReferenceToFunction(B.get(), FA);
-    FB = insertSimpleCallFunction<int32_t(int32_t, int32_t)>(B.get(),
-                                                             FAExtern_in_B);
+    FB = insertSimpleCallFunction(B.get(), FAExtern_in_B);
   }
 
   // Module A { Function FA },
@@ -268,11 +264,11 @@
 
     B.reset(createEmptyModule("B"));
     Function *FAExtern_in_B = insertExternalReferenceToFunction(B.get(), FA);
-    FB = insertSimpleCallFunction<int32_t(int32_t, int32_t)>(B.get(), FAExtern_in_B);
+    FB = insertSimpleCallFunction(B.get(), FAExtern_in_B);
 
     C.reset(createEmptyModule("C"));
     Function *FAExtern_in_C = insertExternalReferenceToFunction(C.get(), FA);
-    FC = insertSimpleCallFunction<int32_t(int32_t, int32_t)>(C.get(), FAExtern_in_C);
+    FC = insertSimpleCallFunction(C.get(), FAExtern_in_C);
   }
 };
 
diff --git a/llvm/unittests/ExecutionEngine/Orc/IndirectionUtilsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/IndirectionUtilsTest.cpp
index ed42544..1dfa0a1 100644
--- a/llvm/unittests/ExecutionEngine/Orc/IndirectionUtilsTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/IndirectionUtilsTest.cpp
@@ -19,7 +19,10 @@
 TEST(IndirectionUtilsTest, MakeStub) {
   LLVMContext Context;
   ModuleBuilder MB(Context, "x86_64-apple-macosx10.10", "");
-  Function *F = MB.createFunctionDecl<void(DummyStruct, DummyStruct)>("");
+  FunctionType *FTy = FunctionType::get(
+      Type::getVoidTy(Context),
+      {getDummyStructTy(Context), getDummyStructTy(Context)}, false);
+  Function *F = MB.createFunctionDecl(FTy, "");
   AttributeSet FnAttrs = AttributeSet::get(
       Context, AttrBuilder().addAttribute(Attribute::NoUnwind));
   AttributeSet RetAttrs; // None
diff --git a/llvm/unittests/ExecutionEngine/Orc/LegacyRTDyldObjectLinkingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/LegacyRTDyldObjectLinkingLayerTest.cpp
index 8c9c958..b3696c6 100644
--- a/llvm/unittests/ExecutionEngine/Orc/LegacyRTDyldObjectLinkingLayerTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/LegacyRTDyldObjectLinkingLayerTest.cpp
@@ -123,6 +123,8 @@
   if (!SupportsJIT)
     return;
 
+  Type *Int32Ty = IntegerType::get(Context, 32);
+
   ExecutionSession ES;
 
   auto MM = std::make_shared<SectionMemoryManagerWrapper>();
@@ -153,7 +155,8 @@
   ModuleBuilder MB1(Context, "", "dummy");
   {
     MB1.getModule()->setDataLayout(TM->createDataLayout());
-    Function *BarImpl = MB1.createFunctionDecl<int32_t(void)>("bar");
+    Function *BarImpl =
+        MB1.createFunctionDecl(FunctionType::get(Int32Ty, {}, false), "bar");
     BasicBlock *BarEntry = BasicBlock::Create(Context, "entry", BarImpl);
     IRBuilder<> Builder(BarEntry);
     IntegerType *Int32Ty = IntegerType::get(Context, 32);
@@ -166,8 +169,10 @@
   ModuleBuilder MB2(Context, "", "dummy");
   {
     MB2.getModule()->setDataLayout(TM->createDataLayout());
-    Function *BarDecl = MB2.createFunctionDecl<int32_t(void)>("bar");
-    Function *FooImpl = MB2.createFunctionDecl<int32_t(void)>("foo");
+    Function *BarDecl =
+        MB2.createFunctionDecl(FunctionType::get(Int32Ty, {}, false), "bar");
+    Function *FooImpl =
+        MB2.createFunctionDecl(FunctionType::get(Int32Ty, {}, false), "foo");
     BasicBlock *FooEntry = BasicBlock::Create(Context, "entry", FooImpl);
     IRBuilder<> Builder(FooEntry);
     Builder.CreateRet(Builder.CreateCall(BarDecl));
@@ -207,6 +212,8 @@
   if (!SupportsJIT)
     return;
 
+  Type *Int32Ty = IntegerType::get(Context, 32);
+
   ExecutionSession ES;
 
   auto MM = std::make_shared<SectionMemoryManagerWrapper>();
@@ -233,7 +240,8 @@
   ModuleBuilder MB1(Context, "", "dummy");
   {
     MB1.getModule()->setDataLayout(TM->createDataLayout());
-    Function *BarImpl = MB1.createFunctionDecl<int32_t(void)>("foo");
+    Function *BarImpl =
+        MB1.createFunctionDecl(FunctionType::get(Int32Ty, {}, false), "foo");
     BasicBlock *BarEntry = BasicBlock::Create(Context, "entry", BarImpl);
     IRBuilder<> Builder(BarEntry);
     IntegerType *Int32Ty = IntegerType::get(Context, 32);
@@ -246,7 +254,8 @@
   ModuleBuilder MB2(Context, "", "dummy");
   {
     MB2.getModule()->setDataLayout(TM->createDataLayout());
-    Function *BarImpl = MB2.createFunctionDecl<int32_t(void)>("bar");
+    Function *BarImpl =
+        MB2.createFunctionDecl(FunctionType::get(Int32Ty, {}, false), "bar");
     BasicBlock *BarEntry = BasicBlock::Create(Context, "entry", BarImpl);
     IRBuilder<> Builder(BarEntry);
     IntegerType *Int32Ty = IntegerType::get(Context, 32);
diff --git a/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp b/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp
index b288b6b..54d8156 100644
--- a/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp
@@ -27,8 +27,15 @@
 protected:
   std::unique_ptr<Module> createTestModule(const Triple &TT) {
     ModuleBuilder MB(Context, TT.str(), "");
-    Function *TestFunc = MB.createFunctionDecl<int()>("testFunc");
-    Function *Main = MB.createFunctionDecl<int(int, char*[])>("main");
+    Type *IntTy = Type::getScalarTy<int>(Context);
+    Function *TestFunc =
+        MB.createFunctionDecl(FunctionType::get(IntTy, {}, false), "testFunc");
+    Function *Main = MB.createFunctionDecl(
+        FunctionType::get(
+            IntTy,
+            {IntTy, Type::getInt8PtrTy(Context)->getPointerTo()},
+            false),
+        "main");
 
     Main->getBasicBlockList().push_back(BasicBlock::Create(Context));
     IRBuilder<> B(&Main->back());
diff --git a/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h b/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h
index e76d2fa..e25c513 100644
--- a/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h
+++ b/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h
@@ -22,7 +22,6 @@
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
-#include "llvm/IR/TypeBuilder.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
@@ -169,11 +168,8 @@
   ModuleBuilder(LLVMContext &Context, StringRef Triple,
                 StringRef Name);
 
-  template <typename FuncType>
-  Function* createFunctionDecl(StringRef Name) {
-    return Function::Create(
-             TypeBuilder<FuncType, false>::get(M->getContext()),
-             GlobalValue::ExternalLinkage, Name, M.get());
+  Function *createFunctionDecl(FunctionType *FTy, StringRef Name) {
+    return Function::Create(FTy, GlobalValue::ExternalLinkage, Name, M.get());
   }
 
   Module* getModule() { return M.get(); }
@@ -189,15 +185,9 @@
   int X[256];
 };
 
-// TypeBuilder specialization for DummyStruct.
-template <bool XCompile>
-class TypeBuilder<DummyStruct, XCompile> {
-public:
-  static StructType *get(LLVMContext &Context) {
-    return StructType::get(
-        TypeBuilder<types::i<32>[256], XCompile>::get(Context));
-  }
-};
+inline StructType *getDummyStructTy(LLVMContext &Context) {
+  return StructType::get(ArrayType::get(Type::getInt32Ty(Context), 256));
+}
 
 template <typename HandleT, typename ModuleT>
 class MockBaseLayer {
diff --git a/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
index 6b1dbe9..2db237f 100644
--- a/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
@@ -131,13 +131,17 @@
     ModuleBuilder MB(*TSCtx.getContext(), TM->getTargetTriple().str(), "dummy");
     MB.getModule()->setDataLayout(TM->createDataLayout());
 
-    Function *FooImpl = MB.createFunctionDecl<void()>("foo");
+    Function *FooImpl = MB.createFunctionDecl(
+        FunctionType::get(Type::getVoidTy(*TSCtx.getContext()), {}, false),
+        "foo");
     BasicBlock *FooEntry =
         BasicBlock::Create(*TSCtx.getContext(), "entry", FooImpl);
     IRBuilder<> B1(FooEntry);
     B1.CreateRetVoid();
 
-    Function *BarImpl = MB.createFunctionDecl<void()>("bar");
+    Function *BarImpl = MB.createFunctionDecl(
+        FunctionType::get(Type::getVoidTy(*TSCtx.getContext()), {}, false),
+        "bar");
     BasicBlock *BarEntry =
         BasicBlock::Create(*TSCtx.getContext(), "entry", BarImpl);
     IRBuilder<> B2(BarEntry);
@@ -181,9 +185,9 @@
     FunkySimpleCompiler(TargetMachine &TM) : SimpleCompiler(TM) {}
 
     CompileResult operator()(Module &M) {
-      Function *BarImpl =
-          Function::Create(TypeBuilder<void(), false>::get(M.getContext()),
-                           GlobalValue::ExternalLinkage, "bar", &M);
+      Function *BarImpl = Function::Create(
+          FunctionType::get(Type::getVoidTy(M.getContext()), {}, false),
+          GlobalValue::ExternalLinkage, "bar", &M);
       BasicBlock *BarEntry =
           BasicBlock::Create(M.getContext(), "entry", BarImpl);
       IRBuilder<> B(BarEntry);
@@ -200,7 +204,9 @@
     ModuleBuilder MB(*TSCtx.getContext(), TM->getTargetTriple().str(), "dummy");
     MB.getModule()->setDataLayout(TM->createDataLayout());
 
-    Function *FooImpl = MB.createFunctionDecl<void()>("foo");
+    Function *FooImpl = MB.createFunctionDecl(
+        FunctionType::get(Type::getVoidTy(*TSCtx.getContext()), {}, false),
+        "foo");
     BasicBlock *FooEntry =
         BasicBlock::Create(*TSCtx.getContext(), "entry", FooImpl);
     IRBuilder<> B(FooEntry);
diff --git a/llvm/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp
index 09224c2..4ffd741 100644
--- a/llvm/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp
@@ -95,7 +95,12 @@
   LLVMContext Ctx;
   ModuleBuilder MB(Ctx, TM->getTargetTriple().str(), "TestModule");
   MB.getModule()->setDataLayout(TM->createDataLayout());
-  auto *Main = MB.createFunctionDecl<void(int, char**)>("main");
+  auto *Main = MB.createFunctionDecl(
+      FunctionType::get(Type::getInt32Ty(Ctx),
+                        {Type::getInt32Ty(Ctx),
+                         Type::getInt8PtrTy(Ctx)->getPointerTo()},
+                        false),
+      "main");
   Main->getBasicBlockList().push_back(BasicBlock::Create(Ctx));
   IRBuilder<> B(&Main->back());
   B.CreateRet(ConstantInt::getSigned(Type::getInt32Ty(Ctx), 42));