As reported in https://bugs.freebsd.org/247665, clang 10.0 (and the most recent clang 11) asserts while compiling the emulators/rpcs3 port. This happens during parsing of an expression using __builtin_assume: % cat System-min.cpp // clang -cc1 -triple x86_64-- -S System-min.cpp enum {} a; class b { public: b() { a ? void() : __builtin_assume(0); } } c; % clang -cc1 -triple x86_64-- -S System-min.cpp Assertion failed: (getType() == V->getType() && "All operands to PHI node must be the same type as the PHI node!"), function setIncomingValue, file /home/dim/src/llvm/llvm-project/llvm/include/llvm/IR/Instructions.h, line 2576. PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: clang -cc1 -triple x86_64-- -S System-min.cpp 1. <eof> parser at end of file 2. Per-file LLVM IR generation 3. System-min.cpp:5:3: Generating code for declaration 'b::b' 4. System-min.cpp:5:7: LLVM IR generation of compound statement ('{}') #0 0x000000000304f378 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (clang+0x304f378) #1 0x000000000304d0a8 llvm::sys::RunSignalHandlers() (clang+0x304d0a8) #2 0x000000000304fadd SignalHandler(int) (clang+0x304fadd) #3 0x0000000805750a30 handle_signal /usr/src/lib/libthr/thread/thr_sig.c:0:3
This is coming from clang (front-end) codegen; backtrace: 9 clang 0x00000001133734d3 llvm::PHINode::addIncoming(llvm::Value*, llvm::BasicBlock*) (.cold.6) + 35 10 clang 0x000000010fe079bb llvm::PHINode::addIncoming(llvm::Value*, llvm::BasicBlock*) + 315 11 clang 0x00000001106e8a57 (anonymous namespace)::ScalarExprEmitter::VisitAbstractConditionalOperator(clang::AbstractConditionalOperator const*) + 3079 12 clang 0x00000001106d560b clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) + 107 13 clang 0x000000011068f6c2 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) + 66 14 clang 0x000000011068f66c clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) + 92 15 clang 0x00000001107d4c56 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) + 294 16 clang 0x00000001107de261 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) + 593 17 clang 0x00000001107dd54a clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) + 330 18 clang 0x00000001107d56da clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*) + 154 19 clang 0x00000001107d4b82 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) + 82 20 clang 0x00000001106402f2 clang::CodeGen::CodeGenFunction::EmitConstructorBody(clang::CodeGen::FunctionArgList&) + 610 21 clang 0x000000011082e5da clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 1002
Note that in the mean time, the assertion changed to: Assertion failed: (!areInvalidOperands(C, S1, S2) && "Invalid operands for select"), function init, file /home/dim/src/llvm/llvm-project/llvm/include/llvm/IR/Instructions.h, line 1768. Program received signal SIGABRT, Aborted. Sent by thr_kill() from pid 66194 and user 1236. thr_kill () at thr_kill.S:4 4 thr_kill.S: No such file or directory. (gdb) bt #0 thr_kill () at thr_kill.S:4 #1 0x0000000806309544 in __raise (s=s@entry=6) at /usr/src/lib/libc/gen/raise.c:52 #2 0x00000008063be6a9 in abort () at /usr/src/lib/libc/stdlib/abort.c:67 #3 0x00000008062ec461 in __assert (func=<optimized out>, file=<optimized out>, line=<optimized out>, failedexpr=<optimized out>) at /usr/src/lib/libc/gen/assert.c:51 #4 0x0000000001fdb7a5 in llvm::SelectInst::init(llvm::Value*, llvm::Value*, llvm::Value*) () #5 0x0000000002e4b43d in llvm::IRBuilderBase::CreateSelect(llvm::Value*, llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*) () #6 0x0000000003bdecd8 in (anonymous namespace)::ScalarExprEmitter::VisitAbstractConditionalOperator(clang::AbstractConditionalOperator const*) () #7 0x0000000003bcaeeb in clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) () #8 0x0000000003b1b692 in clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) () #9 0x0000000003b1b639 in clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) () #10 0x0000000003beb9fa in clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) () #11 0x0000000003bf6911 in clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) () #12 0x0000000003bf5951 in clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) () #13 0x0000000003bec16d in clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) () #14 0x0000000003beb91e in clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) () #15 0x0000000003c56c05 in clang::CodeGen::CodeGenFunction::EmitConstructorBody(clang::CodeGen::FunctionArgList&) () #16 0x0000000003b0b337 in clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) () #17 0x0000000003bb46f0 in clang::CodeGen::CodeGenModule::codegenCXXStructor(clang::GlobalDecl) () #18 0x0000000003dd4a51 in (anonymous namespace)::ItaniumCXXABI::emitCXXStructor(clang::GlobalDecl) () #19 0x0000000003a93fd0 in clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) () #20 0x0000000003a874c0 in clang::CodeGen::CodeGenModule::EmitDeferred() () #21 0x0000000003a874ec in clang::CodeGen::CodeGenModule::EmitDeferred() () #22 0x0000000003a85dbc in clang::CodeGen::CodeGenModule::Release() () #23 0x0000000004151424 in (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) () #24 0x000000000414e769 in clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) () #25 0x00000000049a8d03 in clang::ParseAST(clang::Sema&, bool, bool) () #26 0x0000000004094563 in clang::FrontendAction::Execute() () #27 0x000000000401ffe9 in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) () #28 0x00000000041481a1 in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) () #29 0x0000000001bf9b62 in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) () #30 0x0000000001bf7407 in ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) () #31 0x0000000001bf719a in main () It changed between clang 11 and 12, with commit https://github.com/llvm/llvm-project/commit/038edf6029bafe70b1f7165abe2b0e61ddf506b3 ("Don't reject uses of void-returning consteval functions").