mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user