[llvm] r302485 - Ignore !associated metadata with null argument.

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Mon May 8 16:46:21 PDT 2017


Author: eugenis
Date: Mon May  8 18:46:20 2017
New Revision: 302485

URL: http://llvm.org/viewvc/llvm-project?rev=302485&view=rev
Log:
Ignore !associated metadata with null argument.

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

Modified:
    llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
    llvm/trunk/test/CodeGen/X86/elf-associated.ll

Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=302485&r1=302484&r2=302485&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Mon May  8 18:46:20 2017
@@ -232,7 +232,11 @@ static const MCSymbolELF *getAssociatedS
   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");
 

Modified: llvm/trunk/test/CodeGen/X86/elf-associated.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/elf-associated.ll?rev=302485&r1=302484&r2=302485&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/elf-associated.ll (original)
+++ llvm/trunk/test/CodeGen/X86/elf-associated.ll Mon May  8 18:46:20 2017
@@ -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




More information about the llvm-commits mailing list