Skip to content

[openmp][wasm] Fix microtask type mismatch #84355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2024
Merged

Conversation

abrown
Copy link
Contributor

@abrown abrown commented Mar 7, 2024

When OpenMP is compiled for WebAssembly (see #71297), it invokes a microtask via a switch statement that dispatches to the void * microtask pointer with spelled-out arguments (not varargs). As #83329 points out, however, this can result in a type mismatch when the indirect call is executed by WebAssembly; WebAssembly expects the called pointer to have the precise type of the call site. This change fixes the issue by bringing back the approach in D142593 of type-casting all the switch arms to the precise type. This fixes #83329.

When OpenMP is compiled for WebAssembly (see llvm#71297), it invokes a
microtask via a `switch` statement that dispatches to the `void *`
microtask pointer with spelled-out arguments (not varargs). As llvm#83329
points out, however, this can result in a type mismatch when the
indirect call is executed by WebAssembly; WebAssembly expects the called
pointer to have the precise type of the call site. This change fixes the
issue by bringing back the approach in [D142593] of type-casting all the
`switch` arms to the precise type. This fixes llvm#83329.

[D142593]: https://reviews.llvm.org/D142593
@abrown
Copy link
Contributor Author

abrown commented Mar 11, 2024

@jpeyton52, can you take a look at this?

Copy link
Contributor

@jpeyton52 jpeyton52 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@jpeyton52 jpeyton52 merged commit d836608 into llvm:main Mar 14, 2024
@abrown abrown deleted the fix-83329 branch March 14, 2024 15:45
abrown added a commit to abrown/wasm-openmp-examples that referenced this pull request Mar 15, 2024
As [#83329] points out, users of the OpenMP WebAssembly port in upstream
LLVM could run into issues with indirect call type mismatches. [#84355]
fixes that problem, so this commit updates the example to use that fix.
It first changes the `llvm-project` submodule to point upstream, since
all of the work is now merged there, and also changes that submodule to
point directly at the commit for [#84355].

[#83329]: llvm/llvm-project#83329
[#84355]: llvm/llvm-project#84355
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openmp:libomp OpenMP host runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[OpenMP][WASM] Execution aborts in OpenMP runtime for wasm target when parallel region is encountered
3 participants