summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Analysis
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/Analysis')
-rw-r--r--llvm/unittests/Analysis/AliasAnalysisTest.cpp2
-rw-r--r--llvm/unittests/Analysis/DivergenceAnalysisTest.cpp2
-rw-r--r--llvm/unittests/Analysis/OrderedInstructionsTest.cpp2
-rw-r--r--llvm/unittests/Analysis/PhiValuesTest.cpp6
-rw-r--r--llvm/unittests/Analysis/ScalarEvolutionTest.cpp40
-rw-r--r--llvm/unittests/Analysis/TBAATest.cpp2
-rw-r--r--llvm/unittests/Analysis/TargetLibraryInfoTest.cpp2
7 files changed, 26 insertions, 30 deletions
diff --git a/llvm/unittests/Analysis/AliasAnalysisTest.cpp b/llvm/unittests/Analysis/AliasAnalysisTest.cpp
index a1a020f000b..7a842575df4 100644
--- a/llvm/unittests/Analysis/AliasAnalysisTest.cpp
+++ b/llvm/unittests/Analysis/AliasAnalysisTest.cpp
@@ -166,7 +166,7 @@ TEST_F(AliasAnalysisTest, getModRefInfo) {
// 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 9416e592012..deaa800f7be 100644
--- a/llvm/unittests/Analysis/DivergenceAnalysisTest.cpp
+++ b/llvm/unittests/Analysis/DivergenceAnalysisTest.cpp
@@ -78,7 +78,7 @@ TEST_F(DivergenceAnalysisTest, DAInitialState) {
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 58eb0e56e06..1f4002fb766 100644
--- a/llvm/unittests/Analysis/OrderedInstructionsTest.cpp
+++ b/llvm/unittests/Analysis/OrderedInstructionsTest.cpp
@@ -25,7 +25,7 @@ TEST(OrderedInstructionsTest, DominanceTest) {
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 6fd3f6d6654..ec60255cf12 100644
--- a/llvm/unittests/Analysis/PhiValuesTest.cpp
+++ b/llvm/unittests/Analysis/PhiValuesTest.cpp
@@ -26,8 +26,7 @@ TEST(PhiValuesTest, SimplePhi) {
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 @@ TEST(PhiValuesTest, DependentPhi) {
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 d39df897ea6..9d293e0b2a2 100644
--- a/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
+++ b/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
@@ -63,7 +63,7 @@ protected:
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, SCEVUnknownRAUW) {
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 @@ TEST_F(ScalarEvolutionsTest, ExpandPtrTypeSCEV) {
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, CommutativeExprOperandOrder) {
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 @@ TEST_F(ScalarEvolutionsTest, CompareValueComplexity) {
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 @@ TEST_F(ScalarEvolutionsTest, SCEVAddExpr) {
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 @@ TEST_F(ScalarEvolutionsTest, SCEVZeroExtendExpr) {
// 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 @@ TEST_F(ScalarEvolutionsTest, SCEVZeroExtendExprNonIntegral) {
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 @@ TEST_F(ScalarEvolutionsTest, SCEVExitLimitForgetLoop) {
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 @@ TEST_F(ScalarEvolutionsTest, SCEVExitLimitForgetValue) {
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 @@ TEST_F(ScalarEvolutionsTest, SCEVAddRecFromPHIwithLargeConstants) {
// 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 @@ TEST_F(ScalarEvolutionsTest, SCEVAddRecFromPHIwithLargeConstantAccum) {
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 @@ TEST_F(ScalarEvolutionsTest, SCEVFoldSumOfTruncs) {
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 @@ TEST_F(ScalarEvolutionsTest, SCEVExpanderIsSafeToExpandAt) {
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 @@ TEST_F(ScalarEvolutionsTest, SCEVExpanderNUW) {
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 @@ TEST_F(ScalarEvolutionsTest, SCEVExpanderNSW) {
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 @@ TEST_F(ScalarEvolutionsTest, SCEVCacheNUW) {
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 @@ TEST_F(ScalarEvolutionsTest, SCEVCacheNSW) {
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 @@ TEST_F(ScalarEvolutionsTest, SCEVComputeExpressionSize) {
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 5a71c74a80b..a626018c838 100644
--- a/llvm/unittests/Analysis/TBAATest.cpp
+++ b/llvm/unittests/Analysis/TBAATest.cpp
@@ -33,7 +33,7 @@ protected:
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 f3b72b624fc..7830ca4ef7c 100644
--- a/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
+++ b/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
@@ -67,7 +67,7 @@ TEST_F(TargetLibraryInfoTest, InvalidProto) {
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));
}
}
OpenPOWER on IntegriCloud