-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[clang][WebAssembly] Support reftypes & varargs in test_function_pointer_signature #150921
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
6 commits
Select commit
Hold shift + click to select a range
6caa2f7
[clang,WebAssembly] Support reference types in test_function_pointer_…
hoodmane e7b8d8e
Fix handling of varargs function
hoodmane 6dafa4a
Add tests for struct and union abi
hoodmane ceb363a
Add separate union test
hoodmane 2739332
Merge branch 'main' into wasm-test-fp-sig-reference-types
hoodmane 60e2c93
Reject struct/union param/return type in Sema with multivalue abi
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +gc -O3 -emit-llvm -DSINGLE_VALUE -o - %s | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY-SV | ||
// RUN: %clang_cc1 -triple wasm64-unknown-unknown -target-feature +gc -O3 -emit-llvm -DSINGLE_VALUE -o - %s | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY-SV | ||
// RUN: %clang_cc1 -triple wasm64-unknown-unknown -target-feature +gc -target-abi experimental-mv -O3 -emit-llvm -o - %s 2>&1 | FileCheck %s -check-prefixes WEBASSEMBLY | ||
// RUN: not %clang_cc1 -triple wasm64-unknown-unknown -O3 -emit-llvm -o - %s 2>&1 | FileCheck %s -check-prefixes MISSING-GC | ||
|
||
void use(int); | ||
|
||
typedef void (*Fvoid)(void); | ||
void test_function_pointer_signature_void(Fvoid func) { | ||
// MISSING-GC: error: '__builtin_wasm_test_function_pointer_signature' needs target feature gc | ||
// WEBASSEMBLY: %0 = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, token poison) | ||
use(__builtin_wasm_test_function_pointer_signature(func)); | ||
} | ||
|
||
typedef float (*Ffloats)(float, double, int); | ||
void test_function_pointer_signature_floats(Ffloats func) { | ||
// WEBASSEMBLY: %0 = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, float poison, token poison, float poison, double poison, i32 poison) | ||
use(__builtin_wasm_test_function_pointer_signature(func)); | ||
} | ||
|
||
typedef void (*Fpointers)(Fvoid, Ffloats, void*, int*, int***, char[5]); | ||
void test_function_pointer_signature_pointers(Fpointers func) { | ||
// WEBASSEMBLY: %0 = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, token poison, ptr poison, ptr poison, ptr poison, ptr poison, ptr poison, ptr poison) | ||
use(__builtin_wasm_test_function_pointer_signature(func)); | ||
} | ||
|
||
typedef void (*FVarArgs)(int, ...); | ||
void test_function_pointer_signature_varargs(FVarArgs func) { | ||
// WEBASSEMBLY: %0 = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, token poison, i32 poison, ptr poison) | ||
use(__builtin_wasm_test_function_pointer_signature(func)); | ||
} | ||
|
||
typedef __externref_t (*FExternRef)(__externref_t, __externref_t); | ||
void test_function_pointer_externref(FExternRef func) { | ||
// WEBASSEMBLY: %0 = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, ptr addrspace(10) poison, token poison, ptr addrspace(10) poison, ptr addrspace(10) poison) | ||
use(__builtin_wasm_test_function_pointer_signature(func)); | ||
} | ||
|
||
typedef __funcref Fpointers (*FFuncRef)(__funcref Fvoid, __funcref Ffloats); | ||
void test_function_pointer_funcref(FFuncRef func) { | ||
// WEBASSEMBLY: %0 = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, ptr addrspace(20) poison, token poison, ptr addrspace(20) poison, ptr addrspace(20) poison) | ||
use(__builtin_wasm_test_function_pointer_signature(func)); | ||
} | ||
|
||
#ifdef SINGLE_VALUE | ||
// Some tests that we get struct ABIs correct. There is no special code in | ||
// __builtin_wasm_test_function_pointer_signature for this, it gets handled by | ||
// the normal type lowering code. | ||
// Single element structs are unboxed, multi element structs are passed on | ||
// stack. | ||
typedef struct {double x;} (*Fstructs1)(struct {double x;}, struct {float x;}, struct {double x; float y;}); | ||
void test_function_pointer_structs1(Fstructs1 func) { | ||
// WEBASSEMBLY-SV: %0 = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, double poison, token poison, double poison, float poison, ptr poison) | ||
use(__builtin_wasm_test_function_pointer_signature(func)); | ||
} | ||
|
||
// Two element return struct ==> return ptr on stack | ||
typedef struct {double x; double y;} (*Fstructs2)(void); | ||
void test_function_pointer_structs2(Fstructs2 func) { | ||
// WEBASSEMBLY-SV: %0 = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, token poison, ptr poison) | ||
use(__builtin_wasm_test_function_pointer_signature(func)); | ||
} | ||
|
||
// Return union ==> return ptr on stack, one element union => unboxed | ||
typedef union {double x; float y;} (*FUnions)(union {double x; float y;}, union {double x;}); | ||
void test_function_pointer_unions(FUnions func) { | ||
// WEBASSEMBLY-SV: %0 = tail call i32 (ptr, ...) @llvm.wasm.ref.test.func(ptr %func, token poison, ptr poison, ptr poison, double poison) | ||
use(__builtin_wasm_test_function_pointer_signature(func)); | ||
} | ||
#endif |
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
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.
Uh oh!
There was an error while loading. Please reload this page.