[patch] Fix pr25919

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 15 08:50:46 PST 2016


> So the patch should have no impact on the code ld64 generates. I will
> add a test for that. Is the patch OK?

Test added in r257903.

Rebased patch attached.

Cheers,
Rafael
-------------- next part --------------
diff --git a/lib/CodeGen/Analysis.cpp b/lib/CodeGen/Analysis.cpp
index 75579a2..97b692f 100644
--- a/lib/CodeGen/Analysis.cpp
+++ b/lib/CodeGen/Analysis.cpp
@@ -639,6 +639,11 @@ bool llvm::canBeOmittedFromSymbolTable(const GlobalValue *GV) {
   if (isa<GlobalAlias>(GV))
     return false;
 
+  // If we don't see every use, we have to be conservative and assume the value
+  // address is significant.
+  if (GV->getParent()->getMaterializer())
+    return false;
+
   GlobalStatus GS;
   if (GlobalStatus::analyzeGlobal(GV, GS))
     return false;
diff --git a/test/LTO/X86/pr25919.ll b/test/LTO/X86/pr25919.ll
new file mode 100644
index 0000000..b7fe0c6
--- /dev/null
+++ b/test/LTO/X86/pr25919.ll
@@ -0,0 +1,11 @@
+; RUN: llvm-as < %s >%t1
+; RUN: llvm-lto -list-symbols-only %t1 | FileCheck %s
+
+; This tests that we don't crash trying to find all uses in a lazily loaded
+; module.
+; CHECK: foo
+
+target triple = "x86_64-unknown-linux-gnu"
+define linkonce_odr void @foo() {
+  ret void
+}


More information about the llvm-commits mailing list