Skip to content

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

@hiraditya

Description

@hiraditya

Repro

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<llvm::DominatorTreeBase<llvm::MachineBasicBlock, false> >::InfoRec; <template-parameter-1-2> = void; reference = llvm::DomTreeBuilder::SemiNCAInfo<llvm::DominatorTreeBase<llvm::MachineBasicBlock, false> >::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<llvm::MachineBasicBlock, false>>(llvm::DominatorTreeBase<llvm::MachineBasicBlock, false>&) + 29
15 llc       0x000055784728f922 llvm::DominatorTreeBase<llvm::MachineBasicBlock, false>::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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions