[PATCH] D49777: [LTO] Don't internalize declarations

Bob Haarman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 26 19:02:29 PDT 2018


inglorion updated this revision to Diff 157625.
inglorion marked 2 inline comments as done.
inglorion added a comment.

Per @pcc's suggestions:

Updated the comment.

Simplified the testcase. There is still a bit more metadata in there
than in dbg_value.ll, notably !llvm.module.flags and its
descendants. Without that, the broken module error does not reproduce.


https://reviews.llvm.org/D49777

Files:
  llvm/lib/LTO/LTO.cpp
  llvm/test/LTO/X86/pr38046.ll


Index: llvm/test/LTO/X86/pr38046.ll
===================================================================
--- /dev/null
+++ llvm/test/LTO/X86/pr38046.ll
@@ -0,0 +1,31 @@
+; RUN: opt -module-summary -o %t.o %s
+; RUN: llvm-lto2 run -save-temps -o %t.lto.o %t.o \
+; RUN:   -r=%t.o,foo,plx \
+; RUN:   -r=%t.o,get,pl
+; RUN: llvm-dis %t.lto.o.0.2.internalize.bc > /dev/null
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo() {
+  call void @llvm.dbg.value(metadata i32 ()* @get, metadata !7, metadata !DIExpression()), !dbg !DILocation(scope: !6)
+  ret i32 0
+}
+
+define i32 @get() {
+  ret i32 0
+}
+
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2, !3, !4, !5}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1)
+!1 = !DIFile(filename: "t.cc", directory: "/tmp/t")
+!2 = !{i32 2, !"Dwarf Version", i32 4}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !{i32 1, !"wchar_size", i32 4}
+!5 = !{i32 1, !"ThinLTO", i32 0}
+!6 = distinct !DISubprogram(unit: !0)
+!7 = !DILocalVariable(name: "get", scope: !6)
Index: llvm/lib/LTO/LTO.cpp
===================================================================
--- llvm/lib/LTO/LTO.cpp
+++ llvm/lib/LTO/LTO.cpp
@@ -871,8 +871,9 @@
 
       GlobalValue *GV =
           RegularLTO.CombinedModule->getNamedValue(R.second.IRName);
-      // Ignore symbols defined in other partitions.
-      if (!GV || GV->hasLocalLinkage())
+      // Ignore and symbols defined in other partitions.
+      // Also skip declarations, which are not allowed to have internal linkage.
+      if (!GV || GV->hasLocalLinkage() || GV->isDeclaration())
         continue;
       GV->setUnnamedAddr(R.second.UnnamedAddr ? GlobalValue::UnnamedAddr::Global
                                               : GlobalValue::UnnamedAddr::None);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49777.157625.patch
Type: text/x-patch
Size: 1914 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180727/8e65a0af/attachment.bin>


More information about the llvm-commits mailing list