diff options
author | Sam Clegg <sbc@chromium.org> | 2017-07-10 18:36:34 +0000 |
---|---|---|
committer | Sam Clegg <sbc@chromium.org> | 2017-07-10 18:36:34 +0000 |
commit | b03c2b4b0984ce2ea131fb1f06aae6938222498f (patch) | |
tree | d12076a32adf8e930c53d56d19936d7cc52364e1 | |
parent | 0ac065f3184266322e1545982fa98eab832bf029 (diff) | |
download | bcm5719-llvm-b03c2b4b0984ce2ea131fb1f06aae6938222498f.tar.gz bcm5719-llvm-b03c2b4b0984ce2ea131fb1f06aae6938222498f.zip |
[WebAssembly] Use the correct size for MCFillFragment
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
-rw-r--r-- | llvm/lib/MC/WasmObjectWriter.cpp | 2 | ||||
-rw-r--r-- | llvm/test/MC/WebAssembly/array-fill.ll | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp index 769dbb810ed..a38d9339880 100644 --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -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(); diff --git a/llvm/test/MC/WebAssembly/array-fill.ll b/llvm/test/MC/WebAssembly/array-fill.ll new file mode 100644 index 00000000000..4feabc0748e --- /dev/null +++ b/llvm/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 } + +@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 |