llvm / llvm/llvm-project

clang aborts with SelectionDAGBuilder::visitLandingPad() assertion Only two-valued landingpads are supported when compiling an .ll containing a landingpad {}

Open
#220,959 1 comment 0 reactions 0 assignees View on GitHub
backend:X86 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 'ValueVTs.size() == 2 && "Only two-valued landingpads are supported"' failed when compiling the following LLVM IR file (clang minimal.ll -o repro.out, default options).

### Input Program

```llvm
define i32 @main() personality ptr @__gxx_personality_v0 {
invoke void @g()
to label %cont unwind label %cleanup

cont:
ret i32 0

cleanup:
%lp = landingpad {}
cleanup
ret i32 1
}

declare void @g()

declare i32 @__gxx_personality_v0(...)
```

### Error Message

```
warning: overriding the module target triple with x86_64-unknown-linux-gnu [-Woverride-module]
clang-24: /root/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:3658: void llvm::SelectionDAGBuilder::visitLandingPad(const llvm::LandingPadInst &): Assertion `ValueVTs.size() == 2 && "Only two-valued landingpads are supported"' 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::SelectionDAGBuilder::visitLandingPad(llvm::LandingPadInst const&)
#14 llvm::SelectionDAGBuilder::visit(unsigned int, llvm::User const&)
#15 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&)
#16 llvm::SelectionDAGISel::SelectBasicBlock(...)
#17 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
#18 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&)
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

Reproduce the crash with clang minimal.ll -o repro.out using the LLVM IR in the issue. Start in llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp at SelectionDAGBuilder::visitLandingPad and trace the ValueVTs handling for the empty landingpad. Done means the reproducer no longer aborts during X86 DAG-to-DAG instruction selection.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.