Issue |
130830
|
Summary |
Assertion failure in ConstantExpr::getCast with invalid constant _expression_ cast in vector operation
|
Labels |
new issue
|
Assignees |
|
Reporter |
bi6c
|
Compiler Explorer: https://godbolt.org/z/6Efd8v7Tr
- generated by fuzzer
- tested with flag -std=c2x
```console
<source>:11:1: warning: implicit conversion from '_BitInt(67)' to 'v4si' (vector of 4 'int' values) changes value from 66666666666666666666 to 1107995306 [-Wconstant-conversion]
11 | FOO(v4si, add, +);
| ^~~~~~~~~~~~~~~~~
<source>:8:17: note: expanded from macro 'FOO'
8 | return a OP CONSTANT; \
| ~~ ^~~~~~~~
<source>:4:18: note: expanded from macro 'CONSTANT'
4 | #define CONSTANT 66666666666666666666wb;
| ^~~~~~~~~~~~~~~~~~~~~~
clang: /root/llvm-project/llvm/lib/IR/Constants.cpp:2229: static llvm::Constant* llvm::ConstantExpr::getCast(unsigned int, llvm::Constant*, llvm::Type*, bool): Assertion `CastInst::castIsValid(opc, C, Ty) && "Invalid constantexpr cast!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -fno-verbose-asm -c --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c2x <source>
1. <source>:11:18: current parser token ';'
2. <source>:11:1 <Spelling=<scratch space>:6:1>: LLVM IR generation of declaration 'foo_add_v4si'
3. <source>:11:1 <Spelling=<scratch space>:6:1>: Generating code for declaration 'foo_add_v4si'
#0 0x0000000003e6dcc8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e6dcc8)
#1 0x0000000003e6b984 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e6b984)
#2 0x0000000003db8298 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007b58e8242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007b58e82969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007b58e8242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007b58e82287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007b58e822871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007b58e8239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000036b118b llvm::ConstantExpr::getCast(unsigned int, llvm::Constant*, llvm::Type*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x36b118b)
#10 0x000000000422754c llvm::IRBuilderBase::CreateCast(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, llvm::Twine const&, llvm::MDNode*, llvm::FMFSource) (.constprop.0) CGExprScalar.cpp:0:0
#11 0x0000000004244ee8 (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) CGExprScalar.cpp:0:0
#12 0x000000000423bef6 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#13 0x0000000004249cad clang::CodeGen::CodeGenFunction::EmitPromotedScalarExpr(clang::Expr const*, clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4249cad)
#14 0x000000000424a88c (anonymous namespace)::ScalarExprEmitter::EmitBinOps(clang::BinaryOperator const*, clang::QualType) CGExprScalar.cpp:0:0
#15 0x000000000423cec9 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#16 0x000000000424179c clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x424179c)
#17 0x000000000433dd14 clang::CodeGen::CodeGenFunction::EmitReturnStmt(clang::ReturnStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x433dd14)
#18 0x0000000004346330 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4346330)
#19 0x000000000434e53c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x434e53c)
#20 0x00000000043b3b4c clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x43b3b4c)
#21 0x00000000043c6cbe clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x43c6cbe)
#22 0x000000000443073a clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x443073a)
#23 0x000000000442b9b4 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x442b9b4)
#24 0x000000000442bdcb clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x442bdcb)
#25 0x0000000004436183 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#26 0x00000000048346c6 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#27 0x0000000004824684 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4824684)
#28 0x000000000642f404 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x642f404)
#29 0x0000000004830ea8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4830ea8)
#30 0x0000000004af9d95 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4af9d95)
#31 0x0000000004a7d56e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4a7d56e)
#32 0x0000000004be7f2e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4be7f2e)
#33 0x0000000000d535a7 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd535a7)
#34 0x0000000000d4a36a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#35 0x0000000004879539 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#36 0x0000000003db8744 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3db8744)
#37 0x0000000004879b2f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#38 0x000000000483c07d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x483c07d)
#39 0x000000000483d0fe clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x483d0fe)
#40 0x0000000004845015 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4845015)
#41 0x0000000000d4f843 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd4f843)
#42 0x0000000000c17374 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc17374)
#43 0x00007b58e8229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#44 0x00007b58e8229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#45 0x0000000000d49e15 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd49e15)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
Code:
```c
typedef int v4si __attribute__((vector_size(16)));
#define CONSTANT 66666666666666666666wb;
#define FOO(VTYPE, OP_NAME, OP) \
VTYPE \
foo_##OP_NAME##_##VTYPE(VTYPE a) { \
return a OP CONSTANT; \
}
FOO(v4si, add, +);
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs