<div>I'm writing a wasm interpreter, aim to exposure native functions for wasm modules to call directly.</div><div>So the interpreter must share address space with the wasm module.</div><div><br></div><div>To produce a simple wasm module for testing, I tried these steps: </div><div>step 1. Compile a simple c file with clang, targeting host platform.</div><div>step 2. Use llc -march  wasm64 to generate a wasm module file.</div><div>But actually it does not work, even for a simple hello.c.</div><div><br></div><div>hello.c is the classical "hello world" C program: </div><div><br></div><div>#include <stdio.h></div><div><div>int main(){</div><div><span style="white-space:pre"> </span>printf("Hello world!\n");</div><div><span style="white-space:pre">   </span>return 0;</div><div>}</div></div><div><br></div><div>This produces the hello.ll :</div><div>clang -c -emit-llvm -S D:\hello.c</div><div><br></div><div>32-bit version works perfectly:</div><div>llc -march=wasm32 hello.ll</div><div><br></div><div>And this always fail:</div><div>llc -march=wasm64 hello.ll</div><div><br></div><div>The error message says:</div><div><br></div><div><div>LLVM ERROR: Cannot select: 0x17246d26200: ch = store<(store 8 into %ir.7)> 0x17246cbf638, 0x17246d25f28, 0x17246d26268, undef:i64</div><div>  0x17246d25f28: i64,ch = CopyFromReg 0x17246cbf638, Register:i64 %0</div><div>    0x17246d25ff8: i64 = Register %0</div><div>  0x17246d26268: i64,ch = CopyFromReg 0x17246cbf638, Register:i64 %16</div><div>    0x17246d260c8: i64 = Register %16</div><div>  0x17246d25e58: i64 = undef</div><div>In function: sprintf</div><div>Stack dump:</div><div>0.      Program arguments: llc -march=wasm64 hello.ll</div><div>1.      Running pass 'Function Pass Manager' on module 'hello.ll'.</div><div>2.      Running pass 'WebAssembly Instruction Selection' on function '@sprintf'</div></div><div><br></div><div>Is it a bug in LLVM's wasm64 CodeGen?</div>