[llvm] r293119 - LowerTypeTests: Ignore external globals with type metadata.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 25 16:32:16 PST 2017


Author: pcc
Date: Wed Jan 25 18:32:15 2017
New Revision: 293119

URL: http://llvm.org/viewvc/llvm-project?rev=293119&view=rev
Log:
LowerTypeTests: Ignore external globals with type metadata.

Thanks to Davide Italiano for finding the problem and providing a test case.

Added:
    llvm/trunk/test/Transforms/LowerTypeTests/external-global.ll
Modified:
    llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp

Modified: llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp?rev=293119&r1=293118&r2=293119&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp Wed Jan 25 18:32:15 2017
@@ -878,9 +878,9 @@ void LowerTypeTestsModule::verifyTypeMDN
     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())

Added: llvm/trunk/test/Transforms/LowerTypeTests/external-global.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LowerTypeTests/external-global.ll?rev=293119&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/LowerTypeTests/external-global.ll (added)
+++ llvm/trunk/test/Transforms/LowerTypeTests/external-global.ll Wed Jan 25 18:32:15 2017
@@ -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
+ at dipsy = external constant i8, !type !0
+
+define void @tinkywinky() {
+  store i8* @dipsy, i8** undef
+  ret void
+}
+
+!0 = !{i64 16, !"teletubbies"}




More information about the llvm-commits mailing list