summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/IR
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/IR')
-rw-r--r--llvm/unittests/IR/CFGBuilder.cpp2
-rw-r--r--llvm/unittests/IR/MetadataTest.cpp5
-rw-r--r--llvm/unittests/IR/VerifierTest.cpp14
3 files changed, 11 insertions, 10 deletions
diff --git a/llvm/unittests/IR/CFGBuilder.cpp b/llvm/unittests/IR/CFGBuilder.cpp
index a2016f7e6cb..1ce598799ca 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 = cast<Function>(M->getOrInsertFunction(FunctionName, FTy));
+ F = Function::Create(FTy, Function::ExternalLinkage, FunctionName, M.get());
}
CFGHolder::~CFGHolder() = default;
diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp
index c66bbde8182..7b9b7c4d898 100644
--- a/llvm/unittests/IR/MetadataTest.cpp
+++ b/llvm/unittests/IR/MetadataTest.cpp
@@ -117,8 +117,9 @@ protected:
32, 32, 0, DINode::FlagZero, nullptr, 0, nullptr, nullptr, "");
}
Function *getFunction(StringRef Name) {
- return cast<Function>(M.getOrInsertFunction(
- Name, FunctionType::get(Type::getVoidTy(Context), None, false)));
+ return Function::Create(
+ FunctionType::get(Type::getVoidTy(Context), None, false),
+ Function::ExternalLinkage, Name, M);
}
};
typedef MetadataTest MDStringTest;
diff --git a/llvm/unittests/IR/VerifierTest.cpp b/llvm/unittests/IR/VerifierTest.cpp
index a04efa188ca..a85f0a25fc8 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 = cast<Function>(M.getOrInsertFunction("foo", FTy));
+ Function *F = Function::Create(FTy, Function::ExternalLinkage, "foo", M);
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 = cast<Function>(M.getOrInsertFunction("foo", FTy));
+ Function *F = Function::Create(FTy, Function::ExternalLinkage, "foo", M);
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 = cast<Function>(M1.getOrInsertFunction("foo1", FTy));
- Function *F2 = cast<Function>(M2.getOrInsertFunction("foo2", FTy));
- Function *F3 = cast<Function>(M3.getOrInsertFunction("foo3", FTy));
+ 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);
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 = cast<Function>(M.getOrInsertFunction(
- "f", FunctionType::get(Type::getVoidTy(C), false)));
+ auto *F = Function::Create(FunctionType::get(Type::getVoidTy(C), false),
+ Function::ExternalLinkage, "f", M);
IRBuilder<> Builder(BasicBlock::Create(C, "", F));
Builder.CreateUnreachable();
F->setSubprogram(DIB.createFunction(
OpenPOWER on IntegriCloud