[clang] [llvm] [WebAssembly] Add __builtin_wasm_js_catch for catching JSPI SuspendError (PR #153767)

2025-08-19 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane converted_to_draft https://github.com/llvm/llvm-project/pull/153767 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [WebAssembly] Add __builtin_wasm_js_catch for catching JSPI SuspendError (PR #153767)

2025-08-18 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane edited https://github.com/llvm/llvm-project/pull/153767 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] Add __builtin_wasm_js_catch (PR #153767)

2025-08-16 Thread Hood Chatham via cfe-commits
hoodmane wrote: @aheejin I will give a more detailed response about why this is necessary on Monday but the problem is that the `SuspendError` is generated inside the import wrapper: https://github.com/v8/v8/blob/3c61391b55f06f880c7431c231f15014db34dfcc/src/wasm/wrappers.cc#L540-L568 So no JS c

[clang] [llvm] Add __builtin_wasm_js_catch (PR #153767)

2025-08-16 Thread Hood Chatham via cfe-commits
hoodmane wrote: @efriedma-quic that sounds good to me, I'll have to look into how `__try`/ `__catch` work on windows. I was just trying to copy the semantics of a C API that I knew about, so setjmp/longjmp. But a more direct API would probably also have a simpler implementation. https://githu

[clang] [llvm] Add __builtin_wasm_js_catch (PR #153767)

2025-08-15 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/153767 >From f0193d7b0b5c6242e48699c84655eb7c75b90f82 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 13 Aug 2025 13:44:57 +0200 Subject: [PATCH] Add __builtin_wasm_js_catch This is a setjmp-like API that catc

[clang] [llvm] Add __builtin_wasm_js_catch (PR #153767)

2025-08-15 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/153767 >From bfafd3b4a9a8845a4018d2472bb85c61c79e9f85 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 13 Aug 2025 13:44:57 +0200 Subject: [PATCH] Add __builtin_wasm_js_catch This is a setjmp-like API that catc

[clang] [llvm] Add __builtin_wasm_js_catch (PR #153767)

2025-08-15 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane edited https://github.com/llvm/llvm-project/pull/153767 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] Add __builtin_wasm_js_catch (PR #153767)

2025-08-15 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane edited https://github.com/llvm/llvm-project/pull/153767 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] Add __builtin_wasm_js_catch (PR #153767)

2025-08-15 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane created https://github.com/llvm/llvm-project/pull/153767 This is a setjmp-like API that catches JavaScript errors. Its signature is `externref_t __builtin_wasm_js_catch(int *status);` The first time it returns, the return value is `null` and *status is set to 0. If

[clang] [llvm] [clang][WebAssembly] Support reftypes & varargs in test_function_pointer_signature (PR #150921)

2025-08-07 Thread Hood Chatham via cfe-commits
hoodmane wrote: Updated. https://github.com/llvm/llvm-project/pull/150921 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [clang][WebAssembly] Support reftypes & varargs in test_function_pointer_signature (PR #150921)

2025-08-07 Thread Hood Chatham via cfe-commits
hoodmane wrote: Thanks @dschuff! https://github.com/llvm/llvm-project/pull/150921 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [clang][WebAssembly] Support reftypes & varargs in test_function_pointer_signature (PR #150921)

2025-08-07 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane edited https://github.com/llvm/llvm-project/pull/150921 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [clang][WebAssembly] Support reftypes & varargs in test_function_pointer_signature (PR #150921)

2025-08-07 Thread Hood Chatham via cfe-commits
@@ -246,35 +246,26 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID, llvm::FunctionType *LLVMFuncTy = cast(ConvertType(QualType(FuncTy, 0))); +bool VarArg = LLVMFuncTy->isVarArg(); unsigned NParams = LLVMFuncTy->getNumParams();

[clang] [llvm] [clang][WebAssembly] Support reftypes & varargs in test_function_pointer_signature (PR #150921)

2025-08-07 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/150921 >From 6caa2f7b749a9c655864afbbff07e9e78dd9b1b0 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 28 Jul 2025 12:37:24 +0200 Subject: [PATCH 1/5] [clang,WebAssembly] Support reference types in test_functio

[clang] [llvm] [clang][WebAssembly] Support reftypes & varargs in test_function_pointer_signature (PR #150921)

2025-08-07 Thread Hood Chatham via cfe-commits
@@ -246,35 +246,26 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID, llvm::FunctionType *LLVMFuncTy = cast(ConvertType(QualType(FuncTy, 0))); +bool VarArg = LLVMFuncTy->isVarArg(); unsigned NParams = LLVMFuncTy->getNumParams();

[clang] [llvm] [clang][WebAssembly] Support reftypes & varargs in test_function_pointer_signature (PR #150921)

2025-08-07 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane edited https://github.com/llvm/llvm-project/pull/150921 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [WebAssembly] Add gc target feature to addBleedingEdgeFeatures (PR #151294)

2025-07-30 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane created https://github.com/llvm/llvm-project/pull/151294 Also alphebetize feature list, add `-mgc` and `-mno-gc` flags, and add some missing feature tests. Reland of #151107. https://github.com/llvm/llvm-project/pull/150201#discussion_r2237982637 >From 034fa59dd05

[clang] [llvm] [WebAssembly] Add gc target feature to addBleedingEdgeFeatures (PR #151107)

2025-07-29 Thread Hood Chatham via cfe-commits
hoodmane wrote: Thanks @aheejin. How's it look now? https://github.com/llvm/llvm-project/pull/151107 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [WebAssembly] Add gc target feature to addBleedingEdgeFeatures (PR #151107)

2025-07-29 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/151107 >From bb71b4795d85938772e78de3022d5d58b25d6d20 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Tue, 29 Jul 2025 10:41:49 +0200 Subject: [PATCH 1/5] [WebAssembly] Add gc target feature to addBleedingEdgeFeatu

[clang] [llvm] [WebAssembly] Add gc target feature to addBleedingEdgeFeatures (PR #151107)

2025-07-29 Thread Hood Chatham via cfe-commits
hoodmane wrote: Okay I think I'm up to date with the comments so far. https://github.com/llvm/llvm-project/pull/151107 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [WebAssembly] Add gc target feature to addBleedingEdgeFeatures (PR #151107)

2025-07-29 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/151107 >From bb71b4795d85938772e78de3022d5d58b25d6d20 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Tue, 29 Jul 2025 10:41:49 +0200 Subject: [PATCH 1/4] [WebAssembly] Add gc target feature to addBleedingEdgeFeatu

[clang] [WebAssembly] Add gc target feature to addBleedingEdgeFeatures (PR #151107)

2025-07-29 Thread Hood Chatham via cfe-commits
@@ -197,6 +197,7 @@ bool WebAssemblyTargetInfo::initFeatureMap( Features["multimemory"] = true; Features["tail-call"] = true; Features["wide-arithmetic"] = true; +Features["gc"] = true; hoodmane wrote: Well... the CI didn't fail... so maybe not

[clang] [WebAssembly] Add gc target feature to addBleedingEdgeFeatures (PR #151107)

2025-07-29 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane edited https://github.com/llvm/llvm-project/pull/151107 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [clang,WebAssembly] Support reference types in test_function_pointer_signature (PR #150921)

2025-07-29 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/150921 >From 6caa2f7b749a9c655864afbbff07e9e78dd9b1b0 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 28 Jul 2025 12:37:24 +0200 Subject: [PATCH 1/4] [clang,WebAssembly] Support reference types in test_functio

[clang] [llvm] [clang,WebAssembly] Support reference types in test_function_pointer_signature (PR #150921)

2025-07-29 Thread Hood Chatham via cfe-commits
hoodmane wrote: Okay added a test for struct and union abis being handled correctly. https://github.com/llvm/llvm-project/pull/150921 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [clang,WebAssembly] Support reference types in test_function_pointer_signature (PR #150921)

2025-07-29 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/150921 >From 6caa2f7b749a9c655864afbbff07e9e78dd9b1b0 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 28 Jul 2025 12:37:24 +0200 Subject: [PATCH 1/3] [clang,WebAssembly] Support reference types in test_functio

[clang] [llvm] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-29 Thread Hood Chatham via cfe-commits
@@ -307,6 +310,14 @@ bool WebAssemblyTargetInfo::handleTargetFeatures( HasReferenceTypes = false; continue; } +if (Feature == "+gc") { + HasGC = true; + continue; +} +if (Feature == "-gc") { + HasGC = false; + continue; +} ---

[clang] [WebAssembly] Add gc target feature to addBleedingEdgeFeatures (PR #151107)

2025-07-29 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane created https://github.com/llvm/llvm-project/pull/151107 See suggestion here: https://github.com/llvm/llvm-project/pull/150201#discussion_r2237982637 >From bb71b4795d85938772e78de3022d5d58b25d6d20 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Tue, 29 Jul 2025 10

[clang] [llvm] [clang,WebAssembly] Support reference types in test_function_pointer_signature (PR #150921)

2025-07-28 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane edited https://github.com/llvm/llvm-project/pull/150921 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [clang,WebAssembly] Support reference types in test_function_pointer_signature (PR #150921)

2025-07-28 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/150921 >From 6caa2f7b749a9c655864afbbff07e9e78dd9b1b0 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 28 Jul 2025 12:37:24 +0200 Subject: [PATCH 1/2] [clang,WebAssembly] Support reference types in test_functio

[clang] [llvm] [clang,WebAssembly] Support reference types in test_function_pointer_signature (PR #150921)

2025-07-28 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane edited https://github.com/llvm/llvm-project/pull/150921 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [clang,WebAssembly] Support reference types in test_function_pointer_signature (PR #150921)

2025-07-28 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane created https://github.com/llvm/llvm-project/pull/150921 This was simpler than I thought. >From 6caa2f7b749a9c655864afbbff07e9e78dd9b1b0 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 28 Jul 2025 12:37:24 +0200 Subject: [PATCH] [clang,WebAssembly] Support re

[clang] [llvm] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-25 Thread Hood Chatham via cfe-commits
hoodmane wrote: @dschuff would appreciate it if you could merge assuming you have no further comments and the addition of the GC feature looks okay. https://github.com/llvm/llvm-project/pull/150201 ___ cfe-commits mailing list cfe-commits@lists.llvm.o

[clang] [llvm] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-25 Thread Hood Chatham via cfe-commits
hoodmane wrote: And now I think CI is passing again. https://github.com/llvm/llvm-project/pull/150201 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-25 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/150201 >From 6c3c8a1d43b3b06c6b38e8e3d2e00ef2dc5fbc4e Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 7 Jul 2025 22:50:08 +0200 Subject: [PATCH 1/9] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer

[clang] [llvm] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-25 Thread Hood Chatham via cfe-commits
hoodmane wrote: Thanks for the reviews @dschuff and @tlively! https://github.com/llvm/llvm-project/pull/150201 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-25 Thread Hood Chatham via cfe-commits
@@ -199,6 +199,12 @@ TARGET_BUILTIN(__builtin_wasm_ref_is_null_extern, "ii", "nct", "reference-types" // return type. TARGET_BUILTIN(__builtin_wasm_ref_null_func, "i", "nct", "reference-types") +// Check if the runtime type of a function pointer matches its static type. Used

[clang] [llvm] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-25 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/150201 >From 6c3c8a1d43b3b06c6b38e8e3d2e00ef2dc5fbc4e Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 7 Jul 2025 22:50:08 +0200 Subject: [PATCH 1/8] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer

[clang] [llvm] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-25 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/150201 >From 6c3c8a1d43b3b06c6b38e8e3d2e00ef2dc5fbc4e Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 7 Jul 2025 22:50:08 +0200 Subject: [PATCH 1/8] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer

[clang] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-24 Thread Hood Chatham via cfe-commits
@@ -218,6 +221,64 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID, Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_ref_null_func); return Builder.CreateCall(Callee); } + case WebAssembly::BI__builtin_wasm_test_function_pointer_signature:

[clang] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-24 Thread Hood Chatham via cfe-commits
@@ -218,6 +221,64 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID, Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_ref_null_func); return Builder.CreateCall(Callee); } + case WebAssembly::BI__builtin_wasm_test_function_pointer_signature:

[clang] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-24 Thread Hood Chatham via cfe-commits
@@ -227,6 +227,53 @@ bool SemaWasm::BuiltinWasmTableCopy(CallExpr *TheCall) { return false; } +bool SemaWasm::BuiltinWasmTestFunctionPointerSignature(CallExpr *TheCall) { + if (SemaRef.checkArgCount(TheCall, 1)) +return true; + + Expr *FuncPtrArg = TheCall->getArg(0);

[clang] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-24 Thread Hood Chatham via cfe-commits
@@ -218,6 +221,64 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID, Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_ref_null_func); return Builder.CreateCall(Callee); } + case WebAssembly::BI__builtin_wasm_test_function_pointer_signature:

[clang] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-23 Thread Hood Chatham via cfe-commits
hoodmane wrote: If this change looks good can we merge it? https://github.com/llvm/llvm-project/pull/150201 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-23 Thread Hood Chatham via cfe-commits
hoodmane wrote: Other builtins with dynamic return type: `__builtin_call_with_static_chain` > This builtin is only available for C. This builtin can be used to call Go > closures from C. `__builtin_choose_expr` > This built-in function is analogous to the ? : operator in C, except t

[clang] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-23 Thread Hood Chatham via cfe-commits
hoodmane wrote: Well it would also be possible to make success the return value, and make the first argument a `void* result`. This would be a more normal API, but it has the disadvantage that it would never be able to work with functions that return reference types. Maybe that isn't that big

[clang] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-23 Thread Hood Chatham via cfe-commits
hoodmane wrote: It seems that builtins can do that. In `SemaWasm.cpp` we call `TheCall->setType(FuncTy->getReturnType());` and that implies that the return type of the call to `__builtin_wasm_nontrapping_call()` is the same as the return type of `func`. https://github.com/llvm/llvm-project/pu

[clang] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-23 Thread Hood Chatham via cfe-commits
hoodmane wrote: My thought is that it returns the return value. If one of the signatures matches it sets `*success = 1` otherwise it sets `*success = 0`. It probably can be written in terms of `__builtin_wasm_test_function_pointer_signature` with C++ templates but lot of projects I contribute

[clang] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-23 Thread Hood Chatham via cfe-commits
hoodmane wrote: I'd also like to add `__builtin_wasm_nontrapping_call(&success, func, a, b, c)` which tries to call func with 3, 2, 1, and 0 arguments. https://github.com/llvm/llvm-project/pull/150201 ___ cfe-commits mailing list cfe-commits@lists.llv

[clang] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-23 Thread Hood Chatham via cfe-commits
hoodmane wrote: `type` has the advantage that it is a bit less typing. https://github.com/llvm/llvm-project/pull/150201 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-23 Thread Hood Chatham via cfe-commits
hoodmane wrote: I'm neutral on the name, happy to change it if you prefer. https://github.com/llvm/llvm-project/pull/150201 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-23 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/150201 >From 6c3c8a1d43b3b06c6b38e8e3d2e00ef2dc5fbc4e Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 7 Jul 2025 22:50:08 +0200 Subject: [PATCH 1/6] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer

[clang] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-23 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/150201 >From 6c3c8a1d43b3b06c6b38e8e3d2e00ef2dc5fbc4e Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 7 Jul 2025 22:50:08 +0200 Subject: [PATCH 1/5] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer

[clang] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-23 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/150201 >From 6c3c8a1d43b3b06c6b38e8e3d2e00ef2dc5fbc4e Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 7 Jul 2025 22:50:08 +0200 Subject: [PATCH 1/4] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer

[clang] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-23 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/150201 >From 6c3c8a1d43b3b06c6b38e8e3d2e00ef2dc5fbc4e Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 7 Jul 2025 22:50:08 +0200 Subject: [PATCH 1/3] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer

[clang] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-23 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/150201 >From 6c3c8a1d43b3b06c6b38e8e3d2e00ef2dc5fbc4e Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 7 Jul 2025 22:50:08 +0200 Subject: [PATCH 1/2] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer

[clang] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)

2025-07-23 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane created https://github.com/llvm/llvm-project/pull/150201 Tests if the runtime type of the function pointer matches the static type. If this returns false, calling the function pointer will trap. Uses `@llvm.wasm.ref.test.func` added in #147486. cc @sbc100 @dschuff

[clang] [llvm] [WebAssembly,llvm] Add llvm.wasm.ref.test.func intrinsic (PR #147076)

2025-07-08 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane closed https://github.com/llvm/llvm-project/pull/147076 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [WebAssembly,llvm] Add llvm.wasm.ref.test.func intrinsic (PR #147076)

2025-07-08 Thread Hood Chatham via cfe-commits
hoodmane wrote: Closing in favor of #147486. https://github.com/llvm/llvm-project/pull/147076 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [WebAssembly,llvm] Add llvm.wasm.ref.test.func intrinsic (PR #147076)

2025-07-08 Thread Hood Chatham via cfe-commits
hoodmane wrote: Okay I opened https://github.com/llvm/llvm-project/pull/147486/ with a second option. I think that's a bit cleaner, I modified SelectionDAG to be able to emit CImm arguments rather than going to all this trouble to avoid it. https://github.com/llvm/llvm-project/pull/147076

[clang] [llvm] [WebAssembly,llvm] Add llvm.wasm.ref.test.func intrinsic (PR #147076)

2025-07-08 Thread Hood Chatham via cfe-commits
hoodmane wrote: The goal is as an alternative to `EMULATE_FUNCTION_POINTER_CASTS` for projects like Python and GLib that do dispatch with sometimes-incorrect function pointers. In particular, rather than having to `call_indirect` a function pointer and find out whether or not we trap, I want a

[clang] [llvm] [WebAssembly,llvm] Add llvm.wasm.ref.test.func intrinsic (PR #147076)

2025-07-08 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane edited https://github.com/llvm/llvm-project/pull/147076 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [WebAssembly,llvm] Add llvm.wasm.ref.test.func intrinsic (PR #147076)

2025-07-07 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane edited https://github.com/llvm/llvm-project/pull/147076 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #147076)

2025-07-07 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/147076 >From 2009bb945f57c67daa522448eddb2cc01aac4369 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 2 Jul 2025 20:53:56 +0200 Subject: [PATCH 1/8] Add __builtin_wasm_test_function_pointer_signature This uses

[clang] [llvm] Add __builtin_wasm_test_function_pointer_signature (PR #147076)

2025-07-07 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/147076 >From ba4e21486455fcee36e5521050562cd9be35e9b4 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Sat, 10 May 2025 22:01:09 -0400 Subject: [PATCH 1/9] [WebAssembly] Add ref.test_func handling to AsmParser ---

[clang] [llvm] Add __builtin_wasm_test_function_pointer_signature (PR #147076)

2025-07-04 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/147076 >From ba4e21486455fcee36e5521050562cd9be35e9b4 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Sat, 10 May 2025 22:01:09 -0400 Subject: [PATCH 1/8] [WebAssembly] Add ref.test_func handling to AsmParser ---

[clang] [llvm] Add __builtin_wasm_test_function_pointer_signature (PR #147076)

2025-07-04 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/147076 >From ba4e21486455fcee36e5521050562cd9be35e9b4 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Sat, 10 May 2025 22:01:09 -0400 Subject: [PATCH 1/7] [WebAssembly] Add ref.test_func handling to AsmParser ---

[clang] [llvm] Add __builtin_wasm_test_function_pointer_signature (PR #147076)

2025-07-04 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/147076 >From ba4e21486455fcee36e5521050562cd9be35e9b4 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Sat, 10 May 2025 22:01:09 -0400 Subject: [PATCH 1/6] [WebAssembly] Add ref.test_func handling to AsmParser ---

[clang] [llvm] Add __builtin_wasm_test_function_pointer_signature (PR #147076)

2025-07-04 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/147076 >From ba4e21486455fcee36e5521050562cd9be35e9b4 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Sat, 10 May 2025 22:01:09 -0400 Subject: [PATCH 1/5] [WebAssembly] Add ref.test_func handling to AsmParser ---

[clang] [llvm] Add __builtin_wasm_test_function_pointer_signature (PR #147076)

2025-07-04 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane created https://github.com/llvm/llvm-project/pull/147076 This uses ref.test to check whether the function pointer's runtime type matches its static type. If so, then calling it won't trap with "indirect call signature mismatch". This would be very useful here: https:/

[clang] [WebAssembly][Clang] Add __builtin_wasm_ref_is_null_extern (PR #139580)

2025-05-13 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/139580 >From 2ca282f0a20088bef15289a8ce5167d1e23595c3 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Fri, 9 May 2025 00:16:26 -0400 Subject: [PATCH 1/3] [Wasm][Clang] Add __builtin_wasm_ref_is_null_extern I also

[clang] [Clang] Fix Sema::checkArgCount for 0-arg functions (PR #139638)

2025-05-13 Thread Hood Chatham via cfe-commits
hoodmane wrote: CI looks green now. https://github.com/llvm/llvm-project/pull/139638 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Fix Sema::checkArgCount for 0-arg functions (PR #139638)

2025-05-13 Thread Hood Chatham via cfe-commits
hoodmane wrote: Can somebody merge when it's appropriate? I don't have merge rights. https://github.com/llvm/llvm-project/pull/139638 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Fix Sema::checkArgCount for 0-arg functions (PR #139638)

2025-05-13 Thread Hood Chatham via cfe-commits
hoodmane wrote: > are we sure they weren't intentionally skipping diagnostic there? The behavior before was ``` error: cannot compile this scalar expression yet 2 | __externref_t ref = __builtin_wasm_ref_null_extern(0); | ^ PLEAS

[clang] [WebAssembly][Clang] Add __builtin_wasm_ref_is_null_extern (PR #139580)

2025-05-12 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane edited https://github.com/llvm/llvm-project/pull/139580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [WebAssembly][Clang] Add __builtin_wasm_ref_is_null_extern (PR #139580)

2025-05-12 Thread Hood Chatham via cfe-commits
@@ -168,7 +168,7 @@ bool Sema::checkArgCount(CallExpr *Call, unsigned DesiredArgCount) { return Diag(Range.getBegin(), diag::err_typecheck_call_too_many_args) << 0 /*function call*/ << DesiredArgCount << ArgCount - << /*is non object*/ 0 << Call->getArg(1)-

[clang] [WebAssembly][Clang] Add __builtin_wasm_ref_is_null_extern (PR #139580)

2025-05-12 Thread Hood Chatham via cfe-commits
@@ -168,7 +168,7 @@ bool Sema::checkArgCount(CallExpr *Call, unsigned DesiredArgCount) { return Diag(Range.getBegin(), diag::err_typecheck_call_too_many_args) << 0 /*function call*/ << DesiredArgCount << ArgCount - << /*is non object*/ 0 << Call->getArg(1)-

[clang] [WebAssembly][Clang] Add __builtin_wasm_ref_is_null_extern (PR #139580)

2025-05-12 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/139580 Rate limit ยท GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-

[clang] [WebAssembly][Clang] Add __builtin_wasm_ref_is_null_extern (PR #139580)

2025-05-12 Thread Hood Chatham via cfe-commits
@@ -52,14 +52,33 @@ static bool CheckWasmBuiltinArgIsInteger(Sema &S, CallExpr *E, } bool SemaWasm::BuiltinWasmRefNullExtern(CallExpr *TheCall) { - if (TheCall->getNumArgs() != 0) + if (TheCall->getNumArgs() != 0) { hoodmane wrote: Oh right, `getArg(1)` wi

[clang] [WebAssembly][Clang] Add __builtin_wasm_ref_is_null_extern (PR #139580)

2025-05-12 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane edited https://github.com/llvm/llvm-project/pull/139580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Wasm][Clang] Add __builtin_wasm_ref_is_null_extern (PR #139580)

2025-05-12 Thread Hood Chatham via cfe-commits
@@ -52,14 +52,33 @@ static bool CheckWasmBuiltinArgIsInteger(Sema &S, CallExpr *E, } bool SemaWasm::BuiltinWasmRefNullExtern(CallExpr *TheCall) { - if (TheCall->getNumArgs() != 0) + if (TheCall->getNumArgs() != 0) { hoodmane wrote: If a positive number of

[clang] [Wasm][Clang] Add __builtin_wasm_ref_is_null_extern (PR #139580)

2025-05-12 Thread Hood Chatham via cfe-commits
@@ -741,6 +741,12 @@ __externref_t externref_null() { // WEBASSEMBLY-NEXT: ret } +int externref_is_null(__externref_t arg) { + return __builtin_wasm_ref_is_null_extern(arg); + // WEBASSEMBLY: tail call i32 @llvm.wasm.ref.is_null.extern(ptr addrspace(10) %arg)

[clang] [Wasm][Clang] Add __builtin_wasm_ref_is_null_extern (PR #139580)

2025-05-12 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane updated https://github.com/llvm/llvm-project/pull/139580 >From 2ca282f0a20088bef15289a8ce5167d1e23595c3 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Fri, 9 May 2025 00:16:26 -0400 Subject: [PATCH 1/2] [Wasm][Clang] Add __builtin_wasm_ref_is_null_extern I also

[clang] [Wasm][Clang] Add __builtin_wasm_ref_is_null_extern (PR #139580)

2025-05-12 Thread Hood Chatham via cfe-commits
https://github.com/hoodmane created https://github.com/llvm/llvm-project/pull/139580 I also fixed __builtin_wasm_ref_null_extern() to generate a diagnostic when it gets an argument. It seems like `SemaRef.checkArgCount()` has a bug that makes it unable to check for 0 args. cc @sbc100 @pmatos