[llvm-dev] "llc -march wasm64" always fail.

zh via llvm-dev llvm-dev at lists.llvm.org
Mon Sep 30 03:44:09 PDT 2019


I'm writing a wasm interpreter, aim to exposure native functions for wasm modules to call directly.
So the interpreter must share address space with the wasm module.


To produce a simple wasm module for testing, I tried these steps: 
step 1. Compile a simple c file with clang, targeting host platform.
step 2. Use llc -march  wasm64 to generate a wasm module file.
But actually it does not work, even for a simple hello.c.


hello.c is the classical "hello world" C program: 


#include <stdio.h>
int main(){
	printf("Hello world!\n");
	return 0;
}



This produces the hello.ll :
clang -c -emit-llvm -S D:\hello.c


32-bit version works perfectly:
llc -march=wasm32 hello.ll


And this always fail:
llc -march=wasm64 hello.ll


The error message says:


LLVM ERROR: Cannot select: 0x17246d26200: ch = store<(store 8 into %ir.7)> 0x17246cbf638, 0x17246d25f28, 0x17246d26268, undef:i64
  0x17246d25f28: i64,ch = CopyFromReg 0x17246cbf638, Register:i64 %0
    0x17246d25ff8: i64 = Register %0
  0x17246d26268: i64,ch = CopyFromReg 0x17246cbf638, Register:i64 %16
    0x17246d260c8: i64 = Register %16
  0x17246d25e58: i64 = undef
In function: sprintf
Stack dump:
0.      Program arguments: llc -march=wasm64 hello.ll
1.      Running pass 'Function Pass Manager' on module 'hello.ll'.
2.      Running pass 'WebAssembly Instruction Selection' on function '@sprintf'



Is it a bug in LLVM's wasm64 CodeGen?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190930/e50bcc19/attachment.html>


More information about the llvm-dev mailing list