From: Fangrui Song Date: Wed, 19 Jul 2023 18:28:47 +0000 (-0700) Subject: [ELF] splitNonStrings: switch to xxh3_64bits X-Git-Tag: upstream/17.0.6~1109 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eabaf3ba853084a3604745054a2a88fa17d01b26;p=platform%2Fupstream%2Fllvm.git [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. --- diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index c5101e0..ffb0565 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -1263,7 +1263,7 @@ void MergeInputSection::splitNonStrings(ArrayRef 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 diff --git a/lld/test/ELF/icf-merged-sections.s b/lld/test/ELF/icf-merged-sections.s index 480feb9..d1d9dfe 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",@progbits,4 rodata4: diff --git a/lld/test/ELF/linkerscript/merge-output-sections.s b/lld/test/ELF/linkerscript/merge-output-sections.s index b15596f..77670d9 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 different 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 6c6ee30..15304b1 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 8dafe16..686b2ef 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",@progbits,8,unique,0 .align 4 diff --git a/lld/test/ELF/merge-entsize2.s b/lld/test/ELF/merge-entsize2.s index 25036be..217ca10 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",@progbits,4,unique,0 .align 2 diff --git a/lld/test/ELF/merge.s b/lld/test/ELF/merge.s index 35306b8..4cba53f 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",@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