[PATCH] D35090: [WebAssembly] Use the correct size for MCFillFragment

Dan Gohman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 6 14:45:33 PDT 2017


sunfish created this revision.
Herald added subscribers: aheejin, jgravelle-google, dschuff, jfb.

When implementing MCFillFragment, use the size of the fragment, rather than the size of the section.


Repository:
  rL LLVM

https://reviews.llvm.org/D35090

Files:
  lib/MC/WasmObjectWriter.cpp
  test/MC/WebAssembly/array-fill.ll


Index: test/MC/WebAssembly/array-fill.ll
===================================================================
--- /dev/null
+++ test/MC/WebAssembly/array-fill.ll
@@ -0,0 +1,14 @@
+; RUN: llc -filetype=obj %s -o - | obj2yaml | FileCheck %s
+; PR33624
+
+source_filename = "ws.c"
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown-wasm"
+
+%struct.bd = type { i8 }
+
+ at gBd = hidden global [2 x %struct.bd] [%struct.bd { i8 1 }, %struct.bd { i8 2 }], align 1
+
+; CHECK:  - Type:            DATA
+; CHECK:        Content:         '0102'
+; CHECK:    DataSize:        2
Index: lib/MC/WasmObjectWriter.cpp
===================================================================
--- lib/MC/WasmObjectWriter.cpp
+++ lib/MC/WasmObjectWriter.cpp
@@ -1189,7 +1189,7 @@
                                                  Align->getMaxBytesToEmit());
           DataBytes.resize(Size, Value);
         } else if (auto *Fill = dyn_cast<MCFillFragment>(&Frag)) {
-          DataBytes.insert(DataBytes.end(), Size, Fill->getValue());
+          DataBytes.insert(DataBytes.end(), Fill->getSize(), Fill->getValue());
         } else {
           const auto &DataFrag = cast<MCDataFragment>(Frag);
           const SmallVectorImpl<char> &Contents = DataFrag.getContents();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35090.105538.patch
Type: text/x-patch
Size: 1295 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170706/a9be4abd/attachment.bin>


More information about the llvm-commits mailing list