llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.92k stars 11.52k forks source link

ThinLTO duplicates WebAssembly custom sections #37532

Open alexcrichton opened 6 years ago

alexcrichton commented 6 years ago
Bugzilla Link 38184
Version trunk
OS Windows NT
CC @sunfishcode,@sbc100

Extended Description

We've recently upgraded to LLVM 7 in the Rust compiler and have started seeing some odd behavior on WebAssembly combined with ThinLTO. We're using LLVM's wasm.custom_sections metadata to create custom sections, but the encoding via a MDNode seems to cause ThinLTO passes to duplicate it accidentally.

Specifically what we're seeing is that we've got two modules A and B. We define a wasm custom section metadata node in module A, but if B imports some functions from A during the ThinLTO passes then it will also import the named MDNode instances from A, causing both A and B to have wasm custom sections defined.

I believe the relevant code is around here -- https://github.com/llvm-mirror/llvm/blob/e5c7b32694a7580b9e7fcd0f1654ac205fc4eea0/lib/Linker/IRMover.cpp#L1105-L1117. Would it be possible to add a special case there to ignore the wasm.custom_section metadata? Or should we be preventing this through some other means?

alexcrichton commented 5 years ago

We do still currently have the relevant block of code to work around this 1, although we haven't tried removing it recently to see if it's still a problem in upstream LLVM

sbc100 commented 5 years ago

Sorry I only just saw this. Is this still and issue for you?

alexcrichton commented 6 years ago

assigned to @sbc100