Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__builtin_assume: Assertion failed: (!areInvalidOperands(C, S1, S2) && "Invalid operands for select"), function init, file llvm/include/llvm/IR/Instructions.h, line 1709. #45902

Closed
DimitryAndric opened this issue Jul 2, 2020 · 6 comments
Labels
bugzilla Issues migrated from bugzilla clang:codegen confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@DimitryAndric
Copy link
Collaborator

DimitryAndric commented Jul 2, 2020

Bugzilla Link 46557
Version trunk
OS All
CC @zygoloid,@rotateright

Extended Description

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 ('{}')
#&#8203;0 0x000000000304f378 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (clang+0x304f378)
#&#8203;1 0x000000000304d0a8 llvm::sys::RunSignalHandlers() (clang+0x304d0a8)
#&#8203;2 0x000000000304fadd SignalHandler(int) (clang+0x304fadd)
#&#8203;3 0x0000000805750a30 handle_signal /usr/src/lib/libthr/thread/thr_sig.c:0:3
@rotateright
Copy link
Contributor

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

@DimitryAndric
Copy link
Collaborator Author

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=, file=, line=, failedexpr=) 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 038edf6 ("Don't reject uses of void-returning consteval functions").

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@llvmbot llvmbot added the confirmed Verified by a second party label Jan 26, 2022
@arrowd
Copy link
Contributor

arrowd commented Jun 26, 2022

Still reproducible with

FreeBSD clang version 14.0.3 (https://github.com/llvm/llvm-project.git llvmorg-14.0.3-0-g1f9140064dfb)

@fhahn
Copy link
Contributor

fhahn commented Jul 7, 2022

Also crashes on current main: https://clang.godbolt.org/z/ee7qhrd17

@fhahn fhahn added clang:codegen crash Prefer [crash-on-valid] or [crash-on-invalid] labels Jul 7, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Jul 7, 2022

@llvm/issue-subscribers-clang-codegen

@EugeneZelenko EugeneZelenko removed the clang Clang issues not falling into any other category label Jul 7, 2022
@xgupta
Copy link
Contributor

xgupta commented Jan 25, 2023

Also crashes on current main: https://clang.godbolt.org/z/ee7qhrd17

checked the godbolt link, it is fixed on trunk.

@xgupta xgupta closed this as completed Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:codegen confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

No branches or pull requests

7 participants