================
@@ -1669,21 +1680,37 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler 
&Asm,
           switch (Global.Type.Type) {
           case wasm::WASM_TYPE_I32:
             Global.InitExpr.Inst.Opcode = wasm::WASM_OPCODE_I32_CONST;
+            Global.InitExpr.Inst.Value.Int32 = 0;
             break;
           case wasm::WASM_TYPE_I64:
             Global.InitExpr.Inst.Opcode = wasm::WASM_OPCODE_I64_CONST;
+            Global.InitExpr.Inst.Value.Int64 = 0;
             break;
           case wasm::WASM_TYPE_F32:
             Global.InitExpr.Inst.Opcode = wasm::WASM_OPCODE_F32_CONST;
+            Global.InitExpr.Inst.Value.Float32 = 0;
             break;
           case wasm::WASM_TYPE_F64:
             Global.InitExpr.Inst.Opcode = wasm::WASM_OPCODE_F64_CONST;
+            Global.InitExpr.Inst.Value.Float64 = 0;
             break;
           case wasm::WASM_TYPE_EXTERNREF:
             Global.InitExpr.Inst.Opcode = wasm::WASM_OPCODE_REF_NULL;
             break;
           default:
-            llvm_unreachable("unexpected type");
+            // Keep the entry: relocations and the symbol table look up this
+            // global's index in WasmIndices. The error discards the object.
+            reportUnsupportedGlobal(WS, Global.Type.Type);
+            Global.Type.Type = uint8_t(wasm::ValType::I32);
+            Global.InitExpr.Inst.Opcode = wasm::WASM_OPCODE_I32_CONST;
+            Global.InitExpr.Inst.Value.Int32 = 0;
----------------
kateinoigakukun wrote:

It looks like this adds a dummy entry to workaround something? Can you 
elaborate on why we need this change?

https://github.com/llvm/llvm-project/pull/212007
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to