diff options
Diffstat (limited to 'llvm/unittests/IR')
-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 |
3 files changed, 10 insertions, 11 deletions
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( |