llvm / llvm/llvm-project

clang aborts with TypeSize::getFixedValue() assertion (!isScalable() || isZero()) when compiling an .ll where a scalable vector value is used in a following basic block

Open
#220,958 1 comment 0 reactions 0 assignees View on GitHub
backend:X86 crash llvm:SelectionDAG
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

An assertions-enabled clang 24 build aborts with Assertion '(!isScalable() || isZero()) && "Request for a fixed element count on a scalable object"' failed when compiling the following LLVM IR file (clang minimal.ll -o repro.out, default options).

### Input Program

```llvm
define void @main() {
%i = insertelement poison, i32 1, i32 0
br label %cont

cont:
%x = add %i, %i
ret void
}
```

### Error Message

```
warning: overriding the module target triple with x86_64-unknown-linux-gnu [-Woverride-module]
clang-24: /root/llvm-project/llvm/include/llvm/Support/TypeSize.h:202: ScalarTy llvm::details::FixedOrScalableQuantity::getFixedValue() const [LeafTy = llvm::TypeSize, ValueTy = unsigned long]: Assertion `(!isScalable() || isZero()) && "Request for a fixed element count on a scalable object"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0. Program arguments: clang-24 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -o minimal.o -x ir minimal.ll
1. Code generation
2. Running pass 'Function Pass Manager' on module 'minimal.ll'.
3. Running pass 'X86 DAG->DAG Instruction Selection' on function '@main'
#15 getCopyToPartsVector(llvm::SelectionDAG&, llvm::SDLoc const&, llvm::SDValue, llvm::SDValue*, unsigned int, llvm::MVT, llvm::Value const*, std::optional) SelectionDAGBuilder.cpp:0:0
#16 getCopyToParts(llvm::SelectionDAG&, llvm::SDLoc const&, llvm::SDValue, llvm::SDValue*, unsigned int, llvm::MVT, llvm::Value const*, std::optional, llvm::ISD::NodeType) SelectionDAGBuilder.cpp:0:0
#17 llvm::RegsForValue::getCopyToRegs(llvm::SDValue, llvm::SelectionDAG&, llvm::SDLoc const&, llvm::SDValue&, llvm::SDValue*, llvm::Value const*, llvm::ISD::NodeType) const
#18 llvm::SelectionDAGBuilder::CopyValueToVirtualRegister(llvm::Value const*, llvm::Register, llvm::ISD::NodeType)
#19 llvm::SelectionDAGBuilder::CopyToExportRegsIfNeeded(llvm::Value const*)
#20 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&)
clang-24: error: unable to execute command: Aborted (core dumped)
clang-24: error: clang frontend command failed with exit code -2 (use -v to see invocation)
```

Version: f8ca8fcb9924b93d1d3b8694f85968f6bdb65ec0

Contributor guide

Open the contributing guide

Research direction

Start by running clang minimal.ll -o repro.out with the IR in the report. Trace the assertion in llvm/include/llvm/Support/TypeSize.h through SelectionDAGBuilder.cpp, especially getCopyToPartsVector and CopyToExportRegsIfNeeded; done means the reproducer compiles without aborting and the regression is covered.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.