[WebAssembly] Fixed AsmPrinter not emitting .functype for intrinsics
authorWouter van Oortmerssen <aardappel@gmail.com>
Tue, 22 Feb 2022 23:45:49 +0000 (15:45 -0800)
committerWouter van Oortmerssen <aardappel@gmail.com>
Wed, 23 Feb 2022 00:14:26 +0000 (16:14 -0800)
commit2368f18eb305ae9d5a4f2110c048e5daf5007992
treebae3e4966a20c67c66399c88045fdf8fa329ac93
parent8b9f42b61b33ec1493e6d71d0240da6dfc847be2
[WebAssembly] Fixed AsmPrinter not emitting .functype for intrinsics

Intrinsics like `memset` were not emitted as `.functype` because
WebAssemblyAsmPrinter::emitExternalDecls explicitly skips symbols
that are isIntrinsic. Removing that check doesn't work, since the symbol
from the module refers to a 4-argument `llvm.memset.p0i8.i32` rather
than the 3-argument `memset` symbol referenced in the call.
Our `WebAssemblyMCLowerPrePass` however does collect the
`memset` symbol, so the current solution is as simple as emitting
`.functype` for those.

Fixes: https://github.com/llvm/llvm-project/issues/53712

Differential Revision: https://reviews.llvm.org/D120365
llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
llvm/test/MC/WebAssembly/extern-functype-intrinsic.ll [new file with mode: 0644]