[clang] [clang][WebAssembly] Handle casted function pointers with different number of arguments (PR #153168)
Derek Schuff via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 12 11:43:01 PDT 2025
dschuff wrote:
Or another random idea (for the "semi-transparently call with signature mismatches" problem, not the "fix the bugs in my code" problem): What if we represented function pointers (in the source) as being in a different address space, using the existing `address_space(N)` clang/LLVM attributes? They could be freely casted, written into memory and have the same integer values as they otherwise would, but when you call through them, we could either use a generic catch-all thunk like Binaryen's `fpcast-emu` pass does today, or perhaps something more fancy, like a LUT check and a more-specific conversion thunk. That could be feasible if e.g. the `FunctionPointer` C type and `FUNCTION_POINTER` macro could be suitably redefined. Then we maybe wouldn't need any changes to the code at callsites.
https://github.com/llvm/llvm-project/pull/153168
More information about the cfe-commits
mailing list