<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 - wasm32: Codegen bug at O2 for llc"
href="https://bugs.llvm.org/show_bug.cgi?id=37488">37488</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>wasm32: Codegen bug at O2 for llc
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</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>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=20310" name="attach_20310" title="IR">attachment 20310</a> <a href="attachment.cgi?id=20310&action=edit" title="IR">[details]</a></span>
IR
Originally reported at <a href="https://github.com/rust-lang/rust/issues/50754">https://github.com/rust-lang/rust/issues/50754</a> I've
reduced the test case to a smaller piece of Rust code
(<a href="https://gist.github.com/4b0396c7599d3b15dadc2c82f62b624e">https://gist.github.com/4b0396c7599d3b15dadc2c82f62b624e</a>) which at `-C
opt-level=2` for the Rust compiler generates the attached IR.
When the attached IR is compiled to a wasm object file with O0 it generates a
different answer than when generated with O2:
$ llc bar.ll -filetype=obj -O0 -o bar.o
$ wasm-ld bar.o -o bar.wasm --no-entry
$ node bar.js
0
$ llc bar.ll -filetype=obj -O2 -o bar.o
$ wasm-ld bar.o -o bar.wasm --no-entry
$ node bar.js
65534
where `bar.js` looks like:
const fs = require('fs');
let buf = fs.readFileSync('bar.wasm');
let m = new WebAssembly.Module(buf);
let inst = new WebAssembly.Instance(m, {});
console.log(inst.exports.test());
I unfortunately haven't been able to track this down much farther, but I was
hoping that y'all could help me reduce from here!</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>