Skip to content

Commit

Permalink
[WebAssembly] Use the correct size for MCFillFragment
Browse files Browse the repository at this point in the history
Summary: When implementing MCFillFragment, use the size of the fragment,
rather than the size of the section.

Patch by Dan Gohman

Differential Revision: https://reviews.llvm.org/D35090

llvm-svn: 307565
  • Loading branch information
sbc100 committed Jul 10, 2017
1 parent 0ac065f commit b03c2b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/lib/MC/WasmObjectWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm,
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();
Expand Down
14 changes: 14 additions & 0 deletions llvm/test/MC/WebAssembly/array-fill.ll
Original file line number Diff line number Diff line change
@@ -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 }

@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

0 comments on commit b03c2b4

Please sign in to comment.