Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

llvm assertion failure when trying to compile sha2 crate for skylake (with llvm+rustc debug assertions) #100834

Closed
matthiaskrgr opened this issue Aug 21, 2022 · 2 comments · Fixed by #101312
Assignees
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

I have a Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz, so when compiling with -Ctarget-cpu=native this is equivalent to -Ctarget-cpu=skylake.

I have a rustc+llvm that has debug assertions enabled and when I try to compile sha2 v0.10.1 this apparently hits a debug assertion inside llvm:

RUSTFLAGS="-Ctarget-cpu=skylake" RUSTC=/home/matthias/vcs/github/rust_debug_assertions/build/x86_64-unknown-linux-gnu/stage1/bin/rustc cargo build --release

   Compiling sha2 v0.10.1 (/tmp/sha)
rustc: /home/matthias/vcs/github/rust_debug_assertions/src/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:2556: llvm::slpvectorizer::BoUpSLP::TreeEntry *llvm::slpvectorizer::BoUpSLP::newTreeEntry(ArrayRef<llvm::Value *>, TreeEntry::EntryState, Optional<llvm::slpvectorizer::BoUpSLP::ScheduleData *>, const (anonymous namespace)::InstructionsState &, const llvm::slpvectorizer::BoUpSLP::EdgeInfo &, ArrayRef<int>, ArrayRef<unsigned int>): Assertion `!getTreeEntry(V) && "Scalar already in tree!"' failed.
sccache: Compiler killed by signal 6
error: could not compile `sha2`

Caused by:
  process didn't exit successfully: `/home/matthias/.cargo/bin/sccache /home/matthias/vcs/github/rust_debug_assertions/build/x86_64-unknown-linux-gnu/stage1/bin/rustc --crate-name sha2 --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=96ac895c949c4242 -C extra-filename=-96ac895c949c4242 --out-dir /tmp/sha/target/release/deps -L dependency=/tmp/sha/target/release/deps --extern cfg_if=/tmp/sha/target/release/deps/libcfg_if-19e7cc0b6f708960.rmeta --extern cpufeatures=/tmp/sha/target/release/deps/libcpufeatures-60eedbcf432061e3.rmeta --extern digest=/tmp/sha/target/release/deps/libdigest-d6ef0fdeb4fc592a.rmeta -Ctarget-cpu=skylake` (exit status: 254)

This rustc used is built with rustc debug assertions and llvm debug assertions and I noticed this crash during stage 2 of x.py build boostrap.

bootstrap was done with

changelog-seen = 2
[llvm]
download-ci-llvm = false
assertions = true
ninja = true
targets = "X86"
link-jobs = 2
[build]
extended = true
tools = ["cargo", "rls", "clippy", "rustfmt", "analysis", "src"] # + "rust-demangler" if `profiler`
low-priority = true
[install]
[rust]
debug = true
debug-assertions = true
debug-assertions-std = true
overflow-checks = true
overflow-checks-std = true
debuginfo-level = 1
backtrace-on-ice = true
verify-llvm-ir = true
[target.x86_64-unknown-linux-gnu]
[dist]
@matthiaskrgr matthiaskrgr added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Aug 21, 2022
@matthiaskrgr
Copy link
Member Author

I had a quick look into the crate and it seems to have some special avx2 related code, so there might be some unsafe that rustc cannot judge which later causes the assertion failure in llvm 🤔

@nikic
Copy link
Contributor

nikic commented Aug 30, 2022

Upstream issue: llvm/llvm-project#57447

@nikic nikic self-assigned this Aug 30, 2022
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 4, 2022
Update LLVM submodule

This updates to the current 15.x branch plus one cherry-pick.

Fixes rust-lang#100834.
Fixes rust-lang#101121.
@bors bors closed this as completed in 8bed0f2 Sep 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants