<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/83329>83329</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Execution aborts in OpenMP runtime for wasm target when parallel region is encountered
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mawi2017
</td>
</tr>
</table>
<pre>
Currently, a parallel region in a wasm OpenMP application causes the following error:
```
Error: failed to run main module `example.wasm`
Caused by:
0: failed to invoke command default
1: error while executing at wasm backtrace:
0: 0xafe73 - <unknown>!__kmp_invoke_microtask
1: 0x283a4 - <unknown>!__kmp_invoke_task_func
2: 0x22d00 - <unknown>!__kmp_fork_call
3: 0x629f - <unknown>!__kmpc_fork_call
4: 0xca2 - <unknown>!main
5: 0xb590a - <unknown>!__main_void
6: 0xbe9 - <unknown>!_start
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
2: wasm trap: indirect call type mismatch
Error: error while executing at wasm backtrace:
0: 0xafe73 - <unknown>!__kmp_invoke_microtask
1: 0x283a4 - <unknown>!__kmp_invoke_task_func
```
It seems in [`__kmp_invoke_microtask`](https://github.com/llvm/llvm-project/blob/main/openmp/runtime/src/z_Linux_util.cpp#L2545) of the OpenMP runtime, the corresponding casts for each function call inside the `switch` are missing. For example, using `((void (*)(int*, int*, void*))(*pkfn))(>id, &tid, p_argv[0]);` instead of just `(*pkfn)(>id, &tid, p_argv[0]);`. This was also part of a previous PR [D142593](https://reviews.llvm.org/D142593).
As reproducer any parallel region (even empty) will do. More comfortable might be using https://github.com/abrown/wasm-openmp-examples/ as it already includes a working Makefile for building and running. For the llvm-project subfolder just use the latest version.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVt-P2jgQ_mvMy2iRcUggDzxQlkjVdXVVu9I9ookzARfHjvwDlvvrT07Ype1ue9o7hIJNZubz-P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