[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