aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-04-08 07:30:21 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-04-08 07:30:21 +0000
commit2c44a80d991df258a45e2f5fa76d5ada9e99015c (patch)
tree960ce3545438e6d7faf984ab3fa15af79dbb5163 /lib/VMCore
parentdd099e1e5519d718b572ff2b42b2a3581b66b5dd (diff)
downloadexternal_llvm-2c44a80d991df258a45e2f5fa76d5ada9e99015c.zip
external_llvm-2c44a80d991df258a45e2f5fa76d5ada9e99015c.tar.gz
external_llvm-2c44a80d991df258a45e2f5fa76d5ada9e99015c.tar.bz2
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129128 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Verifier.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 1143151..8b89110 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/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);
}