[PATCH] D80255: [RFC] [LLD] Do not ignore comdats when parsing LTO objects

Christy Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 19 16:00:19 PDT 2020


christylee created this revision.
Herald added subscribers: llvm-commits, dexonsmith, steven_wu, MaskRay, hiraditya, arichardson, inglorion, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: MaskRay.
Herald added a project: LLVM.
christylee edited the summary of this revision.
christylee added reviewers: ruiu, hoy, wenlei, sbc100, dblaikie.

We are trying to migrate from gold to lld, and we found that when building with thinlto, lld does not de-duplicate .debug_types. De-duplication is successful with monolithic lto. Repro: clang -flto=thin -fdebug-types-section -fuse-ld=lld -Wl,-plugin-opt=-generate-type-units

If we set ignoreComdats=false for lto builds, then the de-duplication is successful again.  Looking at the thinlto code, it looks like there is no comdat folding at thinlto time.

For more context, see https://reviews.llvm.org/D62884


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80255

Files:
  lld/ELF/Driver.cpp
  lld/test/ELF/lto/comdat.ll
  lld/test/ELF/lto/comdat2.ll


Index: lld/test/ELF/lto/comdat2.ll
===================================================================
--- lld/test/ELF/lto/comdat2.ll
+++ lld/test/ELF/lto/comdat2.ll
@@ -23,13 +23,13 @@
 ; CHECK: Symbol {
 ; CHECK:   Name: foo
 ; CHECK-NEXT:   Value:
-; CHECK-NEXT:   Size: 1
+; CHECK-NEXT:   Size: 0
 ; CHECK-NEXT:   Binding: Global
 ; CHECK-NEXT:   Type: Function
 ; CHECK-NEXT:   Other [
 ; CHECK-NEXT:     STV_PROTECTED
 ; CHECK-NEXT:   ]
-; CHECK-NEXT:   Section: .text
+; CHECK-NEXT:   Section: Undefined
 ; CHECK-NEXT: }
 
 ; OTHER: Symbol {
Index: lld/test/ELF/lto/comdat.ll
===================================================================
--- lld/test/ELF/lto/comdat.ll
+++ lld/test/ELF/lto/comdat.ll
@@ -5,11 +5,11 @@
 
 ; CHECK:      Name: foo
 ; CHECK-NEXT: Value:
-; CHECK-NEXT: Size: 1
+; CHECK-NEXT: Size: 0
 ; CHECK-NEXT: Binding: Global
 ; CHECK-NEXT: Type: Function
 ; CHECK-NEXT: Other: 0
-; CHECK-NEXT: Section: .text
+; CHECK-NEXT: Section: Undefined
 
 target triple = "x86_64-unknown-linux-gnu"
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
@@ -18,4 +18,3 @@
 define void @foo() comdat {
   ret void
 }
-
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -1681,7 +1681,8 @@
 
   for (InputFile *file : lto->compile()) {
     auto *obj = cast<ObjFile<ELFT>>(file);
-    obj->parse(/*ignoreComdats=*/true);
+    // We need comdat de-duplication for thinLTO
+    obj->parse(/*ignoreComdats=*/false);
     for (Symbol *sym : obj->getGlobalSymbols())
       sym->parseSymbolVersion();
     objectFiles.push_back(file);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80255.265069.patch
Type: text/x-patch
Size: 1682 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200519/b98dbc07/attachment-0001.bin>


More information about the llvm-commits mailing list