[PATCH] D32979: Ignore !associated metadata with null argument

Evgenii Stepanov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 8 13:50:14 PDT 2017


eugenis created this revision.
Herald added a subscriber: mehdi_amini.

Fixes PR32577 (comment 10).
Such metadata may legitimately appear in LTO.


Repository:
  rL LLVM

https://reviews.llvm.org/D32979

Files:
  lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  test/CodeGen/X86/elf-associated.ll


Index: test/CodeGen/X86/elf-associated.ll
===================================================================
--- test/CodeGen/X86/elf-associated.ll
+++ test/CodeGen/X86/elf-associated.ll
@@ -37,3 +37,8 @@
 @l = global i32 1, section "ccc", !associated !5
 !5 = !{i32* null}
 ; CHECK-DAG: .section	ccc,"aw", at progbits
+
+; Null metadata.
+ at m = global i32 1, section "ddd", !associated !6
+!6 = distinct !{null}
+; CHECK-DAG: .section	ddd,"aw", at progbits
Index: lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -232,7 +232,11 @@
   if (!MD)
     return nullptr;
 
-  auto *VM = dyn_cast<ValueAsMetadata>(MD->getOperand(0));
+  const MDOperand &Op = MD->getOperand(0);
+  if (!Op.get())
+    return nullptr;
+
+  auto *VM = dyn_cast<ValueAsMetadata>(Op);
   if (!VM)
     report_fatal_error("MD_associated operand is not ValueAsMetadata");
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32979.98201.patch
Type: text/x-patch
Size: 1003 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170508/5115a5aa/attachment.bin>


More information about the llvm-commits mailing list