Skip to content

Commit eccc816

Browse files
fitzgenllvmbot
authored andcommitted
[lld][WebAssembly] Support for the custom-page-sizes WebAssembly proposal (#128942)
This commit adds support for WebAssembly's custom-page-sizes proposal to `wasm-ld`. An overview of the proposal can be found [here](https://github.com/WebAssembly/custom-page-sizes/blob/main/proposals/custom-page-sizes/Overview.md). In a sentence, it allows customizing a Wasm memory's page size, enabling Wasm to target environments with less than 64KiB of memory (the default Wasm page size) available for Wasm memories. This commit contains the following: * Adds a `--page-size=N` CLI flag to `wasm-ld` for configuring the linked Wasm binary's linear memory's page size. * When the page size is configured to a non-default value, then the final Wasm binary will use the encodings defined in the custom-page-sizes proposal to declare the linear memory's page size. * Defines a `__wasm_first_page_end` symbol, whose address points to the first page in the Wasm linear memory, a.k.a. is the Wasm memory's page size. This allows writing code that is compatible with any page size, and doesn't require re-compiling its object code. At the same time, because it just lowers to a constant rather than a memory access or something, it enables link-time optimization. * Adds tests for these new features. r? @sbc100 cc @sunfishcode (cherry picked from commit 6018930)
1 parent 794ba17 commit eccc816

23 files changed

+116
-25
lines changed

Diff for: lld/test/wasm/initial-heap.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ RUN: not wasm-ld %t.o -o %t5.wasm --stack-first -z stack-size=131072 --initial-h
2020
RUN: not wasm-ld %t.o -o %t6.wasm --stack-first -z stack-size=65536 --initial-heap=131072 --initial-memory=131072 2>&1 | FileCheck %s --check-prefix INITIAL-MEMORY-TOO-SMALL
2121
RUN: not wasm-ld %t.o -o %t7.wasm --stack-first -z stack-size=65536 --initial-heap=131072 --max-memory=131072 2>&1 | FileCheck %s --check-prefix MAX-MEMORY-TOO-SMALL
2222

23-
NOT-PAGE-MULTIPLE: initial heap must be 65536-byte aligned
23+
NOT-PAGE-MULTIPLE: initial heap must be aligned to the page size (65536 bytes)
2424
TOO-LARGE-BY-ITSELF: initial heap too large, cannot be greater than 4294901760
2525
TOO-LARGE-WITH-STACK: initial heap too large, cannot be greater than 4294836224
2626
INITIAL-MEMORY-TOO-SMALL: initial memory too small, 196608 bytes needed

Diff for: lld/test/wasm/mutable-global-exports.s

+3-1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ _start:
101101
# CHECK-ALL-NEXT: - Name: __table_base
102102
# CHECK-ALL-NEXT: Kind: GLOBAL
103103
# CHECK-ALL-NEXT: Index: 10
104+
# CHECK-ALL-NEXT: - Name: __wasm_first_page_end
105+
# CHECK-ALL-NEXT: Kind: GLOBAL
106+
# CHECK-ALL-NEXT: Index: 11
104107
# CHECK-ALL-NEXT: - Type: CODE
105108

106109
# CHECK-ALL: Name: target_features
@@ -110,4 +113,3 @@ _start:
110113
# CHECK-ALL-NEXT: - Prefix: USED
111114
# CHECK-ALL-NEXT: Name: mutable-globals
112115
# CHECK-ALL-NEXT: ...
113-

Diff for: lld/test/wasm/page-size.s

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o
2+
3+
.globl _start
4+
_start:
5+
.functype _start () -> (i32)
6+
i32.const __wasm_first_page_end
7+
end_function
8+
9+
# Add a symbol to smoke test that `__wasm_first_page_end` is absolute and not
10+
# relative to other data.
11+
.section .data.foo,"",@
12+
foo:
13+
.int32 0x11111111
14+
.size foo, 4
15+
16+
# RUN: wasm-ld -no-gc-sections -o %t.custom.wasm %t.o --page-size=1
17+
# RUN: obj2yaml %t.custom.wasm | FileCheck %s --check-prefix=CHECK-CUSTOM
18+
19+
# CHECK-CUSTOM: - Type: MEMORY
20+
# CHECK-CUSTOM-NEXT: Memories:
21+
# CHECK-CUSTOM-NEXT: - Flags: [ HAS_PAGE_SIZE ]
22+
# CHECK-CUSTOM-NEXT: Minimum: 0x10410
23+
# CHECK-CUSTOM-NEXT: PageSize: 0x1
24+
25+
# RUN: llvm-objdump --disassemble-symbols=_start %t.custom.wasm | FileCheck %s --check-prefix=CHECK-CUSTOM-DIS
26+
27+
# CHECK-CUSTOM-DIS: <_start>:
28+
# CHECK-CUSTOM-DIS: i32.const 1
29+
# CHECK-CUSTOM-DIS-NEXT: end
30+
31+
# RUN: wasm-ld -no-gc-sections -o %t.default.wasm %t.o
32+
# RUN: obj2yaml %t.default.wasm | FileCheck %s --check-prefix=CHECK-DEFAULT
33+
34+
# CHECK-DEFAULT: - Type: MEMORY
35+
# CHECK-DEFAULT-NEXT: Memories:
36+
# CHECK-DEFAULT-NEXT: Minimum: 0x2
37+
# CHECK-DEFAULT-NEXT: - Type: GLOBAL
38+
39+
# RUN: llvm-objdump --disassemble-symbols=_start %t.default.wasm | FileCheck %s --check-prefix=CHECK-DEFAULT-DIS
40+
41+
# CHECK-DEFAULT-DIS: <_start>:
42+
# CHECK-DEFAULT-DIS: i32.const 65536
43+
# CHECK-DEFAULT-DIS-NEXT: end

Diff for: lld/test/wasm/shared-memory.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Sections:
5656
Flags: [ ]
5757
...
5858

59-
# SHARED-UNALIGNED: maximum memory must be 65536-byte aligned{{$}}
59+
# SHARED-UNALIGNED: maximum memory must be aligned to the page size (65536 bytes)
6060

6161
# SHARED-NO-ATOMICS: 'atomics' feature must be used in order to use shared memory
6262

Diff for: lld/wasm/Config.h

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ struct Config {
9494
// runtime).
9595
uint64_t tableBase;
9696
uint64_t zStackSize;
97+
uint64_t pageSize;
9798
unsigned ltoPartitions;
9899
unsigned ltoo;
99100
llvm::CodeGenOptLevel ltoCgo;

Diff for: lld/wasm/Driver.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,10 @@ static void readConfigs(opt::InputArgList &args) {
642642
ctx.arg.maxMemory = args::getInteger(args, OPT_max_memory, 0);
643643
ctx.arg.noGrowableMemory = args.hasArg(OPT_no_growable_memory);
644644
ctx.arg.zStackSize =
645-
args::getZOptionValue(args, OPT_z, "stack-size", WasmPageSize);
645+
args::getZOptionValue(args, OPT_z, "stack-size", WasmDefaultPageSize);
646+
ctx.arg.pageSize = args::getInteger(args, OPT_page_size, WasmDefaultPageSize);
647+
if (ctx.arg.pageSize != 1 && ctx.arg.pageSize != WasmDefaultPageSize)
648+
error("--page_size=N must be either 1 or 65536");
646649

647650
// -Bdynamic by default if -pie or -shared is specified.
648651
if (ctx.arg.pie || ctx.arg.shared)
@@ -999,6 +1002,11 @@ static void createOptionalSymbols() {
9991002
WasmSym::definedTableBase = symtab->addOptionalDataSymbol("__table_base");
10001003
}
10011004

1005+
WasmSym::firstPageEnd =
1006+
symtab->addOptionalDataSymbol("__wasm_first_page_end");
1007+
if (WasmSym::firstPageEnd)
1008+
WasmSym::firstPageEnd->setVA(ctx.arg.pageSize);
1009+
10021010
// For non-shared memory programs we still need to define __tls_base since we
10031011
// allow object files built with TLS to be linked into single threaded
10041012
// programs, and such object files can contain references to this symbol.

Diff for: lld/wasm/Options.td

+3
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ def import_table: FF<"import-table">,
230230
def initial_heap: JJ<"initial-heap=">,
231231
HelpText<"Initial size of the heap">;
232232

233+
def page_size: JJ<"page-size=">,
234+
HelpText<"The Wasm page size (Defaults to 65536)">;
235+
233236
def initial_memory: JJ<"initial-memory=">,
234237
HelpText<"Initial size of the linear memory">;
235238

Diff for: lld/wasm/SymbolTable.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ Symbol *SymbolTable::addUndefinedTag(StringRef name,
792792
}
793793

794794
TableSymbol *SymbolTable::createUndefinedIndirectFunctionTable(StringRef name) {
795-
WasmLimits limits{0, 0, 0}; // Set by the writer.
795+
WasmLimits limits{0, 0, 0, 0}; // Set by the writer.
796796
WasmTableType *type = make<WasmTableType>();
797797
type->ElemType = ValType::FUNCREF;
798798
type->Limits = limits;
@@ -807,7 +807,7 @@ TableSymbol *SymbolTable::createUndefinedIndirectFunctionTable(StringRef name) {
807807

808808
TableSymbol *SymbolTable::createDefinedIndirectFunctionTable(StringRef name) {
809809
const uint32_t invalidIndex = -1;
810-
WasmLimits limits{0, 0, 0}; // Set by the writer.
810+
WasmLimits limits{0, 0, 0, 0}; // Set by the writer.
811811
WasmTableType type{ValType::FUNCREF, limits};
812812
WasmTable desc{invalidIndex, type, name};
813813
InputTable *table = make<InputTable>(desc, nullptr);

Diff for: lld/wasm/Symbols.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ DefinedFunction *WasmSym::applyGlobalRelocs;
8484
DefinedFunction *WasmSym::applyTLSRelocs;
8585
DefinedFunction *WasmSym::applyGlobalTLSRelocs;
8686
DefinedFunction *WasmSym::initTLS;
87+
DefinedData *WasmSym::firstPageEnd;
8788
DefinedFunction *WasmSym::startFunction;
8889
DefinedData *WasmSym::dsoHandle;
8990
DefinedData *WasmSym::dataEnd;

Diff for: lld/wasm/Symbols.h

+4
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,10 @@ struct WasmSym {
577577
static DefinedData *heapBase;
578578
static DefinedData *heapEnd;
579579

580+
// __wasm_first_page_end
581+
// A symbol whose address is the end of the first page in memory (if any).
582+
static DefinedData *firstPageEnd;
583+
580584
// __wasm_init_memory_flag
581585
// Symbol whose contents are nonzero iff memory has already been initialized.
582586
static DefinedData *initMemoryFlag;

Diff for: lld/wasm/SyntheticSections.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,14 @@ void MemorySection::writeBody() {
360360
flags |= WASM_LIMITS_FLAG_IS_SHARED;
361361
if (ctx.arg.is64.value_or(false))
362362
flags |= WASM_LIMITS_FLAG_IS_64;
363+
if (ctx.arg.pageSize != WasmDefaultPageSize)
364+
flags |= WASM_LIMITS_FLAG_HAS_PAGE_SIZE;
363365
writeUleb128(os, flags, "memory limits flags");
364366
writeUleb128(os, numMemoryPages, "initial pages");
365367
if (hasMax)
366368
writeUleb128(os, maxMemoryPages, "max pages");
369+
if (ctx.arg.pageSize != WasmDefaultPageSize)
370+
writeUleb128(os, llvm::Log2_64(ctx.arg.pageSize), "page size");
367371
}
368372

369373
void TagSection::writeBody() {

Diff for: lld/wasm/Writer.cpp

+13-10
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,12 @@ static void setGlobalPtr(DefinedGlobal *g, uint64_t memoryPtr) {
320320
g->global->setPointerValue(memoryPtr);
321321
}
322322

323+
static void checkPageAligned(StringRef name, uint64_t value) {
324+
if (value != alignTo(value, ctx.arg.pageSize))
325+
error(name + " must be aligned to the page size (" +
326+
Twine(ctx.arg.pageSize) + " bytes)");
327+
}
328+
323329
// Fix the memory layout of the output binary. This assigns memory offsets
324330
// to each of the input data sections as well as the explicit stack region.
325331
// The default memory layout is as follows, from low to high.
@@ -445,8 +451,7 @@ void Writer::layoutMemory() {
445451
}
446452

447453
if (ctx.arg.initialHeap != 0) {
448-
if (ctx.arg.initialHeap != alignTo(ctx.arg.initialHeap, WasmPageSize))
449-
error("initial heap must be " + Twine(WasmPageSize) + "-byte aligned");
454+
checkPageAligned("initial heap", ctx.arg.initialHeap);
450455
uint64_t maxInitialHeap = maxMemorySetting - memoryPtr;
451456
if (ctx.arg.initialHeap > maxInitialHeap)
452457
error("initial heap too large, cannot be greater than " +
@@ -455,8 +460,7 @@ void Writer::layoutMemory() {
455460
}
456461

457462
if (ctx.arg.initialMemory != 0) {
458-
if (ctx.arg.initialMemory != alignTo(ctx.arg.initialMemory, WasmPageSize))
459-
error("initial memory must be " + Twine(WasmPageSize) + "-byte aligned");
463+
checkPageAligned("initial memory", ctx.arg.initialMemory);
460464
if (memoryPtr > ctx.arg.initialMemory)
461465
error("initial memory too small, " + Twine(memoryPtr) + " bytes needed");
462466
if (ctx.arg.initialMemory > maxMemorySetting)
@@ -465,9 +469,9 @@ void Writer::layoutMemory() {
465469
memoryPtr = ctx.arg.initialMemory;
466470
}
467471

468-
memoryPtr = alignTo(memoryPtr, WasmPageSize);
472+
memoryPtr = alignTo(memoryPtr, ctx.arg.pageSize);
469473

470-
out.memorySec->numMemoryPages = memoryPtr / WasmPageSize;
474+
out.memorySec->numMemoryPages = memoryPtr / ctx.arg.pageSize;
471475
log("mem: total pages = " + Twine(out.memorySec->numMemoryPages));
472476

473477
if (WasmSym::heapEnd) {
@@ -480,8 +484,7 @@ void Writer::layoutMemory() {
480484

481485
uint64_t maxMemory = 0;
482486
if (ctx.arg.maxMemory != 0) {
483-
if (ctx.arg.maxMemory != alignTo(ctx.arg.maxMemory, WasmPageSize))
484-
error("maximum memory must be " + Twine(WasmPageSize) + "-byte aligned");
487+
checkPageAligned("maximum memory", ctx.arg.maxMemory);
485488
if (memoryPtr > ctx.arg.maxMemory)
486489
error("maximum memory too small, " + Twine(memoryPtr) + " bytes needed");
487490
if (ctx.arg.maxMemory > maxMemorySetting)
@@ -503,7 +506,7 @@ void Writer::layoutMemory() {
503506
}
504507

505508
if (maxMemory != 0) {
506-
out.memorySec->maxMemoryPages = maxMemory / WasmPageSize;
509+
out.memorySec->maxMemoryPages = maxMemory / ctx.arg.pageSize;
507510
log("mem: max pages = " + Twine(out.memorySec->maxMemoryPages));
508511
}
509512
}
@@ -932,7 +935,7 @@ static void finalizeIndirectFunctionTable() {
932935
}
933936

934937
uint32_t tableSize = ctx.arg.tableBase + out.elemSec->numEntries();
935-
WasmLimits limits = {0, tableSize, 0};
938+
WasmLimits limits = {0, tableSize, 0, 0};
936939
if (WasmSym::indirectFunctionTable->isDefined() && !ctx.arg.growableTable) {
937940
limits.Flags |= WASM_LIMITS_FLAG_HAS_MAX;
938941
limits.Maximum = limits.Minimum;

Diff for: lld/wasm/WriterUtils.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ static std::string toString(const llvm::wasm::WasmLimits &limits) {
6969
ret += "; min=" + std::to_string(limits.Minimum);
7070
if (limits.Flags & WASM_LIMITS_FLAG_HAS_MAX)
7171
ret += "; max=" + std::to_string(limits.Maximum);
72+
if (limits.Flags & WASM_LIMITS_FLAG_HAS_PAGE_SIZE)
73+
ret += "; pagesize=" + std::to_string(limits.PageSize);
7274
return ret;
7375
}
7476

@@ -200,6 +202,8 @@ void writeLimits(raw_ostream &os, const WasmLimits &limits) {
200202
writeUleb128(os, limits.Minimum, "limits min");
201203
if (limits.Flags & WASM_LIMITS_FLAG_HAS_MAX)
202204
writeUleb128(os, limits.Maximum, "limits max");
205+
if (limits.Flags & WASM_LIMITS_FLAG_HAS_PAGE_SIZE)
206+
writeUleb128(os, llvm::Log2_64(limits.PageSize), "page size");
203207
}
204208

205209
void writeGlobalType(raw_ostream &os, const WasmGlobalType &type) {

Diff for: llvm/include/llvm/BinaryFormat/Wasm.h

+9-3
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ const char WasmMagic[] = {'\0', 'a', 's', 'm'};
2828
const uint32_t WasmVersion = 0x1;
2929
// Wasm linking metadata version
3030
const uint32_t WasmMetadataVersion = 0x2;
31-
// Wasm uses a 64k page size
32-
const uint32_t WasmPageSize = 65536;
31+
// Wasm uses a 64k page size by default (but the custom-page-sizes proposal
32+
// allows changing it)
33+
const uint32_t WasmDefaultPageSize = 65536;
3334

3435
enum : unsigned {
3536
WASM_SEC_CUSTOM = 0, // Custom / User-defined section
@@ -157,6 +158,7 @@ enum : unsigned {
157158
WASM_LIMITS_FLAG_HAS_MAX = 0x1,
158159
WASM_LIMITS_FLAG_IS_SHARED = 0x2,
159160
WASM_LIMITS_FLAG_IS_64 = 0x4,
161+
WASM_LIMITS_FLAG_HAS_PAGE_SIZE = 0x8,
160162
};
161163

162164
enum : unsigned {
@@ -317,6 +319,7 @@ struct WasmLimits {
317319
uint8_t Flags;
318320
uint64_t Minimum;
319321
uint64_t Maximum;
322+
uint32_t PageSize;
320323
};
321324

322325
struct WasmTableType {
@@ -532,7 +535,10 @@ inline bool operator!=(const WasmGlobalType &LHS, const WasmGlobalType &RHS) {
532535
inline bool operator==(const WasmLimits &LHS, const WasmLimits &RHS) {
533536
return LHS.Flags == RHS.Flags && LHS.Minimum == RHS.Minimum &&
534537
(LHS.Flags & WASM_LIMITS_FLAG_HAS_MAX ? LHS.Maximum == RHS.Maximum
535-
: true);
538+
: true) &&
539+
(LHS.Flags & WASM_LIMITS_FLAG_HAS_PAGE_SIZE
540+
? LHS.PageSize == RHS.PageSize
541+
: true);
536542
}
537543

538544
inline bool operator==(const WasmTableType &LHS, const WasmTableType &RHS) {

Diff for: llvm/include/llvm/BinaryFormat/WasmTraits.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ template <> struct DenseMapInfo<wasm::WasmGlobalType, void> {
6464
// Traits for using WasmLimits in a DenseMap
6565
template <> struct DenseMapInfo<wasm::WasmLimits, void> {
6666
static wasm::WasmLimits getEmptyKey() {
67-
return wasm::WasmLimits{0xff, 0xff, 0xff};
67+
return wasm::WasmLimits{0xff, 0xff, 0xff, 0xff};
6868
}
6969
static wasm::WasmLimits getTombstoneKey() {
70-
return wasm::WasmLimits{0xee, 0xee, 0xee};
70+
return wasm::WasmLimits{0xee, 0xee, 0xee, 0xee};
7171
}
7272
static unsigned getHashValue(const wasm::WasmLimits &Limits) {
7373
unsigned Hash = hash_value(Limits.Flags);

Diff for: llvm/include/llvm/MC/MCSymbolWasm.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class MCSymbolWasm : public MCSymbol {
147147
uint8_t flags = wasm::WASM_LIMITS_FLAG_NONE) {
148148
// Declare a table with element type VT and no limits (min size 0, no max
149149
// size).
150-
wasm::WasmLimits Limits = {flags, 0, 0};
150+
wasm::WasmLimits Limits = {flags, 0, 0, 0};
151151
setTableType({VT, Limits});
152152
}
153153
};

Diff for: llvm/include/llvm/ObjectYAML/WasmYAML.h

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ struct Limits {
4848
LimitFlags Flags;
4949
yaml::Hex32 Minimum;
5050
yaml::Hex32 Maximum;
51+
yaml::Hex32 PageSize;
5152
};
5253

5354
struct Table {

Diff for: llvm/lib/MC/WasmObjectWriter.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,8 @@ void WasmObjectWriter::writeImportSection(ArrayRef<wasm::WasmImport> Imports,
845845
if (Imports.empty())
846846
return;
847847

848-
uint64_t NumPages = (DataSize + wasm::WasmPageSize - 1) / wasm::WasmPageSize;
848+
uint64_t NumPages =
849+
(DataSize + wasm::WasmDefaultPageSize - 1) / wasm::WasmDefaultPageSize;
849850

850851
SectionBookkeeping Section;
851852
startSection(Section, wasm::WASM_SEC_IMPORT);

Diff for: llvm/lib/Object/WasmObjectFile.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,12 @@ static wasm::WasmLimits readLimits(WasmObjectFile::ReadContext &Ctx) {
291291
Result.Minimum = readVaruint64(Ctx);
292292
if (Result.Flags & wasm::WASM_LIMITS_FLAG_HAS_MAX)
293293
Result.Maximum = readVaruint64(Ctx);
294+
if (Result.Flags & wasm::WASM_LIMITS_FLAG_HAS_PAGE_SIZE) {
295+
uint32_t PageSizeLog2 = readVaruint32(Ctx);
296+
if (PageSizeLog2 >= 32)
297+
report_fatal_error("log2(wasm page size) too large");
298+
Result.PageSize = 1 << PageSizeLog2;
299+
}
294300
return Result;
295301
}
296302

Diff for: llvm/lib/ObjectYAML/WasmYAML.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ void MappingTraits<WasmYAML::Limits>::mapping(IO &IO,
372372
IO.mapRequired("Minimum", Limits.Minimum);
373373
if (!IO.outputting() || Limits.Flags & wasm::WASM_LIMITS_FLAG_HAS_MAX)
374374
IO.mapOptional("Maximum", Limits.Maximum);
375+
if (!IO.outputting() || Limits.Flags & wasm::WASM_LIMITS_FLAG_HAS_PAGE_SIZE)
376+
IO.mapOptional("PageSize", Limits.PageSize);
375377
}
376378

377379
void MappingTraits<WasmYAML::ElemSegment>::mapping(
@@ -552,6 +554,7 @@ void ScalarBitSetTraits<WasmYAML::LimitFlags>::bitset(
552554
BCase(HAS_MAX);
553555
BCase(IS_SHARED);
554556
BCase(IS_64);
557+
BCase(HAS_PAGE_SIZE);
555558
#undef BCase
556559
}
557560

Diff for: llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ struct WebAssemblyOperand : public MCParsedAsmOperand {
204204

205205
// Perhaps this should go somewhere common.
206206
static wasm::WasmLimits defaultLimits() {
207-
return {wasm::WASM_LIMITS_FLAG_NONE, 0, 0};
207+
return {wasm::WASM_LIMITS_FLAG_NONE, 0, 0, 0};
208208
}
209209

210210
static MCSymbolWasm *getOrCreateFunctionTableSymbol(MCContext &Ctx,

Diff for: llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ MCSymbolWasm *WebAssembly::getOrCreateFuncrefCallTableSymbol(
135135
// modules define the table.
136136
Sym->setWeak(true);
137137

138-
wasm::WasmLimits Limits = {0, 1, 1};
138+
wasm::WasmLimits Limits = {0, 1, 1, 0};
139139
wasm::WasmTableType TableType = {wasm::ValType::FUNCREF, Limits};
140140
Sym->setType(wasm::WASM_SYMBOL_TYPE_TABLE);
141141
Sym->setTableType(TableType);

Diff for: llvm/tools/obj2yaml/wasm2yaml.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static WasmYAML::Limits makeLimits(const wasm::WasmLimits &Limits) {
3737
L.Flags = Limits.Flags;
3838
L.Minimum = Limits.Minimum;
3939
L.Maximum = Limits.Maximum;
40+
L.PageSize = Limits.PageSize;
4041
return L;
4142
}
4243

0 commit comments

Comments
 (0)