Skip to content

Wasm code failing regression probably related to update to LLVM 9 trunk  #63918

Closed
@gui1117

Description

@gui1117

Summary:

The following piece of code fail when compiled to wasm32-unknown-unknown since nightly-2019-07-18. This nightly introduces https://github.com/rust-lang/rust/pull/62592/files so probably related.

Regression test:

pub fn get() -> u128 {
	let d = [0, 0, 32, 59, 157, 181, 5, 111, 0, 0, 0, 0, 0, 0, 0, 0];
	decode_impl(&mut &d[..]).unwrap()
}

#[no_mangle]
fn main() {
	let c: u128 = get();
	assert_eq!(c, 8000000000000000000u128);
}

#[inline(never)]
fn decode_impl(input: &mut &[u8]) -> Result<u128, ()> {
	let mut buf = [0u8; 16];
	read(input, &mut buf)?;
	Ok(<u128>::from_le_bytes(buf))
}

#[inline(never)]
fn read(input: &mut &[u8], into: &mut [u8]) -> Result<(), ()> {
	if into.len() != input.len() {
		return Err(());
	}
	into.copy_from_slice(&input[..]);
	Ok(())
}

with configuration:

[lib]
name = "code"
crate-type = [
	"cdylib",
	"rlib",
]

[profile.release]
opt-level = "z"

Reproduce:

see the repo: https://github.com/thiolliere/wasm-llvm9-issue it contains:

  • javascript file t.js used to execute test with node.
  • make.sh file to execute the test on rust version 2019-07-17 and 2019-07-18.

Notes:

cc @pepyakin

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessO-wasmTarget: WASM (WebAssembly), http://webassembly.org/P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions