Revert "[opaque pointer types] Add a FunctionCallee wrapper type, and use it."

This reverts commit f47d6b38c7a61d50db4566b02719de05492dcef1 (r352791).

Seems to run into compilation failures with GCC (but not clang, where
I tested it). Reverting while I investigate.

llvm-svn: 352800
diff --git a/llvm/unittests/Analysis/AliasAnalysisTest.cpp b/llvm/unittests/Analysis/AliasAnalysisTest.cpp
index a1a020f..7a84257 100644
--- a/llvm/unittests/Analysis/AliasAnalysisTest.cpp
+++ b/llvm/unittests/Analysis/AliasAnalysisTest.cpp
@@ -166,7 +166,7 @@
   // Setup function.
   FunctionType *FTy =
       FunctionType::get(Type::getVoidTy(C), std::vector<Type *>(), false);
-  auto *F = Function::Create(FTy, Function::ExternalLinkage, "f", M);
+  auto *F = cast<Function>(M.getOrInsertFunction("f", FTy));
   auto *BB = BasicBlock::Create(C, "entry", F);
   auto IntType = Type::getInt32Ty(C);
   auto PtrType = Type::getInt32PtrTy(C);
diff --git a/llvm/unittests/Analysis/DivergenceAnalysisTest.cpp b/llvm/unittests/Analysis/DivergenceAnalysisTest.cpp
index 9416e59..deaa800 100644
--- a/llvm/unittests/Analysis/DivergenceAnalysisTest.cpp
+++ b/llvm/unittests/Analysis/DivergenceAnalysisTest.cpp
@@ -78,7 +78,7 @@
   IntegerType *IntTy = IntegerType::getInt32Ty(Context);
   FunctionType *FTy =
       FunctionType::get(Type::getVoidTy(Context), {IntTy}, false);
-  Function *F = Function::Create(FTy, Function::ExternalLinkage, "f", M);
+  Function *F = cast<Function>(M.getOrInsertFunction("f", FTy));
   BasicBlock *BB = BasicBlock::Create(Context, "entry", F);
   ReturnInst::Create(Context, nullptr, BB);
 
diff --git a/llvm/unittests/Analysis/OrderedInstructionsTest.cpp b/llvm/unittests/Analysis/OrderedInstructionsTest.cpp
index 58eb0e5..1f4002f 100644
--- a/llvm/unittests/Analysis/OrderedInstructionsTest.cpp
+++ b/llvm/unittests/Analysis/OrderedInstructionsTest.cpp
@@ -25,7 +25,7 @@
   IRBuilder<> B(Ctx);
   FunctionType *FTy =
       FunctionType::get(Type::getVoidTy(Ctx), {B.getInt8PtrTy()}, false);
-  Function *F = Function::Create(FTy, Function::ExternalLinkage, "f", M);
+  Function *F = cast<Function>(M.getOrInsertFunction("f", FTy));
 
   // Create the function as follow and check for dominance relation.
   //
diff --git a/llvm/unittests/Analysis/PhiValuesTest.cpp b/llvm/unittests/Analysis/PhiValuesTest.cpp
index 6fd3f6d..ec60255 100644
--- a/llvm/unittests/Analysis/PhiValuesTest.cpp
+++ b/llvm/unittests/Analysis/PhiValuesTest.cpp
@@ -26,8 +26,7 @@
   Type *I32PtrTy = Type::getInt32PtrTy(C);
 
   // Create a function with phis that do not have other phis as incoming values
-  Function *F = Function::Create(FunctionType::get(VoidTy, false),
-                                 Function::ExternalLinkage, "f", M);
+  Function *F = cast<Function>(M.getOrInsertFunction("f", FunctionType::get(VoidTy, false)));
 
   BasicBlock *Entry = BasicBlock::Create(C, "entry", F);
   BasicBlock *If = BasicBlock::Create(C, "if", F);
@@ -93,8 +92,7 @@
   Type *I32PtrTy = Type::getInt32PtrTy(C);
 
   // Create a function with a phi that has another phi as an incoming value
-  Function *F = Function::Create(FunctionType::get(VoidTy, false),
-                                 Function::ExternalLinkage, "f", M);
+  Function *F = cast<Function>(M.getOrInsertFunction("f", FunctionType::get(VoidTy, false)));
 
   BasicBlock *Entry = BasicBlock::Create(C, "entry", F);
   BasicBlock *If1 = BasicBlock::Create(C, "if1", F);
diff --git a/llvm/unittests/Analysis/ScalarEvolutionTest.cpp b/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
index d39df89..9d293e0 100644
--- a/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
+++ b/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
@@ -63,7 +63,7 @@
 TEST_F(ScalarEvolutionsTest, SCEVUnknownRAUW) {
   FunctionType *FTy = FunctionType::get(Type::getVoidTy(Context),
                                               std::vector<Type *>(), false);
-  Function *F = Function::Create(FTy, Function::ExternalLinkage, "f", M);
+  Function *F = cast<Function>(M.getOrInsertFunction("f", FTy));
   BasicBlock *BB = BasicBlock::Create(Context, "entry", F);
   ReturnInst::Create(Context, nullptr, BB);
 
@@ -112,7 +112,7 @@
 TEST_F(ScalarEvolutionsTest, SimplifiedPHI) {
   FunctionType *FTy = FunctionType::get(Type::getVoidTy(Context),
                                               std::vector<Type *>(), false);
-  Function *F = Function::Create(FTy, Function::ExternalLinkage, "f", M);
+  Function *F = cast<Function>(M.getOrInsertFunction("f", FTy));
   BasicBlock *EntryBB = BasicBlock::Create(Context, "entry", F);
   BasicBlock *LoopBB = BasicBlock::Create(Context, "loop", F);
   BasicBlock *ExitBB = BasicBlock::Create(Context, "exit", F);
@@ -146,7 +146,7 @@
   auto *I32PtrTy = Type::getInt32PtrTy(Context);
   FunctionType *FTy =
       FunctionType::get(Type::getVoidTy(Context), std::vector<Type *>(), false);
-  Function *F = Function::Create(FTy, Function::ExternalLinkage, "f", M);
+  Function *F = cast<Function>(M.getOrInsertFunction("f", FTy));
   BasicBlock *EntryBB = BasicBlock::Create(Context, "entry", F);
   BasicBlock *LoopBB = BasicBlock::Create(Context, "loop", F);
   BasicBlock *ExitBB = BasicBlock::Create(Context, "exit", F);
@@ -329,7 +329,7 @@
 TEST_F(ScalarEvolutionsTest, CompareSCEVComplexity) {
   FunctionType *FTy =
       FunctionType::get(Type::getVoidTy(Context), std::vector<Type *>(), false);
-  Function *F = Function::Create(FTy, Function::ExternalLinkage, "f", M);
+  Function *F = cast<Function>(M.getOrInsertFunction("f", FTy));
   BasicBlock *EntryBB = BasicBlock::Create(Context, "entry", F);
   BasicBlock *LoopBB = BasicBlock::Create(Context, "bb1", F);
   BranchInst::Create(LoopBB, EntryBB);
@@ -399,7 +399,7 @@
 
   FunctionType *FTy =
       FunctionType::get(Type::getVoidTy(Context), {IntPtrTy, IntPtrTy}, false);
-  Function *F = Function::Create(FTy, Function::ExternalLinkage, "f", M);
+  Function *F = cast<Function>(M.getOrInsertFunction("f", FTy));
   BasicBlock *EntryBB = BasicBlock::Create(Context, "entry", F);
 
   Value *X = &*F->arg_begin();
@@ -435,7 +435,7 @@
 
   FunctionType *FTy =
       FunctionType::get(Type::getVoidTy(Context), ArgTys, false);
-  Function *F = Function::Create(FTy, Function::ExternalLinkage, "f", M);
+  Function *F = cast<Function>(M.getOrInsertFunction("f", FTy));
 
   Argument *A1 = &*F->arg_begin();
   Argument *A2 = &*(std::next(F->arg_begin()));
@@ -669,7 +669,7 @@
   //   ret void
   // }
   FunctionType *FTy = FunctionType::get(Type::getVoidTy(Context), {}, false);
-  Function *F = Function::Create(FTy, Function::ExternalLinkage, "foo", M);
+  Function *F = cast<Function>(M.getOrInsertFunction("foo", FTy));
 
   BasicBlock *EntryBB = BasicBlock::Create(Context, "entry", F);
   BasicBlock *CondBB = BasicBlock::Create(Context, "for.cond", F);
@@ -748,7 +748,7 @@
 
   FunctionType *FTy =
       FunctionType::get(Type::getVoidTy(Context), {T_pint64}, false);
-  Function *F = Function::Create(FTy, Function::ExternalLinkage, "foo", NIM);
+  Function *F = cast<Function>(NIM.getOrInsertFunction("foo", FTy));
 
   Argument *Arg = &*F->arg_begin();
 
@@ -821,7 +821,7 @@
 
   FunctionType *FTy =
       FunctionType::get(Type::getVoidTy(Context), {T_pint64}, false);
-  Function *F = Function::Create(FTy, Function::ExternalLinkage, "foo", NIM);
+  Function *F = cast<Function>(NIM.getOrInsertFunction("foo", FTy));
 
   BasicBlock *Top = BasicBlock::Create(Context, "top", F);
   BasicBlock *LPh = BasicBlock::Create(Context, "L.ph", F);
@@ -919,7 +919,7 @@
 
   FunctionType *FTy =
       FunctionType::get(Type::getVoidTy(Context), {T_pint64}, false);
-  Function *F = Function::Create(FTy, Function::ExternalLinkage, "foo", NIM);
+  Function *F = cast<Function>(NIM.getOrInsertFunction("foo", FTy));
 
   Argument *Arg = &*F->arg_begin();
 
@@ -979,8 +979,7 @@
   // ix.
   FunctionType *FTy =
       FunctionType::get(Type::getVoidTy(Context), std::vector<Type *>(), false);
-  Function *F =
-      Function::Create(FTy, Function::ExternalLinkage, "addrecphitest", M);
+  Function *F = cast<Function>(M.getOrInsertFunction("addrecphitest", FTy));
 
   /*
     Create IR:
@@ -1036,8 +1035,7 @@
   SmallVector<Type *, 1> Types;
   Types.push_back(Int32Ty);
   FunctionType *FTy = FunctionType::get(Type::getVoidTy(Context), Types, false);
-  Function *F =
-      Function::Create(FTy, Function::ExternalLinkage, "addrecphitest", M);
+  Function *F = cast<Function>(M.getOrInsertFunction("addrecphitest", FTy));
 
   /*
     Create IR:
@@ -1091,7 +1089,7 @@
   SmallVector<Type *, 1> Types;
   Types.push_back(ArgTy);
   FunctionType *FTy = FunctionType::get(Type::getVoidTy(Context), Types, false);
-  Function *F = Function::Create(FTy, Function::ExternalLinkage, "f", M);
+  Function *F = cast<Function>(M.getOrInsertFunction("f", FTy));
   BasicBlock *BB = BasicBlock::Create(Context, "entry", F);
   ReturnInst::Create(Context, nullptr, BB);
 
@@ -1147,7 +1145,7 @@
 
   FunctionType *FTy =
       FunctionType::get(Type::getVoidTy(Context), {T_pint64}, false);
-  Function *F = Function::Create(FTy, Function::ExternalLinkage, "foo", NIM);
+  Function *F = cast<Function>(NIM.getOrInsertFunction("foo", FTy));
 
   BasicBlock *Top = BasicBlock::Create(Context, "top", F);
   BasicBlock *LPh = BasicBlock::Create(Context, "L.ph", F);
@@ -1208,7 +1206,7 @@
 
   FunctionType *FTy =
       FunctionType::get(Type::getVoidTy(Context), { T_int64 }, false);
-  Function *F = Function::Create(FTy, Function::ExternalLinkage, "func", M);
+  Function *F = cast<Function>(M.getOrInsertFunction("func", FTy));
   Argument *Arg = &*F->arg_begin();
   ConstantInt *C = ConstantInt::get(Context, APInt(64, -1));
 
@@ -1260,7 +1258,7 @@
 
   FunctionType *FTy =
       FunctionType::get(Type::getVoidTy(Context), { T_int64 }, false);
-  Function *F = Function::Create(FTy, Function::ExternalLinkage, "func", M);
+  Function *F = cast<Function>(M.getOrInsertFunction("func", FTy));
   Argument *Arg = &*F->arg_begin();
   ConstantInt *C = ConstantInt::get(Context, APInt(64, -1));
 
@@ -1310,7 +1308,7 @@
 
   FunctionType *FTy =
       FunctionType::get(Type::getVoidTy(Context), { T_int64 }, false);
-  Function *F = Function::Create(FTy, Function::ExternalLinkage, "func", M);
+  Function *F = cast<Function>(M.getOrInsertFunction("func", FTy));
   Argument *Arg = &*F->arg_begin();
   ConstantInt *C = ConstantInt::get(Context, APInt(64, -1));
 
@@ -1361,7 +1359,7 @@
 
   FunctionType *FTy =
       FunctionType::get(Type::getVoidTy(Context), { T_int64 }, false);
-  Function *F = Function::Create(FTy, Function::ExternalLinkage, "func", M);
+  Function *F = cast<Function>(M.getOrInsertFunction("func", FTy));
   Argument *Arg = &*F->arg_begin();
   ConstantInt *C = ConstantInt::get(Context, APInt(64, -1));
 
@@ -1411,7 +1409,7 @@
 
   FunctionType *FTy =
       FunctionType::get(Type::getVoidTy(Context), { T_int64, T_int64 }, false);
-  Function *F = Function::Create(FTy, Function::ExternalLinkage, "func", M);
+  Function *F = cast<Function>(M.getOrInsertFunction("func", FTy));
   Argument *A = &*F->arg_begin();
   Argument *B = &*std::next(F->arg_begin());
   ConstantInt *C = ConstantInt::get(Context, APInt(64, 1));
diff --git a/llvm/unittests/Analysis/TBAATest.cpp b/llvm/unittests/Analysis/TBAATest.cpp
index 5a71c74..a626018 100644
--- a/llvm/unittests/Analysis/TBAATest.cpp
+++ b/llvm/unittests/Analysis/TBAATest.cpp
@@ -33,7 +33,7 @@
 static StoreInst *getFunctionWithSingleStore(Module *M, StringRef Name) {
   auto &C = M->getContext();
   FunctionType *FTy = FunctionType::get(Type::getVoidTy(C), {});
-  auto *F = Function::Create(FTy, Function::ExternalLinkage, Name, M);
+  auto *F = cast<Function>(M->getOrInsertFunction(Name, FTy));
   auto *BB = BasicBlock::Create(C, "entry", F);
   auto *IntType = Type::getInt32Ty(C);
   auto *PtrType = Type::getInt32PtrTy(C);
diff --git a/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp b/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
index f3b72b6..7830ca4 100644
--- a/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
+++ b/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
@@ -67,7 +67,7 @@
   for (unsigned FI = 0; FI != LibFunc::NumLibFuncs; ++FI) {
     LibFunc LF = (LibFunc)FI;
     auto *F = cast<Function>(
-        M->getOrInsertFunction(TLI.getName(LF), InvalidFTy).getCallee());
+        M->getOrInsertFunction(TLI.getName(LF), InvalidFTy));
     EXPECT_FALSE(isLibFunc(F, LF));
   }
 }