diff options
Diffstat (limited to 'llvm/unittests')
-rw-r--r-- | llvm/unittests/Analysis/AliasAnalysisTest.cpp | 2 | ||||
-rw-r--r-- | llvm/unittests/Analysis/DivergenceAnalysisTest.cpp | 2 | ||||
-rw-r--r-- | llvm/unittests/Analysis/OrderedInstructionsTest.cpp | 2 | ||||
-rw-r--r-- | llvm/unittests/Analysis/PhiValuesTest.cpp | 6 | ||||
-rw-r--r-- | llvm/unittests/Analysis/ScalarEvolutionTest.cpp | 40 | ||||
-rw-r--r-- | llvm/unittests/Analysis/TBAATest.cpp | 2 | ||||
-rw-r--r-- | llvm/unittests/Analysis/TargetLibraryInfoTest.cpp | 2 | ||||
-rw-r--r-- | llvm/unittests/IR/CFGBuilder.cpp | 2 | ||||
-rw-r--r-- | llvm/unittests/IR/MetadataTest.cpp | 5 | ||||
-rw-r--r-- | llvm/unittests/IR/VerifierTest.cpp | 14 |
10 files changed, 36 insertions, 41 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)); } } diff --git a/llvm/unittests/IR/CFGBuilder.cpp b/llvm/unittests/IR/CFGBuilder.cpp index 1ce598799ca..a2016f7e6cb 100644 --- a/llvm/unittests/IR/CFGBuilder.cpp +++ b/llvm/unittests/IR/CFGBuilder.cpp @@ -23,7 +23,7 @@ CFGHolder::CFGHolder(StringRef ModuleName, StringRef FunctionName) : Context(llvm::make_unique<LLVMContext>()), M(llvm::make_unique<Module>(ModuleName, *Context)) { FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Context), {}, false); - F = Function::Create(FTy, Function::ExternalLinkage, FunctionName, M.get()); + F = cast<Function>(M->getOrInsertFunction(FunctionName, FTy)); } CFGHolder::~CFGHolder() = default; diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp index 7b9b7c4d898..c66bbde8182 100644 --- a/llvm/unittests/IR/MetadataTest.cpp +++ b/llvm/unittests/IR/MetadataTest.cpp @@ -117,9 +117,8 @@ protected: 32, 32, 0, DINode::FlagZero, nullptr, 0, nullptr, nullptr, ""); } Function *getFunction(StringRef Name) { - return Function::Create( - FunctionType::get(Type::getVoidTy(Context), None, false), - Function::ExternalLinkage, Name, M); + return cast<Function>(M.getOrInsertFunction( + Name, FunctionType::get(Type::getVoidTy(Context), None, false))); } }; typedef MetadataTest MDStringTest; diff --git a/llvm/unittests/IR/VerifierTest.cpp b/llvm/unittests/IR/VerifierTest.cpp index a85f0a25fc8..a04efa188ca 100644 --- a/llvm/unittests/IR/VerifierTest.cpp +++ b/llvm/unittests/IR/VerifierTest.cpp @@ -26,7 +26,7 @@ TEST(VerifierTest, Branch_i1) { LLVMContext C; Module M("M", C); FunctionType *FTy = FunctionType::get(Type::getVoidTy(C), /*isVarArg=*/false); - Function *F = Function::Create(FTy, Function::ExternalLinkage, "foo", M); + Function *F = cast<Function>(M.getOrInsertFunction("foo", FTy)); BasicBlock *Entry = BasicBlock::Create(C, "entry", F); BasicBlock *Exit = BasicBlock::Create(C, "exit", F); ReturnInst::Create(C, Exit); @@ -49,7 +49,7 @@ TEST(VerifierTest, InvalidRetAttribute) { LLVMContext C; Module M("M", C); FunctionType *FTy = FunctionType::get(Type::getInt32Ty(C), /*isVarArg=*/false); - Function *F = Function::Create(FTy, Function::ExternalLinkage, "foo", M); + Function *F = cast<Function>(M.getOrInsertFunction("foo", FTy)); AttributeList AS = F->getAttributes(); F->setAttributes( AS.addAttribute(C, AttributeList::ReturnIndex, Attribute::UWTable)); @@ -67,9 +67,9 @@ TEST(VerifierTest, CrossModuleRef) { Module M2("M2", C); Module M3("M3", C); FunctionType *FTy = FunctionType::get(Type::getInt32Ty(C), /*isVarArg=*/false); - Function *F1 = Function::Create(FTy, Function::ExternalLinkage, "foo1", M1); - Function *F2 = Function::Create(FTy, Function::ExternalLinkage, "foo2", M2); - Function *F3 = Function::Create(FTy, Function::ExternalLinkage, "foo3", M3); + Function *F1 = cast<Function>(M1.getOrInsertFunction("foo1", FTy)); + Function *F2 = cast<Function>(M2.getOrInsertFunction("foo2", FTy)); + Function *F3 = cast<Function>(M3.getOrInsertFunction("foo3", FTy)); BasicBlock *Entry1 = BasicBlock::Create(C, "entry", F1); BasicBlock *Entry3 = BasicBlock::Create(C, "entry", F3); @@ -173,8 +173,8 @@ TEST(VerifierTest, DetectInvalidDebugInfo) { new GlobalVariable(M, Type::getInt8Ty(C), false, GlobalValue::ExternalLinkage, nullptr, "g"); - auto *F = Function::Create(FunctionType::get(Type::getVoidTy(C), false), - Function::ExternalLinkage, "f", M); + auto *F = cast<Function>(M.getOrInsertFunction( + "f", FunctionType::get(Type::getVoidTy(C), false))); IRBuilder<> Builder(BasicBlock::Create(C, "", F)); Builder.CreateUnreachable(); F->setSubprogram(DIB.createFunction( |