[globalopt] Crash after dropping user that still has debug value
| Bugzilla Link | 26786 |
| Resolution | FIXED |
| Resolved on | May 01, 2020 04:05 |
| Version | trunk |
| OS | Linux |
| Attachments | Reduced input file with crash in globalopt |
| CC | @ekatz |
Extended Description
With the attached file running:
opt -globalopt -o /dev/null bugpoint-reduced-simplified.ll
crashes like this: opt: ../include/llvm/Support/Casting.h:81: static bool llvm::isa_impl_cl<llvm::BasicBlock, llvm::Value >::doit(const From ) [To = llvm::BasicBlock, From = llvm::Value ]: Assertion `Val && "isa<> used on a null pointer"' failed. 0 opt 0x00000000023c542e llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 46 1 opt 0x00000000023c5839 2 opt 0x00000000023c4143 llvm::sys::RunSignalHandlers() + 131 3 opt 0x00000000023c5c7f 4 libpthread.so.0 0x00007f88d8f5e340 5 libc.so.6 0x00007f88d8186cc9 gsignal + 57 6 libc.so.6 0x00007f88d818a0d8 abort + 328 7 libc.so.6 0x00007f88d817fb86 8 libc.so.6 0x00007f88d817fc32 9 opt 0x0000000000ea11ae 10 opt 0x0000000000ea1158 11 opt 0x0000000000ea1132 12 opt 0x0000000000ea10d5 13 opt 0x0000000001937277 llvm::ValueEnumerator::EnumerateValue(llvm::Value const) + 471 14 opt 0x000000000193789d llvm::ValueEnumerator::EnumerateMetadata(llvm::Metadata const) + 301 15 opt 0x000000000193638e llvm::ValueEnumerator::ValueEnumerator(llvm::Module const&, bool) + 2702 16 opt 0x0000000001909052 17 opt 0x0000000001908bff llvm::WriteBitcodeToFile(llvm::Module const, llvm::raw_ostream&, bool, bool) + 335 18 opt 0x0000000001908a90 19 opt 0x0000000001dca9e1 20 opt 0x0000000001dca4db llvm::legacy::PassManagerImpl::run(llvm::Module&) + 347 21 opt 0x0000000001dcaf21 llvm::legacy::PassManager::run(llvm::Module&) + 33 22 opt 0x000000000091f2ec main + 8588 23 libc.so.6 0x00007f88d8171ec5 __libc_start_main + 245 24 opt 0x00000000008f3748 Stack dump: 0. Program arguments: build-master/bin/opt -globalopt -o /dev/null bugpoint-reduced-simplified.ll
-
Running pass 'Bitcode Writer' on module 'bugpoint-reduced-simplified.ll'.
Aborted
I have been debugging this for a while and found that globalopt tries to extract the bitcast from:
store i16 0, i16* bitcast (i16** @a.1 to i16*), align 8, !dbg !11
This bitcast also exists in debug info:
tail call void @llvm.dbg.value(metadata i16* bitcast (i16** @a.1 to i16*), i64 0, metadata !1, metadata !9), !dbg !10
In makeAllConstantUsesInstructions(Constant *C) dropAllReferences is called on the bitcast expression and this seems to break the instruction with the llvm.dbg.value
Fixed in LLVM 5.0.
Updated reproducer The previous reproducer didn't adhere to current expectations on ll-files. Patched it to work again and verified that it still crashes globalopt.