LowerTypeTests: Ignore external globals with type metadata.
Thanks to Davide Italiano for finding the problem and providing a test case. llvm-svn: 293119
This commit is contained in:
parent
7c021afef2
commit
1df6e858ef
|
@ -878,9 +878,9 @@ void LowerTypeTestsModule::verifyTypeMDNode(GlobalObject *GO, MDNode *Type) {
|
|||
report_fatal_error(
|
||||
"A member of a type identifier may not have an explicit section");
|
||||
|
||||
if (isa<GlobalVariable>(GO) && GO->isDeclarationForLinker())
|
||||
report_fatal_error(
|
||||
"A global var member of a type identifier must be a definition");
|
||||
// FIXME: We previously checked that global var member of a type identifier
|
||||
// must be a definition, but the IR linker may leave type metadata on
|
||||
// declarations. We should restore this check after fixing PR31759.
|
||||
|
||||
auto OffsetConstMD = dyn_cast<ConstantAsMetadata>(Type->getOperand(0));
|
||||
if (!OffsetConstMD)
|
||||
|
@ -1375,6 +1375,9 @@ bool LowerTypeTestsModule::lower() {
|
|||
unsigned I = 0;
|
||||
SmallVector<MDNode *, 2> Types;
|
||||
for (GlobalObject &GO : M.global_objects()) {
|
||||
if (isa<GlobalVariable>(GO) && GO.isDeclarationForLinker())
|
||||
continue;
|
||||
|
||||
Types.clear();
|
||||
GO.getMetadata(LLVMContext::MD_type, Types);
|
||||
if (Types.empty())
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
; RUN: opt -S -lowertypetests -lowertypetests-summary-action=export -o - %s | FileCheck %s
|
||||
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-scei-ps4"
|
||||
|
||||
; CHECK: @dipsy = external
|
||||
@dipsy = external constant i8, !type !0
|
||||
|
||||
define void @tinkywinky() {
|
||||
store i8* @dipsy, i8** undef
|
||||
ret void
|
||||
}
|
||||
|
||||
!0 = !{i64 16, !"teletubbies"}
|
Loading…
Reference in New Issue