Why compiling Rust to WebAssembly is slow
Summary
The article analyzes why compiling Rust to WebAssembly with full debug information is unexpectedly slow, tracing the slowdown to DBG_VALUE handling in LLVM and a WebAssembly backend pass. It provides a detailed reproducer, explains the quadratic scan problem, and presents a patch to LLVM that significantly speeds up the WebAssembly codegen, with benchmarking across various crates. The piece highlights implications for Rust-to-Wasm workflows and potential fixes coming from LLVM and compiler improvements.