diff options
author | Ashley Nelson <nashley@google.com> | 2023-01-03 11:29:41 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-03 19:29:41 +0000 |
commit | fe01812696a8108bcd7103a7a09573c99743fa04 (patch) | |
tree | eadf1e655567afd70f46fe92ae07403faa1308da /src | |
parent | 4a8a4b87a1dfde2809f08432d34b9a7618cb4a4f (diff) | |
download | binaryen-fe01812696a8108bcd7103a7a09573c99743fa04.tar.gz binaryen-fe01812696a8108bcd7103a7a09573c99743fa04.tar.bz2 binaryen-fe01812696a8108bcd7103a7a09573c99743fa04.zip |
Move assert in MultiMemoryLowering (#5376)
Moved the assert that checks whether the DataSegment* offset type is Const. This assert only needs to happen when the DataSegment belongs to a memory other than the first.
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/MultiMemoryLowering.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/passes/MultiMemoryLowering.cpp b/src/passes/MultiMemoryLowering.cpp index 38a5ded93..ab0a1376b 100644 --- a/src/passes/MultiMemoryLowering.cpp +++ b/src/passes/MultiMemoryLowering.cpp @@ -468,17 +468,20 @@ struct MultiMemoryLowering : public Pass { } } + // TODO: Add a trap for segments that have a non-constant offset that would + // have been out of bounds at runtime but is in bounds after multi-memory + // lowering void adjustActiveDataSegmentOffsets() { Builder builder(*wasm); ModuleUtils::iterActiveDataSegments(*wasm, [&](DataSegment* dataSegment) { - assert(dataSegment->offset->is<Const>() && - "TODO: handle non-const segment offsets"); auto idx = memoryIdxMap.at(dataSegment->memory); dataSegment->memory = combinedMemory; // No need to update the offset of data segments for the first memory if (idx != 0) { - auto offsetGlobalName = getOffsetGlobal(idx); + assert(dataSegment->offset->is<Const>() && + "TODO: handle non-const segment offsets"); assert(wasm->features.hasExtendedConst()); + auto offsetGlobalName = getOffsetGlobal(idx); dataSegment->offset = builder.makeBinary( Abstract::getBinary(pointerType, Abstract::Add), builder.makeGlobalGet(offsetGlobalName, pointerType), |