[PATCH] D40236: COFF: Stop requiring comdat sections to have an external leader to participate in ICF.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 20 10:53:38 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL318682: COFF: Stop requiring comdat sections to have an external leader to participate… (authored by pcc).

Changed prior to commit:
  https://reviews.llvm.org/D40236?vs=123541&id=123624#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40236

Files:
  lld/trunk/COFF/ICF.cpp
  lld/trunk/test/COFF/icf-executable.s


Index: lld/trunk/COFF/ICF.cpp
===================================================================
--- lld/trunk/COFF/ICF.cpp
+++ lld/trunk/COFF/ICF.cpp
@@ -82,10 +82,8 @@
   if (!C->isCOMDAT() || !C->isLive() || Writable)
     return false;
 
-  // Code sections with external symbols are eligible.
-  bool Global = C->Sym && C->Sym->isExternal();
-  bool Executable = C->getPermissions() & llvm::COFF::IMAGE_SCN_MEM_EXECUTE;
-  if (Global && Executable)
+  // Code sections are eligible.
+  if (C->getPermissions() & llvm::COFF::IMAGE_SCN_MEM_EXECUTE)
     return true;
 
   // .xdata unwind info sections are eligble.
Index: lld/trunk/test/COFF/icf-executable.s
===================================================================
--- lld/trunk/test/COFF/icf-executable.s
+++ lld/trunk/test/COFF/icf-executable.s
@@ -0,0 +1,18 @@
+# RUN: llvm-mc -triple=x86_64-windows-msvc %s -filetype=obj -o %t.obj
+# RUN: lld-link -entry:main %t.obj -out:%t.exe -verbose 2>&1 | FileCheck %s
+
+# CHECK: Selected internal
+# CHECK:   Removed f2
+
+.section .text,"xr",one_only,internal
+internal:
+.globl main
+main:
+call f2
+ret
+
+.section .text,"xr",one_only,f2
+.globl f2
+f2:
+call main
+ret


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40236.123624.patch
Type: text/x-patch
Size: 1185 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171120/93c78428/attachment.bin>


More information about the llvm-commits mailing list