Skip to content

LLVM Assertion in autovectorization when compiling with release + overflow-checks since 1.73 #120813

Closed
@DavidBJaffe

Description

@DavidBJaffe

Using Rust 1.76.0 on an Apple M1 Pro with OSX 14.3, using cargo b with opt-level = 3:

fn main() {
    let mut slobber = Vec::<([u8; 52], [u8; 16], usize)>::new();
    slobber.push(([0; 52], [0; 16], 0));
    let mut dels = Vec::<([u8; 16], [u8; 10], i8)>::new();
    let i = 0;
    while i < slobber.len() {
        let j = slobber.len();
        let mut counts = Vec::<(usize, [u8; 16], usize)>::new();
        let mut k = i;
        while k < j {
            let l = slobber.len();
            counts.push((0, [0; 16], 0));
            k = l;
        }
        for u in 1..counts.len() {
            let (b1, b2) = (counts[0].1, counts[u].1);
            let mut diffs = 0;
            for m in 0..16 {
                if b1[m] != b2[m] {
                    diffs += 1;
                }
            }
            if diffs <= 0 {
                dels.push(([0; 16], [0; 10], 0));
            }
        }
    }
}

this happens

mac% cargo b
   Compiling bugsy v0.0.1 (/Users/davidjaffe/repos/infinimmune/bugsy)
error: could not compile `bugsy` (bin "bugsy")

Caused by:
  process didn't exit successfully: `/Users/davidjaffe/.rustup/toolchains/1.76.0-aarch64-apple-darwin/bin/rustc --crate-name bugsy src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=100 --crate-type bin --emit=dep-info,link -C opt-level=3 -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C debug-assertions=on -C metadata=188901b3f11ecd49 -C extra-filename=-188901b3f11ecd49 --out-dir /Users/davidjaffe/repos/infinimmune/bugsy/target/debug/deps -C incremental=/Users/davidjaffe/repos/infinimmune/bugsy/target/debug/incremental -L dependency=/Users/davidjaffe/repos/infinimmune/bugsy/target/debug/deps` (signal: 5, SIGTRAP: trace/breakpoint trap)

The error depends on the optimization level and overflow checking.

Activity

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Feb 8, 2024
added
I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
on Feb 8, 2024
added
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
on Feb 8, 2024
added
I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
and removed
I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Feb 8, 2024
saethlin

saethlin commented on Feb 8, 2024

@saethlin
Member

This is an LLVM assertion that can be hit by compiling for the aarch64-unknown-linux-gnu as well. I suspect any aarch64 target would hit it.

The regression is in nightly-2023-08-09, which is when #114048, the LLVM 17 update landed.

#5  0x00007dc16fedbd46 in __assert_fail (
    assertion=0x7dc167ca4fce <.L.str.95> "VT.isVector() == N1.getValueType().isVector() && \"TRUNCATE result type type should be vector iff the operand \" \"type is vector!\"", 
    file=0x7dc167e993bd <str.6.llvm> "/checkout/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp", line=5734, 
    function=0x7dc1672a701b <.L__PRETTY_FUNCTION__._ZN4llvm12SelectionDAG7getNodeEjRKNS_5SDLocENS_3EVTENS_7SDValueENS_11SDNodeFlagsE> "SDValue llvm::SelectionDAG::getNode(unsigned int, const SDLoc &, EVT, SDValue, const SDNodeFlags)") at assert.c:103
#6  0x00007dc16ecf7219 in llvm::SelectionDAG::getNode(unsigned int, llvm::SDLoc const&, llvm::EVT, llvm::SDValue, llvm::SDNodeFlags) [clone .cold.0] () from /home/ben/rust-master/build/x86_64-unknown-linux-gnu/stage1/lib/libLLVM-17-rust-1.78.0-nightly.so
#7  0x00007dc16e070915 in llvm::SelectionDAG::getZExtOrTrunc(llvm::SDValue, llvm::SDLoc const&, llvm::EVT) ()
   from /home/ben/rust-master/build/x86_64-unknown-linux-gnu/stage1/lib/libLLVM-17-rust-1.78.0-nightly.so
#8  0x00007dc16ca33838 in llvm::AArch64TargetLowering::ReplaceBITCASTResults(llvm::SDNode*, llvm::SmallVectorImpl<llvm::SDValue>&, llvm::SelectionDAG&) const ()
   from /home/ben/rust-master/build/x86_64-unknown-linux-gnu/stage1/lib/libLLVM-17-rust-1.78.0-nightly.so
#9  0x00007dc16ece7e31 in llvm::DAGTypeLegalizer::PromoteIntegerResult(llvm::SDNode*, unsigned int) [clone .cold.0] ()
   from /home/ben/rust-master/build/x86_64-unknown-linux-gnu/stage1/lib/libLLVM-17-rust-1.78.0-nightly.so
#10 0x00007dc16de03705 in llvm::DAGTypeLegalizer::run() ()
   from /home/ben/rust-master/build/x86_64-unknown-linux-gnu/stage1/lib/libLLVM-17-rust-1.78.0-nightly.so
#11 0x00007dc16e2812c9 in llvm::SelectionDAG::LegalizeTypes() ()
   from /home/ben/rust-master/build/x86_64-unknown-linux-gnu/stage1/lib/libLLVM-17-rust-1.78.0-nightly.so
#12 0x00007dc16e2819ca in llvm::SelectionDAGISel::CodeGenAndEmitDAG() ()
   from /home/ben/rust-master/build/x86_64-unknown-linux-gnu/stage1/lib/libLLVM-17-rust-1.78.0-nightly.so
#13 0x00007dc16e48aa1a in llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) ()
   from /home/ben/rust-master/build/x86_64-unknown-linux-gnu/stage1/lib/libLLVM-17-rust-1.78.0-nightly.so
#14 0x00007dc16e1461f9 in llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) ()
   from /home/ben/rust-master/build/x86_64-unknown-linux-gnu/stage1/lib/libLLVM-17-rust-1.78.0-nightly.so
#15 0x00007dc16de332c0 in llvm::MachineFunctionPass::runOnFunction(llvm::Function&) ()
   from /home/ben/rust-master/build/x86_64-unknown-linux-gnu/stage1/lib/libLLVM-17-rust-1.78.0-nightly.so
#16 0x00007dc16e24a4be in llvm::FPPassManager::runOnFunction(llvm::Function&) ()
   from /home/ben/rust-master/build/x86_64-unknown-linux-gnu/stage1/lib/libLLVM-17-rust-1.78.0-nightly.so
#17 0x00007dc16e2493b2 in llvm::FPPassManager::runOnModule(llvm::Module&) ()
   from /home/ben/rust-master/build/x86_64-unknown-linux-gnu/stage1/lib/libLLVM-17-rust-1.78.0-nightly.so
#18 0x00007dc16e4f957a in llvm::legacy::PassManagerImpl::run(llvm::Module&) ()
   from /home/ben/rust-master/build/x86_64-unknown-linux-gnu/stage1/lib/libLLVM-17-rust-1.78.0-nightly.so
#19 0x00007dc171362893 in LLVMRustWriteOutputFile ()
   from /home/ben/rust-master/build/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-0bac2e639c27cdd1.so
changed the title [-]SIGTRAP using 1.76.0 on Apple M1 Pro[/-] [+]LLVM Assertion in autovectorization when compiling with release + overflow-checks since 1.73[/+] on Feb 8, 2024

11 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.llvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixesregression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @nikic@apiraino@dianqk@DavidBJaffe@saethlin

      Issue actions

        LLVM Assertion in autovectorization when compiling with release + overflow-checks since 1.73 · Issue #120813 · rust-lang/rust