From 53eb6785988e0e0564dd8a48413672b2b0705f29 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 28 Jun 2021 21:24:16 +0200 Subject: [PATCH] [Verifier] Support opaque pointers for global_ctors Adjust the assertion to allow opaque pointers. --- lib/IR/Verifier.cpp | 3 ++- test/Other/force-opaque-ptrs.ll | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index 24f5d513818..6039d1cf2dc 100644 --- a/lib/IR/Verifier.cpp +++ b/lib/IR/Verifier.cpp @@ -699,8 +699,9 @@ void Verifier::visitGlobalVariable(const GlobalVariable &GV) { "the third field of the element type is mandatory, " "specify i8* null to migrate from the obsoleted 2-field form"); Type *ETy = STy->getTypeAtIndex(2); + Type *Int8Ty = Type::getInt8Ty(ETy->getContext()); Assert(ETy->isPointerTy() && - cast(ETy)->getElementType()->isIntegerTy(8), + cast(ETy)->isOpaqueOrPointeeTypeMatches(Int8Ty), "wrong type for intrinsic global variable", &GV); } } diff --git a/test/Other/force-opaque-ptrs.ll b/test/Other/force-opaque-ptrs.ll index e80fdce0e6e..fa83bb56080 100644 --- a/test/Other/force-opaque-ptrs.ll +++ b/test/Other/force-opaque-ptrs.ll @@ -6,6 +6,9 @@ ; CHECK: @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 @g2 = global i18 0 @ga = alias i18, i18* @g2