-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Closed
Labels
Description
Example:
Source file:
static __externref_t table[0];
__externref_t test_builtin_wasm_table_get() {
return __builtin_wasm_table_get(table, 0);
}Compiling as follows works:
clang -c -target wasm32 -mreference-types builtins-table.c
but if I add -fPIC, it says:
fatal error: error in backend: Cannot select: intrinsic %llvm.wasm.table.get.externref
Bad/good IR
The IR looks as follows:
@table = internal addrspace(1) global [0 x ptr addrspace(10)] zeroinitializer, align 1
; Function Attrs: noinline nounwind optnone
define hidden ptr addrspace(10) @test_builtin_wasm_table_get() #0 {
entry:
%0 = call ptr addrspace(10) @llvm.wasm.table.get.externref(ptr addrspace(1) @table, i32 0)
ret ptr addrspace(10) %0
}
; Function Attrs: nocallback nofree nosync nounwind willreturn memory(read)
declare ptr addrspace(10) @llvm.wasm.table.get.externref(ptr addrspace(1), i32) #1If I change @table = internal addrspace(1) to @table = local_unnamed_addr addrspace(1) it seems to fix the problem.