[lld] b568c11 - [WebAssembly] Fixed LLD generation of 64-bit __wasm_init_memory
Wouter van Oortmerssen via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 12 15:26:51 PDT 2021
Author: Wouter van Oortmerssen
Date: 2021-07-12T15:26:11-07:00
New Revision: b568c11b4090ce25bcb5e5efa9c1c504e0074bd7
URL: https://github.com/llvm/llvm-project/commit/b568c11b4090ce25bcb5e5efa9c1c504e0074bd7
DIFF: https://github.com/llvm/llvm-project/commit/b568c11b4090ce25bcb5e5efa9c1c504e0074bd7.diff
LOG: [WebAssembly] Fixed LLD generation of 64-bit __wasm_init_memory
Differential Revision: https://reviews.llvm.org/D105849
Added:
Modified:
lld/test/wasm/data-segments.ll
lld/wasm/Writer.cpp
Removed:
################################################################################
diff --git a/lld/test/wasm/data-segments.ll b/lld/test/wasm/data-segments.ll
index 72c4d9117bbcc..61bf903a116cf 100644
--- a/lld/test/wasm/data-segments.ll
+++ b/lld/test/wasm/data-segments.ll
@@ -122,7 +122,7 @@
; PASSIVE64-PIC-NEXT: - Type: I64
; PASSIVE-PIC-NEXT: Count: 1
; PASSIVE32-PIC-NEXT: Body: 230141B4CE006A2100200041004101FE480200044020004101427FFE0102001A05410023016A4100410DFC080000411023016A41004114FC08010020004102FE1702002000417FFE0002001A0BFC0900FC09010B
-; PASSIVE64-PIC-NEXT: Body: 230142B4CE006A2100200041004101FE480200044020004101427FFE0102001A05420023016A4100410DFC080000421023016A41004114FC08010020004102FE1702002000417FFE0002001A0BFC0900FC09010B
+; PASSIVE64-PIC-NEXT: Body: 230142B4CE007C2100200041004101FE480200044020004101427FFE0102001A05420023017C4100410DFC080000421023017C41004114FC08010020004102FE1702002000417FFE0002001A0BFC0900FC09010B
; PASSIVE-PIC-NEXT: - Index: 3
; PASSIVE-PIC-NEXT: Locals: []
; PASSIVE-PIC-NEXT: Body: 0B
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index 7312386ef417f..42dbc27261f2b 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -1057,7 +1057,7 @@ void Writer::createInitMemoryFunction() {
writeU8(os, WASM_OPCODE_GLOBAL_GET, "GLOBAL_GET");
writeUleb128(os, WasmSym::memoryBase->getGlobalIndex(), "memory_base");
writePtrConst(os, flagAddress, is64, "flag address");
- writeU8(os, WASM_OPCODE_I32_ADD, "add");
+ writeU8(os, is64 ? WASM_OPCODE_I64_ADD : WASM_OPCODE_I32_ADD, "add");
writeU8(os, WASM_OPCODE_LOCAL_SET, "local.set");
writeUleb128(os, 0, "local 0");
} else {
@@ -1104,7 +1104,8 @@ void Writer::createInitMemoryFunction() {
writeU8(os, WASM_OPCODE_GLOBAL_GET, "GLOBAL_GET");
writeUleb128(os, WasmSym::memoryBase->getGlobalIndex(),
"memory_base");
- writeU8(os, WASM_OPCODE_I32_ADD, "i32.add");
+ writeU8(os, is64 ? WASM_OPCODE_I64_ADD : WASM_OPCODE_I32_ADD,
+ "i32.add");
}
// source segment offset
writeI32Const(os, 0, "segment offset");
More information about the llvm-commits
mailing list