As reported in https://bugs.freebsd.org/240765, compiling the commoncpp port with clang 9.0.0 results in an assertion: Assertion failed: (A->getParent() == B->getParent() && "Instructions must be in the same basic block!"), function dominates, file /lib/Analysis/OrderedBasicBlock.cpp, line 68. #0 thr_kill () at thr_kill.S:3 #1 0x0000000804812934 in __raise (s=6) at /usr/src/lib/libc/gen/raise.c:52 #2 0x0000000804785d99 in abort () at /usr/src/lib/libc/stdlib/abort.c:67 #3 0x00000008048025c1 in __assert (func=<optimized out>, file=<optimized out>, line=<optimized out>, failedexpr=<optimized out>) at /usr/src/lib/libc/gen/assert.c:51 #4 0x0000000001d6e6d6 in llvm::OrderedBasicBlock::dominates(llvm::Instruction const*, llvm::Instruction const*) () #5 0x0000000002649878 in eliminateDeadStores(llvm::BasicBlock&, llvm::AAResults*, llvm::MemoryDependenceResults*, llvm::DominatorTree*, llvm::TargetLibraryInfo const*) () #6 0x0000000002650445 in (anonymous namespace)::DSELegacyPass::runOnFunction(llvm::Function&) () #7 0x000000000231b673 in llvm::FPPassManager::runOnFunction(llvm::Function&) () #8 0x00000000020e1b95 in (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) () #9 0x000000000231be62 in llvm::legacy::PassManagerImpl::run(llvm::Module&) () #10 0x0000000002a643d1 in clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream> >) () #11 0x00000000030e6fed in clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) () #12 0x00000000038117e3 in clang::ParseAST(clang::Sema&, bool, bool) () #13 0x000000000304ab0a in clang::FrontendAction::Execute() () #14 0x0000000002fc85c1 in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) () #15 0x00000000030e0dde in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) () #16 0x000000000145c43d in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) () #17 0x000000000145a0db in main () This regressed with https://reviews.llvm.org/rL357222 (Recommit "[DSE] Preserve basic block ordering using OrderedBasicBlock"), which was a recommit of https://reviews.llvm.org/rL357208 for bug 38829. Minimized test case: // clang -cc1 -triple x86_64-- -S -O1 -fexceptions in6addr-min.cpp struct a { int b[6]; }; extern "C" void *memcpy(void *, void *, long); struct c { a *d; int e; c(); }; c::c() : e() { d = new a; memcpy(&d, 0, sizeof(a)); }
This got fixed by https://github.com/llvm/llvm-project/commit/369a9195144.