<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - [WebAssembly] codegen bug during instruction selection"
href="https://bugs.llvm.org/show_bug.cgi?id=40805">40805</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[WebAssembly] codegen bug during instruction selection
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>8.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: WebAssembly
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>alex@crichton.co
</td>
</tr>
<tr>
<th>CC</th>
<td>dan433584@gmail.com, llvm-bugs@lists.llvm.org, tlively@google.com
</td>
</tr></table>
<p>
<div>
<pre>First reported upstream to rust-lang/rust -
<a href="https://github.com/rust-lang/rust/issues/58548">https://github.com/rust-lang/rust/issues/58548</a> - I've managed to reduce this a
little more from the Rust issue report. It looks like during "WebAssembly
Instruction Selection" on the `run_test` function a bug is generated.
All the relevant files for this should be in
<a href="https://gist.github.com/alexcrichton/f0098f0505ce1476a2bef944b03ff06e">https://gist.github.com/alexcrichton/f0098f0505ce1476a2bef944b03ff06e</a>, notably:
* lib.rs -
<a href="https://gist.github.com/alexcrichton/f0098f0505ce1476a2bef944b03ff06e#file-lib-rs">https://gist.github.com/alexcrichton/f0098f0505ce1476a2bef944b03ff06e#file-lib-rs</a>
- the original Rust source used to generate this buggy program
* foo.ll -
<a href="https://gist.github.com/alexcrichton/f0098f0505ce1476a2bef944b03ff06e#file-foo-ll">https://gist.github.com/alexcrichton/f0098f0505ce1476a2bef944b03ff06e#file-foo-ll</a>
- the LLVM IR generated by rustc with LTO (to avoid references to the Rust
standard library).
* foo.js -
<a href="https://gist.github.com/alexcrichton/f0098f0505ce1476a2bef944b03ff06e#file-foo-js">https://gist.github.com/alexcrichton/f0098f0505ce1476a2bef944b03ff06e#file-foo-js</a>
- auxiliary JS for node.js to run the output wasm binary
* build.sh -
<a href="https://gist.github.com/alexcrichton/f0098f0505ce1476a2bef944b03ff06e#file-build-sh">https://gist.github.com/alexcrichton/f0098f0505ce1476a2bef944b03ff06e#file-build-sh</a>
- the invocations of `llc` and `wasm-ld` used to produce a WebAssembly binary.
Using `-opt-bisect-limit` I've found that the pass "WebAssembly Instruction
Selection on function (run_test)" looks to be causing the issue here (different
behavior in optimized vs non-optimized mode). This pass changes the final
output wasm with this diff:
<a href="https://gist.github.com/alexcrichton/5603d6a0e59d638e9ac74751d51f4cad">https://gist.github.com/alexcrichton/5603d6a0e59d638e9ac74751d51f4cad</a>
but I unfortunately can't really make heads or tails of where the bug is.
If any more info is needed from our end please just let me know!</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>