Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

ThinLTO duplicates WebAssembly custom sections #37157

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR38184
Status NEW
Importance P enhancement
Reported by Alex Crichton (alex@crichton.co)
Reported on 2018-07-16 13:33:13 -0700
Last modified on 2019-03-08 12:35:20 -0800
Version trunk
Hardware PC Windows NT
CC fitzgen@gmail.com, llvm-bugs@lists.llvm.org, llvm@sunfishcode.online, sbc@chromium.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also

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?

Quuxplusone commented 5 years ago

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

Quuxplusone 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