[PATCH] D50424: [WebAssembly] Group rodata into a single output segment

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 7 21:02:12 PDT 2018


sbc100 created this revision.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, dschuff.

Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D50424

Files:
  test/wasm/data-segment-merging.ll
  wasm/Writer.cpp


Index: wasm/Writer.cpp
===================================================================
--- wasm/Writer.cpp
+++ wasm/Writer.cpp
@@ -930,6 +930,8 @@
     return ".data";
   if (Name.startswith(".bss."))
     return ".bss";
+  if (Name.startswith(".rodata."))
+    return ".rodata";
   return Name;
 }
 
Index: test/wasm/data-segment-merging.ll
===================================================================
--- test/wasm/data-segment-merging.ll
+++ test/wasm/data-segment-merging.ll
@@ -5,44 +5,27 @@
 @c = hidden global [9 x i8] c"whatever\00", align 1
 @d = hidden global i32 42, align 4
 
+ at e = private constant [9 x i8] c"constant\00", align 1
+ at f = private constant i8 43, align 4
+
 ; RUN: llc -filetype=obj %s -o %t.data-segment-merging.o
 
 ; RUN: wasm-ld -no-gc-sections --no-entry -o %t.merged.wasm %t.data-segment-merging.o
 ; RUN: obj2yaml %t.merged.wasm | FileCheck %s --check-prefix=MERGE
-; MERGE:       - Type:            DATA
-; MERGE-NEXT:    Segments:
-; MERGE-NEXT:      - SectionOffset:   7
-; MERGE-NEXT:        MemoryIndex:     0
-; MERGE-NEXT:        Offset:
-; MERGE-NEXT:          Opcode:          I32_CONST
-; MERGE-NEXT:          Value:           1024
-; MERGE-NEXT:        Content:         68656C6C6F00676F6F6462796500776861746576657200002A000000
+; MERGE:   - Type:            DATA
+; MERGE:     Segments:
+; MERGE:        Content:         68656C6C6F00676F6F6462796500776861746576657200002A000000
+; MERGE:        Content:         636F6E7374616E74000000002B
+; MERGE-NOT:    Content:
 
 ; RUN: wasm-ld -no-gc-sections --no-entry --no-merge-data-segments -o %t.separate.wasm %t.data-segment-merging.o
 ; RUN: obj2yaml %t.separate.wasm | FileCheck %s --check-prefix=SEPARATE
-; SEPARATE:       - Type:            DATA
-; SEPARATE-NEXT:    Segments:
-; SEPARATE-NEXT:      - SectionOffset:   7
-; SEPARATE-NEXT:        MemoryIndex:     0
-; SEPARATE-NEXT:        Offset:
-; SEPARATE-NEXT:          Opcode:          I32_CONST
-; SEPARATE-NEXT:          Value:           1024
-; SEPARATE-NEXT:        Content:         68656C6C6F00
-; SEPARATE-NEXT:      - SectionOffset:   19
-; SEPARATE-NEXT:        MemoryIndex:     0
-; SEPARATE-NEXT:        Offset:
-; SEPARATE-NEXT:          Opcode:          I32_CONST
-; SEPARATE-NEXT:          Value:           1030
-; SEPARATE-NEXT:        Content:         676F6F6462796500
-; SEPARATE-NEXT:      - SectionOffset:   33
-; SEPARATE-NEXT:        MemoryIndex:     0
-; SEPARATE-NEXT:        Offset:
-; SEPARATE-NEXT:          Opcode:          I32_CONST
-; SEPARATE-NEXT:          Value:           1038
-; SEPARATE-NEXT:        Content:         '776861746576657200'
-; SEPARATE-NEXT:      - SectionOffset:   48
-; SEPARATE-NEXT:        MemoryIndex:     0
-; SEPARATE-NEXT:        Offset:
-; SEPARATE-NEXT:          Opcode:          I32_CONST
-; SEPARATE-NEXT:          Value:           1048
-; SEPARATE-NEXT:        Content:         2A000000
+; SEPARATE:   - Type:            DATA
+; SEPARATE:     Segments:
+; SEPARATE:        Content:         68656C6C6F00
+; SEPARATE:        Content:         676F6F6462796500
+; SEPARATE:        Content:         '776861746576657200'
+; SEPARATE:        Content:         2A000000
+; SEPARATE:        Content:         636F6E7374616E7400
+; SEPARATE:        Content:         2B
+; SEPARATE-NOT:    Content:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50424.159641.patch
Type: text/x-patch
Size: 3310 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180808/e25ce415/attachment.bin>


More information about the llvm-commits mailing list