Skip to content

Commit

Permalink
llvm6: Don't clone LLVM modules on wasm
Browse files Browse the repository at this point in the history
The comment for why cloning exists doesn't actually apply for wasm today and
apparently cloning is causing subtle bugs in LLVM, so let's just avoid it
altogether. More specifically after we emit the assembly for the wasm target we
don't actually use the module again, so there's no need to keep both around.

This seemed to be causing some scary verifier assertions in LLVM which seemed to
be uncovered by presumably (?) buggy behavior. Let's just avoid it for now and
make the wasm target slightly more lean in the process.
  • Loading branch information
alexcrichton committed Jan 24, 2018
1 parent caedb36 commit 63b3168
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/librustc_trans/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ unsafe fn codegen(cgcx: &CodegenContext,
// We can't use the same module for asm and binary output, because that triggers
// various errors like invalid IR or broken binaries, so we might have to clone the
// module to produce the asm output
let llmod = if config.emit_obj {
let llmod = if config.emit_obj && !asm2wasm {
llvm::LLVMCloneModule(llmod)
} else {
llmod
Expand All @@ -742,7 +742,7 @@ unsafe fn codegen(cgcx: &CodegenContext,
write_output_file(diag_handler, tm, cpm, llmod, &path,
llvm::FileType::AssemblyFile)
})?;
if config.emit_obj {
if config.emit_obj && !asm2wasm {
llvm::LLVMDisposeModule(llmod);
}
timeline.record("asm");
Expand Down

0 comments on commit 63b3168

Please sign in to comment.