llvm / llvm/llvm-project

clang aborts with AllocaInst::getAllocationSize() assertion !Size.isScalable() when compiling an .ll containing an alloca of a scalable-vector array

Open
#220,956 3 comments 0 reactions 0 assignees View on GitHub
confirmed crash-on-valid 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 '!Size.isScalable() && "Array elements cannot have a scalable size"' failed when compiling the following LLVM IR file (clang minimal.ll -o repro.out, default options).

### Input Program

```llvm
define void @main() {
%a = alloca , i32 4, align 1, addrspace(1)
ret void
}
```

### Error Message

```
warning: overriding the module target triple with x86_64-unknown-linux-gnu [-Woverride-module]
clang-24: /root/llvm-project/llvm/lib/IR/Instructions.cpp:81: std::optional llvm::AllocaInst::getAllocationSize(const llvm::DataLayout &) const: Assertion `!Size.isScalable() && "Array elements cannot have a scalable size"' 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'
#13 llvm::AllocaInst::getAllocationSize(llvm::DataLayout const&)
#14 llvm::FunctionLoweringInfo::set(llvm::Function const&, llvm::MachineFunction&, llvm::SelectionDAG*)
#15 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&)
#16 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#17 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&)
#18 llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
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 reproducing the assertion with minimal.ll using the command in the issue. Read llvm/lib/IR/Instructions.cpp around AllocaInst::getAllocationSize(), then trace the reported FunctionLoweringInfo and X86 DAG instruction-selection path. Done means the scalable-vector alloca no longer aborts clang and the regression is covered by a test.

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
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.