[Verifier] Support opaque pointers for global_ctors

Adjust the assertion to allow opaque pointers.
This commit is contained in:
Nikita Popov 2021-06-28 21:24:16 +02:00
parent 14a8aa6155
commit 333c0acb9b
2 changed files with 5 additions and 1 deletions

View File

@ -699,8 +699,9 @@ void Verifier::visitGlobalVariable(const GlobalVariable &GV) {
"the third field of the element type is mandatory, " "the third field of the element type is mandatory, "
"specify i8* null to migrate from the obsoleted 2-field form"); "specify i8* null to migrate from the obsoleted 2-field form");
Type *ETy = STy->getTypeAtIndex(2); Type *ETy = STy->getTypeAtIndex(2);
Type *Int8Ty = Type::getInt8Ty(ETy->getContext());
Assert(ETy->isPointerTy() && Assert(ETy->isPointerTy() &&
cast<PointerType>(ETy)->getElementType()->isIntegerTy(8), cast<PointerType>(ETy)->isOpaqueOrPointeeTypeMatches(Int8Ty),
"wrong type for intrinsic global variable", &GV); "wrong type for intrinsic global variable", &GV);
} }
} }

View File

@ -6,6 +6,9 @@
; CHECK: @g = external global i16 ; CHECK: @g = external global i16
@g = external global i16 @g = external global i16
; CHECK: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 1, ptr null, ptr null }]
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 1, void ()* null, i8* null }]
; CHECK: @ga = alias i18, ptr @g2 ; CHECK: @ga = alias i18, ptr @g2
@g2 = global i18 0 @g2 = global i18 0
@ga = alias i18, i18* @g2 @ga = alias i18, i18* @g2