[llvm] 333c0ac - [Verifier] Support opaque pointers for global_ctors
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 28 12:41:06 PDT 2021
Author: Nikita Popov
Date: 2021-06-28T21:40:54+02:00
New Revision: 333c0acb9bb36bd89ab75abba3d368da67f7370c
URL: https://github.com/llvm/llvm-project/commit/333c0acb9bb36bd89ab75abba3d368da67f7370c
DIFF: https://github.com/llvm/llvm-project/commit/333c0acb9bb36bd89ab75abba3d368da67f7370c.diff
LOG: [Verifier] Support opaque pointers for global_ctors
Adjust the assertion to allow opaque pointers.
Added:
Modified:
llvm/lib/IR/Verifier.cpp
llvm/test/Other/force-opaque-ptrs.ll
Removed:
################################################################################
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 24f5d51381803..6039d1cf2dc02 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/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<PointerType>(ETy)->getElementType()->isIntegerTy(8),
+ cast<PointerType>(ETy)->isOpaqueOrPointeeTypeMatches(Int8Ty),
"wrong type for intrinsic global variable", &GV);
}
}
diff --git a/llvm/test/Other/force-opaque-ptrs.ll b/llvm/test/Other/force-opaque-ptrs.ll
index e80fdce0e6e27..fa83bb56080e5 100644
--- a/llvm/test/Other/force-opaque-ptrs.ll
+++ b/llvm/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 }]
+ at 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
More information about the llvm-commits
mailing list