-
Notifications
You must be signed in to change notification settings - Fork 18.2k
[WebAssembly] Represent reference types as TargetExtType #203165
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
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
475bcb6
[WebAssembly] Represent reference types as TargetExtType
hoodmane 5ba79f5
Remove unneeded llvm:: namespace qualifier
hoodmane 32f2c03
Implement zero initializers for externref and funcref
hoodmane fdcf148
Implement funcref calls in FastISel
hoodmane e01a780
Trim ref-test-func back down
hoodmane ed6aab1
Revert "Implement funcref calls in FastISel"
hoodmane 5298195
Update guard to bail out of FastISel when we have a funcref call
hoodmane 927f205
Add regression test for issue #69894
hoodmane 587499b
Go back to skipping FastISel with dontUseFastISelFor
hoodmane 14dd691
Update changelog
hoodmane e6167f9
Fix test assertions
hoodmane db1aa93
Poison instead of undef
hoodmane 34252da
Revert "Revert "Implement funcref calls in FastISel""
hoodmane File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
clang/test/CodeGen/WebAssembly/wasm-funcref-to-ptr-error.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // RUN: not %clang_cc1 -triple wasm32 -target-feature +reference-types -S -o /dev/null %s 2>&1 | FileCheck %s | ||
| // RUN: not %clang_cc1 -triple wasm64 -target-feature +reference-types -S -o /dev/null %s 2>&1 | FileCheck %s | ||
|
|
||
| // We haven't implemented a way of converting a funcref to a function pointer. | ||
| // We can generate code for it if the result is immediately called, which avoids | ||
| // the need for creating a function pointer. If the resulting pointer escapes, | ||
| // we haven't implemented codegen for that. Diagnose it in the front end rather | ||
| // than crashing in the backend. | ||
|
|
||
| typedef void (*__funcref funcref_t)(void); | ||
| typedef void (*fn_t)(void); | ||
|
|
||
| // CHECK: error: a funcref can only be converted to a pointer to be directly called; the resulting pointer cannot otherwise be used | ||
| void store_funcref_as_ptr(funcref_t f, fn_t *out) { | ||
| *out = (fn_t)f; | ||
| } | ||
|
|
||
| // CHECK: error: a funcref can only be converted to a pointer to be directly called; the resulting pointer cannot otherwise be used | ||
| fn_t return_funcref_as_ptr(funcref_t f) { | ||
| return (fn_t)f; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this comment be updated, since this works when directly called? or is this case just for a standalone funcref_to_ptr?
We could implement a standalone funcref_to_ptr by appending an entry to the indirect function table and then returning a table.get of that entry. That smells like the kind of thing that might best be a libcall, since runtimes like Emscripten are at least aware of the indirect function table (and it doesn't have to be in this PR). Also I'm not sure what the utility would be but it seems worth doing for completeness.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
For now let's not do that. I think for it to work correctly we need a stack of funcrefs, and it's just not worth it.