LLVM: lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp File Reference (original) (raw)

Fix bitcasted functions.

WebAssembly requires caller and callee signatures to match, however in LLVM, some amount of slop is vaguely permitted. Detect mismatch by looking for bitcasts of functions and rewrite them to use wrapper functions instead.

This doesn't catch all cases, such as when a function's address is taken in one place and casted in another, but it works for many common cases.

Note that LLVM already optimizes away function bitcasts in common cases by dropping arguments as needed, so this pass only ends up getting used in less common cases.

Definition in file WebAssemblyFixFunctionBitcasts.cpp.