[PATCH] D30365: ELF ICF: Merge only functions.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 24 17:09:44 PST 2017
ruiu updated this revision to Diff 89755.
ruiu added a comment.
- Updated the test to be more realistic -- now it is a data section rather than a text section without x bit.
https://reviews.llvm.org/D30365
Files:
lld/ELF/ICF.cpp
lld/test/ELF/icf8.s
Index: lld/test/ELF/icf8.s
===================================================================
--- /dev/null
+++ lld/test/ELF/icf8.s
@@ -0,0 +1,19 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: ld.lld %t -o %t2 --icf=all --verbose | FileCheck %s
+
+# CHECK-NOT: selected .data.d1
+# CHECK-NOT: selected .data.d2
+
+.globl _start, d1, d2
+_start:
+ ret
+
+.section .data.f1, "a"
+d1:
+ .byte 1
+
+.section .data.f2, "a"
+d2:
+ .byte 1
Index: lld/ELF/ICF.cpp
===================================================================
--- lld/ELF/ICF.cpp
+++ lld/ELF/ICF.cpp
@@ -163,8 +163,8 @@
// .init and .fini contains instructions that must be executed to
// initialize and finalize the process. They cannot and should not
// be merged.
- return S->Live && (S->Flags & SHF_ALLOC) && !(S->Flags & SHF_WRITE) &&
- S->Name != ".init" && S->Name != ".fini";
+ return S->Live && (S->Flags & SHF_ALLOC) && (S->Flags & SHF_EXECINSTR) &&
+ !(S->Flags & SHF_WRITE) && S->Name != ".init" && S->Name != ".fini";
}
// Split an equivalence class into smaller classes.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30365.89755.patch
Type: text/x-patch
Size: 1135 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170225/ee29c47e/attachment.bin>
More information about the llvm-commits
mailing list