[lld] eabaf3b - [ELF] splitNonStrings: switch to xxh3_64bits
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 19 11:29:02 PDT 2023
Author: Fangrui Song
Date: 2023-07-19T11:28:47-07:00
New Revision: eabaf3ba853084a3604745054a2a88fa17d01b26
URL: https://github.com/llvm/llvm-project/commit/eabaf3ba853084a3604745054a2a88fa17d01b26
DIFF: https://github.com/llvm/llvm-project/commit/eabaf3ba853084a3604745054a2a88fa17d01b26.diff
LOG: [ELF] splitNonStrings: switch to xxh3_64bits
This is primarily used for .rodata.cst* duplicate elimination. The
sections are usually much smaller than .debug_str (D154813), so the
speedup is negligible. We do this switch for consistency as we want to
eliminate xxh64 in lld.
Added:
Modified:
lld/ELF/InputSection.cpp
lld/test/ELF/icf-merged-sections.s
lld/test/ELF/linkerscript/merge-output-sections.s
lld/test/ELF/merge-align.s
lld/test/ELF/merge-align2.s
lld/test/ELF/merge-entsize2.s
lld/test/ELF/merge.s
Removed:
################################################################################
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index c5101e0e4ad25a..ffb056565b9219 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -1263,7 +1263,7 @@ void MergeInputSection::splitNonStrings(ArrayRef<uint8_t> data,
pieces.resize_for_overwrite(size / entSize);
for (size_t i = 0, j = 0; i != size; i += entSize, j++)
- pieces[j] = {i, (uint32_t)xxHash64(data.slice(i, entSize)), live};
+ pieces[j] = {i, (uint32_t)xxh3_64bits(data.slice(i, entSize)), live};
}
template <class ELFT>
diff --git a/lld/test/ELF/icf-merged-sections.s b/lld/test/ELF/icf-merged-sections.s
index 480feb9ab60544..d1d9dfe274f246 100644
--- a/lld/test/ELF/icf-merged-sections.s
+++ b/lld/test/ELF/icf-merged-sections.s
@@ -22,7 +22,7 @@
# CHECK-NEXT: AddressAlignment: 1
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: SectionData (
-# CHECK-NEXT: 0000: 67452301 10325476 67452301 10325476
+# CHECK-NEXT: 0000: 10325476 67452301 67452301 10325476
.section .rodata.cst4,"aM", at progbits,4
rodata4:
diff --git a/lld/test/ELF/linkerscript/merge-output-sections.s b/lld/test/ELF/linkerscript/merge-output-sections.s
index b15596f84cf665..77670d9b03f41a 100644
--- a/lld/test/ELF/linkerscript/merge-output-sections.s
+++ b/lld/test/ELF/linkerscript/merge-output-sections.s
@@ -7,7 +7,7 @@
# RUN: llvm-readelf -x .rodata %t | FileCheck --check-prefix=SAME %s --implicit-check-not=section
# SAME: section '.rodata':
-# SAME-NEXT: 0x00000000 01000200 0300
+# SAME-NEXT: 0x00000000 03000100 0200
## SHF_MERGE sections with
diff erent output sections cannot be merged.
# RUN: echo 'SECTIONS { \
@@ -18,7 +18,7 @@
# RUN: llvm-readelf -x .rodata.foo -x .rodata.bar %t2 | FileCheck --check-prefix=DIFF %s --implicit-check-not=section
# DIFF: section '.rodata.foo':
-# DIFF-NEXT: 0x00000000 01000200 0300
+# DIFF-NEXT: 0x00000000 03000100 0200
# DIFF: section '.rodata.bar':
# DIFF-NEXT: 0x00000006 0100
diff --git a/lld/test/ELF/merge-align.s b/lld/test/ELF/merge-align.s
index 6c6ee30ab494e4..15304b1a129dc2 100644
--- a/lld/test/ELF/merge-align.s
+++ b/lld/test/ELF/merge-align.s
@@ -29,6 +29,6 @@
// CHECK-NEXT: AddressAlignment: 16
// CHECK-NEXT: EntrySize: 1
// CHECK-NEXT: SectionData (
-// CHECK-NEXT: 0000: 42000000 00000000 00000000 00000000 |
-// CHECK-NEXT: 0010: 41 |
+// CHECK-NEXT: 0000: 41000000 00000000 00000000 00000000 |
+// CHECK-NEXT: 0010: 42 |
// CHECK-NEXT: )
diff --git a/lld/test/ELF/merge-align2.s b/lld/test/ELF/merge-align2.s
index 8dafe161bdd715..686b2ef7ba71c6 100644
--- a/lld/test/ELF/merge-align2.s
+++ b/lld/test/ELF/merge-align2.s
@@ -16,8 +16,8 @@
# SEC: Name Type {{.*}} Size ES Flg Lk Inf Al
# SEC: .cst8 PROGBITS {{.*}} 000018 08 AM 0 0 8
-# CHECK: 0x{{[0-9a-f]+}} 02000000 00000000 01000000 00000000
-# CHECK-NEXT: 0x{{[0-9a-f]+}} 03000000 00000000
+# CHECK: [[#%x,]] 01000000 00000000 02000000 00000000
+# CHECK-NEXT: [[#%x,]] 03000000 00000000
.section .cst8,"aM", at progbits,8,unique,0
.align 4
diff --git a/lld/test/ELF/merge-entsize2.s b/lld/test/ELF/merge-entsize2.s
index 25036beeea8e83..217ca10821e5a0 100644
--- a/lld/test/ELF/merge-entsize2.s
+++ b/lld/test/ELF/merge-entsize2.s
@@ -18,8 +18,8 @@
# SEC: .cst PROGBITS {{.*}} 000020 00 AM 0 0 8
# HEX: Hex dump of section '.cst':
-# HEX-NEXT: 0x{{[0-9a-f]+}} 01000000 00000000 02000000 00000000
-# HEX-NEXT: 0x{{[0-9a-f]+}} 01000000 00000000 03000000 00000000
+# HEX-NEXT: [[#%x,]] 00000000 02000000 01000000 00000000
+# HEX-NEXT: [[#%x,]] 01000000 00000000 03000000 00000000
.section .cst,"aM", at progbits,4,unique,0
.align 2
diff --git a/lld/test/ELF/merge.s b/lld/test/ELF/merge.s
index 35306b86818dc7..4cba53fb47a329 100644
--- a/lld/test/ELF/merge.s
+++ b/lld/test/ELF/merge.s
@@ -3,17 +3,17 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/merge.s -o %t2.o
// RUN: ld.lld %t.o %t2.o -o %t
// RUN: llvm-readelf -S -s -x .mysec %t | FileCheck %s
-// RUN: llvm-objdump --no-print-imm-hex -d %t | FileCheck --check-prefix=DISASM %s
+// RUN: llvm-objdump -d %t | FileCheck --check-prefix=DISASM %s
// CHECK: Name Type Address Off Size ES Flg Lk Inf Al
// CHECK: .mysec PROGBITS 0000000000200120 000120 000008 04 AM 0 0 4
-// CHECK-DAG: 0000000000200124 0 NOTYPE LOCAL DEFAULT 1 bar
-// CHECK-DAG: 0000000000200124 0 NOTYPE LOCAL DEFAULT 1 zed
-// CHECK-DAG: 0000000000200124 0 NOTYPE LOCAL HIDDEN 1 foo
+// CHECK-DAG: 0000000000200120 0 NOTYPE LOCAL DEFAULT 1 bar
+// CHECK-DAG: 0000000000200120 0 NOTYPE LOCAL DEFAULT 1 zed
+// CHECK-DAG: 0000000000200120 0 NOTYPE LOCAL HIDDEN 1 foo
// CHECK: Hex dump of section '.mysec':
-// CHECK-NEXT: 0x00200120 10000000 42000000
+// CHECK-NEXT: 0x00200120 42000000 10000000
.section .mysec,"aM", at progbits,4
.align 4
@@ -35,37 +35,37 @@ _start:
// DISASM-NEXT: <_start>:
movl .mysec, %eax
-// addr(0x10) = 2097440
-// DISASM-NEXT: movl 2097440, %eax
+// addr(0x10)
+// DISASM-NEXT: movl 0x200124, %eax
movl .mysec+7, %eax
-// addr(0x42) + 3 = 2097444 + 3 = 2097447
-// DISASM-NEXT: movl 2097447, %eax
+// addr(0x42) + 3
+// DISASM-NEXT: movl 0x200123, %eax
movl .mysec+8, %eax
-// addr(0x42) = 2097444
-// DISASM-NEXT: movl 2097444, %eax
+// addr(0x42)
+// DISASM-NEXT: movl 0x200120, %eax
movl bar+7, %eax
-// addr(0x42) + 7 = 2097444 + 7 = 2097451
-// DISASM-NEXT: movl 2097451, %eax
+// addr(0x42) + 3
+// DISASM-NEXT: movl 0x200127, %eax
movl bar+8, %eax
-// addr(0x42) + 8 = 2097444 + 8 = 2097452
-// DISASM-NEXT: movl 2097452, %eax
+// addr(0x42)
+// DISASM-NEXT: movl 0x200128, %eax
movl foo, %eax
-// addr(0x42) = 2097444
-// DISASM-NEXT: movl 2097444, %eax
+// addr(0x42)
+// DISASM-NEXT: movl 0x200120, %eax
movl foo+7, %eax
-// addr(0x42) + 7 = = 2097444 + 7 = 2097451
-// DISASM-NEXT: movl 2097451, %eax
+// addr(0x42) + 7
+// DISASM-NEXT: movl 0x200127, %eax
movl foo+8, %eax
-// addr(0x42) + 8 = = 2097444 + 8 = 2097452
-// DISASM-NEXT: movl 2097452, %eax
+// addr(0x42) + 8
+// DISASM-NEXT: movl 0x200128, %eax
// From the other file: movl .mysec, %eax
-// addr(0x42) = 2097444
-// DISASM-NEXT: movl 2097444, %eax
+// addr(0x42)
+// DISASM-NEXT: movl 0x200120, %eax
More information about the llvm-commits
mailing list