aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/IR/VerifierTest.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-10-30 22:37:51 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-10-30 22:37:51 +0000
commit55fdcff4469bd9ff1364f50f9969d2202e822e75 (patch)
treecf17fc0b260fba3f983acb466c0629bf4523c6fb /llvm/unittests/IR/VerifierTest.cpp
parent6f1b2852fcddc0ee7f335bff52237e9b5309ee8f (diff)
downloadllvm-55fdcff4469bd9ff1364f50f9969d2202e822e75.zip
llvm-55fdcff4469bd9ff1364f50f9969d2202e822e75.tar.gz
llvm-55fdcff4469bd9ff1364f50f9969d2202e822e75.tar.bz2
Add calls to doInitialization() and doFinalization() in verifyFunction()
The function verifyFunction() in lib/IR/Verifier.cpp misses some calls. It creates a temporary FunctionPassManager that will run a single Verifier pass. Unfortunately, FunctionPassManager is no PassManager and does not call doInitialization() and doFinalization() by itself. Verifier does important tasks in doInitialization() such as collecting type information used to check DebugInfo metadata and doFinalization() does some additional checks. Therefore these checks were missed and debug info couldn't be verified at all, it just crashed if the function had some. verifyFunction() is currently not used in llvm unless -debug option is enabled, and in unittests/IR/VerifierTest.cpp VerifierTest had to be changed to create the function in a module from which the type debug info can be collected. Patch by Michael Kruse. llvm-svn: 193719
Diffstat (limited to 'llvm/unittests/IR/VerifierTest.cpp')
-rw-r--r--llvm/unittests/IR/VerifierTest.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/unittests/IR/VerifierTest.cpp b/llvm/unittests/IR/VerifierTest.cpp
index 2848cb8..31936c3 100644
--- a/llvm/unittests/IR/VerifierTest.cpp
+++ b/llvm/unittests/IR/VerifierTest.cpp
@@ -24,10 +24,11 @@ namespace {
TEST(VerifierTest, Branch_i1) {
LLVMContext &C = getGlobalContext();
+ Module M("M", C);
FunctionType *FTy = FunctionType::get(Type::getVoidTy(C), /*isVarArg=*/false);
- OwningPtr<Function> F(Function::Create(FTy, GlobalValue::ExternalLinkage));
- BasicBlock *Entry = BasicBlock::Create(C, "entry", F.get());
- BasicBlock *Exit = BasicBlock::Create(C, "exit", F.get());
+ 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);
// To avoid triggering an assertion in BranchInst::Create, we first create