Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lld][WebAssembly] Initial support merging string data
This change adds support for a new WASM_SEG_FLAG_STRINGS flag in the object format which works in a similar fashion to SHF_STRINGS in the ELF world. Unlike the ELF linker this support is currently limited: - No support for SHF_MERGE (non-string merging) - Always do full tail merging ("lo" can be merged with "hello") - Only support single byte strings (p2align 0) Like the ELF linker merging is only performed at `-O1` and above. This fixes part of https://bugs.llvm.org/show_bug.cgi?id=48828, although crucially it doesn't not currently support debug sections because they are not represented by data segments (they are custom sections) Differential Revision: https://reviews.llvm.org/D97657
- Loading branch information
Showing
25 changed files
with
559 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o | ||
// RUN: wasm-ld -O2 %t.o -o %t.wasm --no-gc-sections --no-entry | ||
// RUN: obj2yaml %t.wasm | FileCheck %s --check-prefixes=COMMON,MERGE | ||
// RUN: wasm-ld -O0 %t.o -o %t2.wasm --no-gc-sections --no-entry | ||
// RUN: obj2yaml %t2.wasm | FileCheck --check-prefixes=COMMON,NOMERGE %s | ||
|
||
.section .rodata1,"S",@ | ||
.asciz "abc" | ||
foo: | ||
.ascii "a" | ||
.size foo, 1 | ||
bar: | ||
.asciz "bc" | ||
.asciz "bc" | ||
.size bar, 4 | ||
|
||
.globl foo | ||
.globl bar | ||
.export_name foo, foo | ||
.export_name bar, bar | ||
|
||
// COMMON: - Type: GLOBAL | ||
// COMMON-NEXT: Globals: | ||
// COMMON-NEXT: - Index: 0 | ||
// COMMON-NEXT: Type: I32 | ||
// COMMON-NEXT: Mutable: true | ||
// COMMON-NEXT: InitExpr: | ||
// COMMON-NEXT: Opcode: I32_CONST | ||
// COMMON-NEXT: Value: 66576 | ||
// COMMON-NEXT: - Index: 1 | ||
// COMMON-NEXT: Type: I32 | ||
// COMMON-NEXT: Mutable: false | ||
// COMMON-NEXT: InitExpr: | ||
// COMMON-NEXT: Opcode: I32_CONST | ||
// MERGE-NEXT: Value: 1024 | ||
// NOMERGE-NEXT: Value: 1028 | ||
// COMMON-NEXT: - Index: 2 | ||
// COMMON-NEXT: Type: I32 | ||
// COMMON-NEXT: Mutable: false | ||
// COMMON-NEXT: InitExpr: | ||
// COMMON-NEXT: Opcode: I32_CONST | ||
// MERGE-NEXT: Value: 1025 | ||
// NOMERGE-NEXT: Value: 1029 | ||
// COMMON-NEXT: - Type: EXPORT | ||
// COMMON-NEXT: Exports: | ||
// COMMON-NEXT: - Name: memory | ||
// COMMON-NEXT: Kind: MEMORY | ||
// COMMON-NEXT: Index: 0 | ||
// COMMON-NEXT: - Name: foo | ||
// COMMON-NEXT: Kind: GLOBAL | ||
// COMMON-NEXT: Index: 1 | ||
// COMMON-NEXT: - Name: bar | ||
// COMMON-NEXT: Kind: GLOBAL | ||
// COMMON-NEXT: Index: 2 | ||
|
||
// | ||
// COMMON: - Type: DATA | ||
// COMMON-NEXT: Segments: | ||
// COMMON-NEXT: - SectionOffset: 7 | ||
// COMMON-NEXT: InitFlags: 0 | ||
// COMMON-NEXT: Offset: | ||
// COMMON-NEXT: Opcode: I32_CONST | ||
// COMMON-NEXT: Value: 1024 | ||
// MERGE-NEXT: Content: '61626300' | ||
// NOMERGE-NEXT: Content: '6162630061626300626300' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.