Open
Description
Compiler explorer: https://godbolt.org/z/r55hMorrY
generated by fuzzer
Code:
int v;
__attribute__((noinline, noclone)) void bar(void) { v++; }
#define T(n, t1, t2, tr, v1, v2, vr, b, o) \
__attribute__((noinline, noclone)) tr t##n##_1##b(t1 x, t2 y) { \
tr r; \
if (__builtin_##b##_overflow(x, y, &r)) \
bar(); \
return r; \
} \
\
__attribute__((noinline, noclone)) tr t##n##_3##b(t2 y) { \
tr r; \
if (__builtin_##b##_overflow((v1), y, &r)) \
bar(); \
return r; \
} \
\
__attribute__((noinline, noclone)) tr t##n##_4##b(t1 x) { \
t2 y = (v2); \
tr r; \
if (__builtin_##b##_overflow(x, y, &r)) \
bar(); \
return r; \
} \
#define ST(n, t, v1, v2, vr, b, o) T(n, t, t, t, v1, v2, vr, b, o)
#define TESTS(type, min, max) \
ST(171, unsigned type, max, 3, 3 * (unsigned type)max, U(u, mul), 1)
#define U(s, op) op
TESTS(_BitInt(119), (-332306998946228968225951765070086143wb - 1),
332306998946228968225951765070086143wb)
Stack trace:
clang: /root/llvm-project/llvm/lib/IR/Instructions.cpp:3033: static llvm::CastInst* llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, const llvm::Twine&, llvm::InsertPosition): Assertion `castIsValid(op, S, Ty) && "Invalid 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 <source>
1. <source>:36:1 <Spelling=<source>:20:3>: current parser token '__attribute__'
2. <source>:36:1 <Spelling=<scratch space>:11:1>: LLVM IR generation of declaration 't171_3mul'
3. <source>:36:1 <Spelling=<scratch space>:11:1>: Generating code for declaration 't171_3mul'
#0 0x0000000003fb0f48 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fb0f48)
#1 0x0000000003faebd4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3faebd4)
#2 0x0000000003ef3728 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x0000772769842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007727698969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x0000772769842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007727698287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x000077276982871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x0000772769839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000038b5c54 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x38b5c54)
#10 0x0000000000ff09b5 llvm::IRBuilderBase::CreateTrunc(llvm::Value*, llvm::Type*, llvm::Twine const&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xff09b5)
#11 0x0000000004847ac3 clang::CodeGen::CodeGenFunction::EmitBuiltinExpr(clang::GlobalDecl, unsigned int, clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4847ac3)
#12 0x000000000432050e clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot, llvm::CallBase**) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x432050e)
#13 0x0000000004392df4 (anonymous namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) CGExprScalar.cpp:0:0
#14 0x0000000004385c20 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#15 0x000000000438bb9c clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x438bb9c)
#16 0x00000000042ef36d clang::CodeGen::CodeGenFunction::EvaluateExprAsBool(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42ef36d)
#17 0x000000000450ab4c clang::CodeGen::CodeGenFunction::EmitBranchOnBoolExpr(clang::Expr const*, llvm::BasicBlock*, llvm::BasicBlock*, unsigned long, clang::Stmt::Likelihood, clang::Expr const*, clang::VarDecl const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x450ab4c)
#18 0x000000000449f7b5 clang::CodeGen::CodeGenFunction::EmitIfStmt(clang::IfStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x449f7b5)
#19 0x00000000044982ae clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44982ae)
#20 0x00000000044a018c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44a018c)
#21 0x000000000450640e clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x450640e)
#22 0x0000000004519714 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4519714)
#23 0x0000000004583cad clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4583cad)
#24 0x000000000457eca4 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x457eca4)
#25 0x000000000457f353 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x457f353)
#26 0x0000000004589ef3 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#27 0x000000000496e0f6 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#28 0x000000000495dbd4 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x495dbd4)
#29 0x0000000006664364 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6664364)
#30 0x000000000496a288 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x496a288)
#31 0x0000000004c640f5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c640f5)
#32 0x0000000004be13fe clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4be13fe)
#33 0x0000000004d565e9 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4d565e9)
#34 0x0000000000d821df cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd821df)
#35 0x0000000000d78dea ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#36 0x00000000049d0d99 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
#37 0x0000000003ef3bc4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ef3bc4)
#38 0x00000000049d13af 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
#39 0x000000000499344d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x499344d)
#40 0x00000000049944de 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+0x49944de)
#41 0x000000000499c1e5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x499c1e5)
#42 0x0000000000d7e6ef clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd7e6ef)
#43 0x0000000000c3c994 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc3c994)
#44 0x0000772769829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#45 0x0000772769829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#46 0x0000000000d78895 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd78895)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134