diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2011-04-08 07:30:21 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2011-04-08 07:30:21 +0000 |
commit | 466d0c1f9339583e548ce55b93c69b034c6ab85f (patch) | |
tree | 9ae05c0ee496e61f0b4ce43e2ce6a6d1ca70ca61 /llvm/lib/VMCore/Verifier.cpp | |
parent | 42983aef3497399630a64ff098361ab5f24b9691 (diff) | |
download | bcm5719-llvm-466d0c1f9339583e548ce55b93c69b034c6ab85f.tar.gz bcm5719-llvm-466d0c1f9339583e548ce55b93c69b034c6ab85f.zip |
llvm.global_[cd]tor is defined to be either external, or appending with an array
of { i32, void ()* }. Teach the verifier to verify that, deleting copies of
checks strewn about.
llvm-svn: 129128
Diffstat (limited to 'llvm/lib/VMCore/Verifier.cpp')
-rw-r--r-- | llvm/lib/VMCore/Verifier.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Verifier.cpp b/llvm/lib/VMCore/Verifier.cpp index 1143151b01d..8b891100839 100644 --- a/llvm/lib/VMCore/Verifier.cpp +++ b/llvm/lib/VMCore/Verifier.cpp @@ -471,6 +471,23 @@ void Verifier::visitGlobalVariable(GlobalVariable &GV) { "invalid linkage type for global declaration", &GV); } + if (GV.hasName() && (GV.getName() == "llvm.global_ctors" || + GV.getName() == "llvm.global_dtors")) { + Assert1(!GV.hasInitializer() || GV.hasAppendingLinkage(), + "invalid linkage for intrinsic global variable", &GV); + // Don't worry about emitting an error for it not being an array, + // visitGlobalValue will complain on appending non-array. + if (const ArrayType *ATy = dyn_cast<ArrayType>(GV.getType())) { + const StructType *STy = dyn_cast<StructType>(ATy->getElementType()); + const PointerType *FuncPtrTy = + FunctionType::get(Type::getVoidTy(*Context), false)->getPointerTo(); + Assert1(STy && STy->getNumElements() == 2 && + STy->getTypeAtIndex(0u)->isIntegerTy(32) && + STy->getTypeAtIndex(1) == FuncPtrTy, + "wrong type for intrinsic global variable", &GV); + } + } + visitGlobalValue(GV); } |