Skip to content

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

Merged
jpeyton52 merged 1 commit into
llvm:mainfrom
abrown:fix-83329
Mar 14, 2024
Merged

jpeyton52 merged 1 commit into
llvm:mainfrom
abrown:fix-83329

Conversation

@abrown

@abrown abrown commented Mar 7, 2024

Copy link
Copy Markdown
Contributor

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

abrown commented Mar 11, 2024

Copy link
Copy Markdown
Contributor Author

@jpeyton52, can you take a look at this?

@jpeyton52 jpeyton52 left a comment

Copy link
Copy Markdown

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
paleauraaaa pushed a commit to paleauraaaa/llvm-project that referenced this pull request Oct 7, 2026
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
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