llvm / llvm/llvm-project

llvm::DominatorTreeBase::recalculate called on empty function with if-converter

Open
#167,419 2 comments 0 reactions 0 assignees View on GitHub
llvm:adt llvm:codegen
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Repro

```llvm
define i32 @sext_known_nonzero(i16 %xx) {
%x = shl i16 256, %xx
%z = sext i16 %x to i32
%r = call i32 @llvm.cttz.i32(i32 %z, i1 false)
ret i32 %r
}
```

$ llc -start-before=if-converter test.ll

```
:DomTreeBuilder::SemiNCAInfo >::InfoRec; = void; reference = llvm::DomTreeBuilder::SemiNCAInfo >::InfoRec&; size_type = long unsigned int]: Assertion `idx < size()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: ./bin/llc a.ll -start-before=if-converter -print-after-all
1. Running pass 'Function Pass Manager' on module 'a.ll'.
2. Running pass 'X86 Assembly Printer' on function '@sext_known_nonzero'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 llc 0x000055784892fdf6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 59
1 llc 0x00005578489302ba
2 llc 0x000055784892d892 llvm::sys::RunSignalHandlers() + 131
3 llc 0x000055784892f75f
4 libc.so.6 0x00007f9077449df0
5 libc.so.6 0x00007f907749e95c
6 libc.so.6 0x00007f9077449cc2 gsignal + 18
7 libc.so.6 0x00007f90774324ac abort + 34
8 libc.so.6 0x00007f9077432420 __assert_perror_fail + 0
9 llc 0x000055784729b6f0
10 llc 0x0000557847297e83
11 llc 0x00005578472999a8
12 llc 0x00005578472953be
13 llc 0x00005578472918db
14 llc 0x000055784728fc3c void llvm::DomTreeBuilder::Calculate>(llvm::DominatorTreeBase&) + 29
15 llc 0x000055784728f922 llvm::DominatorTreeBase::recalculate(llvm::MachineFunction&) + 52
16 llc 0x0000557846e34e68 llvm::AsmPrinter::emitFunctionBody() + 292
17 llc 0x0000557845b5c481
18 llc 0x00005578472cdbbb llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 1117
19 llc 0x0000557847b5a06b llvm::FPPassManager::runOnFunction(llvm::Function&) + 639
20 llc 0x0000557847b5a2cd llvm::FPPassManager::runOnModule(llvm::Module&) + 97
21 llc 0x0000557847b5a6d8
22 llc 0x0000557847b55f22 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 244
23 llc 0x0000557847b5af03 llvm::legacy::PassManager::run(llvm::Module&) + 39
```

Contributor guide

Open the contributing guide

Research direction

Start by running the supplied test.ll reproducer with llc -start-before=if-converter and inspect the DominatorTreeBase::recalculate path shown in the stack trace. Follow how the if-converter leaves the function and how the X86 Assembly Printer reaches this path; done means the reproducer no longer triggers the assertion and the relevant compiler test covers it.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.