llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.77k stars 11.9k forks source link

clang++ (inline-asm): segment fault in RegAllocFast::allocVirtReg / assertion `V->getType()->isIntOrIntVectorTy() && DestTy->isIntOrIntVectorTy() && "Can only zero extend/truncate integers!"' failed #48510

Open llvmbot opened 3 years ago

llvmbot commented 3 years ago
Bugzilla Link 49166
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @chengniansun,@zygoloid

Extended Description

Hi,

There is an assertion failure on version 11.1.0. But it also affects other versions (I additionally test it with 12.0.0 and my apt-installed 6.0.0).

Details of version 11.1.0 are attached below. With version 6.0.0 (w/o assertion), it encounters a fatal error in backend.

I suspect it is due to the inlined asm. Additionally, the poc file can be successfully compiled by gcc.

My system is Ubuntu 18.04, x86-64. Please let me know if there is anything I can help with. Thanks!

==== detailed information ====

$ ./clang poc.c
clang-11: /home/xxx/data/git/llvm-project/llvm/include/llvm/IR/IRBuilder.h:1976: llvm::Value *llvm::IRBuilderBase::CreateZExtOrTrunc(llvm::Value *, llvm::Type *, const llvm::Twine &): Assertion `V->getType()->isIntOrIntVectorTy() && DestTy->isIntOrIntVectorTy() && "Can only zero extend/truncate integers!"' failed.
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: /data/xxx/git/llvm-project/build/bin/clang-11 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name poc.c -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /data/xxx/git/llvm-project/build/lib/clang/11.1.0 -internal-isystem /usr/local/include -internal-isystem /data/xxx/git/llvm-project/build/lib/clang/11.1.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /data/xxx/docker_share/clang/11.x -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -o /tmp/poc-00c026.o -x c poc.c
1.      <eof> parser at end of file
2.      poc.c:2:5: LLVM IR generation of declaration 'main'
3.      poc.c:2:5: Generating code for declaration 'main'
 #0 0x0000000006e97306 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/xxx/data/git/llvm-project/llvm/lib/Support/Unix/Signals.inc:560:7
 #1 0x0000000006e9266e llvm::sys::RunSignalHandlers() /home/xxx/data/git/llvm-project/llvm/lib/Support/Signals.cpp:69:18
 #2 0x0000000006e97caa SignalHandler(int) /home/xxx/data/git/llvm-project/llvm/lib/Support/Unix/Signals.inc:396:3
 #3 0x00007f1f2d9698a0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
 #4 0x00007f1f2c62ff47 gsignal /build/glibc-2ORdQG/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f1f2c6318b1 abort /build/glibc-2ORdQG/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007f1f2c62142a __assert_fail_base /build/glibc-2ORdQG/glibc-2.27/assert/assert.c:89:0
 #7 0x00007f1f2c6214a2 (/lib/x86_64-linux-gnu/libc.so.6+0x304a2)
 #8 0x0000000000f20fa0 std::_Rb_tree_iterator<std::pair<unsigned long const, llvm::Value*> > std::_Rb_tree<unsigned long, std::pair<unsigned long const, llvm::Value*>, std::_Select1st<std::pair<unsigned long const, llvm::Value*> >, std::less<unsigned long>, std::allocator<std::pair<unsigned long const, llvm::Value*> > >::_M_emplace_hint_unique<std::piecewise_construct_t const&, std::tuple<unsigned long&&>, std::tuple<> >(std::_Rb_tree_const_iterator<std::pair<unsigned long const, llvm::Value*> >, std::piecewise_construct_t const&, std::tuple<unsigned long&&>&&, std::tuple<>&&) /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_tree.h:2397:0
 #9 0x00000000077320ef clang::CodeGen::CodeGenFunction::EmitAsmStmt(clang::AsmStmt const&) /home/xxx/data/git/llvm-project/clang/lib/CodeGen/CGStmt.cpp:0:23
#10 0x000000000771e287 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) /home/xxx/data/git/llvm-project/clang/lib/CodeGen/CGStmt.cpp:152:32
#11 0x00000000077367c8 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) /home/xxx/data/git/llvm-project/clang/lib/CodeGen/CGStmt.cpp:416:11
#12 0x0000000007841dec clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) /home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1147:5
#13 0x0000000007843de2 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) /home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1322:7
#14 0x00000000078a5878 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) /home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:4528:3
#15 0x000000000788f7dc clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) /home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:2891:3
#16 0x0000000007899c6a clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) /home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:2642:5
#17 0x00000000078ae3ef clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) /home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:5342:5
#18 0x00000000099efef7 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) /home/xxx/data/git/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp:169:35
#19 0x00000000099e69f6 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) /home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:216:11
#20 0x000000000c81d02d clang::ParseAST(clang::Sema&, bool, bool) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseAST.cpp:162:31
#21 0x000000000861c2a2 clang::ASTFrontendAction::ExecuteAction() /home/xxx/data/git/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1059:1
#22 0x00000000099decd8 clang::CodeGenAction::ExecuteAction() /home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1184:28
#23 0x000000000861a51a clang::FrontendAction::Execute() /home/xxx/data/git/llvm-project/clang/lib/Frontend/FrontendAction.cpp:954:10
#24 0x000000000854eaa7 llvm::Error::operator bool() /home/xxx/data/git/llvm-project/llvm/include/llvm/Support/Error.h:0:0
#25 0x000000000854eaa7 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/xxx/data/git/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:984:0
#26 0x00000000088f183f clang::CompilerInstance::getFrontendOpts() /home/xxx/data/git/llvm-project/clang/include/clang/Frontend/CompilerInstance.h:0:0
#27 0x00000000088f183f clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/xxx/data/git/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:279:0
#28 0x0000000000b094cc llvm::TimeTraceScope::~TimeTraceScope() /home/xxx/data/git/llvm-project/llvm/include/llvm/Support/TimeProfiler.h:0:0
#29 0x0000000000b094cc cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/xxx/data/git/llvm-project/clang/tools/driver/cc1_main.cpp:241:0
#30 0x0000000000afaf3b ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) /home/xxx/data/git/llvm-project/clang/tools/driver/driver.cpp:330:12
#31 0x0000000000af6966 main /home/xxx/data/git/llvm-project/clang/tools/driver/driver.cpp:407:12
#32 0x00007f1f2c612b97 __libc_start_main /build/glibc-2ORdQG/glibc-2.27/csu/../csu/libc-start.c:344:0
#33 0x0000000000af38ea _start (/data/xxx/git/llvm-project/build/bin/clang-11+0xaf38ea)
clang-11: error: unable to execute command: Aborted (core dumped)
clang-11: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 11.1.0 (https://github.com/llvm/llvm-project.git 1fdec59bffc11ae37eb51a1b9869f0696bfd5312)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /data/xxx/git/llvm-project/build/bin
clang-11: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-11: note: diagnostic msg: /tmp/poc-e50460.c
clang-11: note: diagnostic msg: /tmp/poc-e50460.sh
clang-11: note: diagnostic msg:

********************

$ cat /tmp/poc-e50460.c

# 1 "<built-in>"
# 1 "poc.c"
int a;
int main() { asm("" : "=a"(a), "=d"(a) : "1"(.1)); }

$ cat /tmp/poc-e50460.sh

# Crash reproducer for clang version 11.1.0 (https://github.com/llvm/llvm-project.git 1fdec59bffc11ae37eb51a1b9869f0696bfd5312)
# Driver args: "poc.c"
# Original command:  "/data/zhan3299/git/llvm-project/build/bin/clang-11" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-main-file-name" "poc.c" "-mrelocation-model" "static" "-mframe-pointer=all" "-fmath-errno" "-fno-rounding-math" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-fno-split-dwarf-inlining" "-debugger-tuning=gdb" "-resource-dir" "/data/zhan3299/git/llvm-project/build/lib/clang/11.1.0" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/data/zhan3299/git/llvm-project/build/lib/clang/11.1.0/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-fdebug-compilation-dir" "/data/zhan3299/docker_share/clang/11.x" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig" "-o" "/tmp/poc-00c026.o" "-x" "c" "poc.c"
 "/data/zhan3299/git/llvm-project/build/bin/clang-11" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-main-file-name" "poc.c" "-mrelocation-model" "static" "-mframe-pointer=all" "-fmath-errno" "-fno-rounding-math" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-fno-split-dwarf-inlining" "-debugger-tuning=gdb" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig" "-x" "c" "poc-e50460.c"
chengniansun commented 3 years ago

A duplicate.

$ clang-trunk -v clang version 13.0.0 (https://github.com/llvm/llvm-project.git 2e9c75daffddd65e37c3236708b5b133e6f5f2f5) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/cnsun/usr/bin Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9 Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10 Candidate multilib: .;@m64 Candidate multilib: 32;@m32 Candidate multilib: x32;@mx32 Selected multilib: .;@m64

$ cat mutant.c a; reset() { asm("" : "=r"(a) : "0"(23.23)); }

$ clang-trunk mutant.c mutant.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int] a; ^ mutant.c:2:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int] reset() { asm("" : "=r"(a) : "0"(23.23)); } ^ mutant.c:2:43: warning: non-void function does not return a value [-Wreturn-type] reset() { asm("" : "=r"(a) : "0"(23.23)); } ^ clang-13: /tmp/tmp.xjN6dMkdrg-clang-builder/llvm-project/llvm/include/llvm/IR/IRBuilder.h:1994: llvm::Value llvm::IRBuilderBase::CreateZExtOrTrunc(llvm::Value, llvm::Type*, const llvm::Twine&): Assertion `V->getType()->isIntOrIntVectorTy() && DestTy->isIntOrIntVectorTy() && "Can only zero extend/truncate integers!"' failed. PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump:

  1. Program arguments: /scratch/software/clang-trunk/bin/clang-13 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -main-file-name mutant.c -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/scratch/cnsun/workspace/perses-fuzzer/default_c_finding_folder/crash_20210624_093415_031d/delta/perses_result -resource-dir /scratch/software/clang-trunk/lib/clang/13.0.0 -c-isystem . -c-isystem /usr/local/include/cmsith -internal-isystem /scratch/software/clang-trunk/lib/clang/13.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/scratch/cnsun/workspace/perses-fuzzer/default_c_finding_folder/crash_20210624_093415_031d/delta/perses_result -ferror-limit 19 -fgnuc-version=4.2.1 -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/mutant-171a12.o -x c mutant.c
  2. parser at end of file
  3. mutant.c:2:1: LLVM IR generation of declaration 'reset'
  4. mutant.c:2:1: Generating code for declaration 'reset'

    ​0 0x0000564810de6184 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0

    ​1 0x0000564810de393e SignalHandler(int) Signals.cpp:0:0

    ​2 0x00007f4e3cbb73c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)

    ​3 0x00007f4e3c65618b raise /build/glibc-ZN95T4/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1

    ​4 0x00007f4e3c635859 abort /build/glibc-ZN95T4/glibc-2.31/stdlib/abort.c:81:7

    ​5 0x00007f4e3c635729 get_sysdep_segment_value /build/glibc-ZN95T4/glibc-2.31/intl/loadmsgcat.c:509:8

    ​6 0x00007f4e3c635729 _nl_load_domain /build/glibc-ZN95T4/glibc-2.31/intl/loadmsgcat.c:970:34

    ​7 0x00007f4e3c646f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)

    ​8 0x0000564811173cd7 clang::CodeGen::CodeGenFunction::EmitAsmStmt(clang::AsmStmt const&) (/scratch/software/clang-trunk/bin/clang-13+0x3ce8cd7)

    ​9 0x0000564811175e8b clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const, llvm::ArrayRef<clang::Attr const>) (/scratch/software/clang-trunk/bin/clang-13+0x3ceae8b)

    ​10 0x000056481117c0bc clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/scratch/software/clang-trunk/bin/clang-13+0x3cf10bc)

    ​11 0x00005648111d3501 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/scratch/software/clang-trunk/bin/clang-13+0x3d48501)

    ​12 0x00005648111e4d5c clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/scratch/software/clang-trunk/bin/clang-13+0x3d59d5c)

    ​13 0x000056481123e3f6 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/scratch/software/clang-trunk/bin/clang-13+0x3db33f6)

    ​14 0x0000564811239f45 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/scratch/software/clang-trunk/bin/clang-13+0x3daef45)

    ​15 0x000056481123a3ab clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/scratch/software/clang-trunk/bin/clang-13+0x3daf3ab)

    ​16 0x0000564811242e62 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0

    ​17 0x0000564811f457e9 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0

    ​18 0x0000564811f379d0 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/scratch/software/clang-trunk/bin/clang-13+0x4aac9d0)

    ​19 0x0000564812ffb2b4 clang::ParseAST(clang::Sema&, bool, bool) (/scratch/software/clang-trunk/bin/clang-13+0x5b702b4)

    ​20 0x0000564811f42968 clang::CodeGenAction::ExecuteAction() (/scratch/software/clang-trunk/bin/clang-13+0x4ab7968)

    ​21 0x00005648117f2599 clang::FrontendAction::Execute() (/scratch/software/clang-trunk/bin/clang-13+0x4367599)

    ​22 0x00005648117857e6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/scratch/software/clang-trunk/bin/clang-13+0x42fa7e6)

    ​23 0x00005648118d0480 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/scratch/software/clang-trunk/bin/clang-13+0x4445480)

    ​24 0x000056480e6f0696 cc1_main(llvm::ArrayRef<char const>, char const, void*) (/scratch/software/clang-trunk/bin/clang-13+0x1265696)

    ​25 0x000056480e6ec9d8 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0

    ​26 0x000056480e61a0e6 main (/scratch/software/clang-trunk/bin/clang-13+0x118f0e6)

    ​27 0x00007f4e3c6370b3 __libc_start_main /build/glibc-ZN95T4/glibc-2.31/csu/../csu/libc-start.c:342:3

    ​28 0x000056480e6ec54e _start (/scratch/software/clang-trunk/bin/clang-13+0x126154e)

    clang-13: error: unable to execute command: Aborted (core dumped) clang-13: error: clang frontend command failed due to signal (use -v to see invocation) clang version 13.0.0 (https://github.com/llvm/llvm-project.git 2e9c75daffddd65e37c3236708b5b133e6f5f2f5) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/cnsun/usr/bin clang-13: note: diagnostic msg:


PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang-13: note: diagnostic msg: /tmp/mutant-d49756.c clang-13: note: diagnostic msg: /tmp/mutant-d49756.sh clang-13: note: diagnostic msg:


llvmbot commented 3 years ago

It also affects trunk (https://godbolt.org/z/4P5fv9).

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: /opt/compiler-explorer/clang-trunk/bin/clang++ -g -o ./output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1.  <eof> parser at end of file
2.  Code generation
3.  Running pass 'Function Pass Manager' on module '<source>'.
4.  Running pass 'Fast Register Allocator' on function '@main'
 #0 0x000055921250db2c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3061b2c)
 #1 0x000055921250b8d4 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x305f8d4)
 #2 0x000055921250bb55 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x305fb55)
 #3 0x00005592124724d8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x00007f337b33f3c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #5 0x0000559211c0ebf4 (anonymous namespace)::RegAllocFast::allocVirtReg(llvm::MachineInstr&, (anonymous namespace)::RegAllocFast::LiveReg&, llvm::Register, bool) RegAllocFast.cpp:0:0
 #6 0x0000559211c111c6 (anonymous namespace)::RegAllocFast::allocateInstruction(llvm::MachineInstr&) RegAllocFast.cpp:0:0
 #7 0x0000559211c13519 (anonymous namespace)::RegAllocFast::runOnMachineFunction(llvm::MachineFunction&) RegAllocFast.cpp:0:0
 #8 0x0000559211964008 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x24b8008)
 #9 0x0000559211d5bf27 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x28aff27)
#10 0x0000559211d5c641 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x28b0641)
#11 0x0000559211d5b29f llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x28af29f)
#12 0x00005592127b9692 (anonymous namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) BackendUtil.cpp:0:0
#13 0x00005592127bd755 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3311755)
#14 0x000055921338b52a clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3edf52a)
#15 0x000055921415d069 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4cb1069)
#16 0x000055921338b5e2 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3edf5e2)
#17 0x0000559212d882e1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x38dc2e1)
#18 0x0000559212d1f013 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3873013)
#19 0x0000559212e4f7c3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x39a37c3)
#20 0x00005592104a1f8c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xff5f8c)
#21 0x000055921049e0ad ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#22 0x0000559212bd5cc5 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#23 0x00005592124725b3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2fc65b3)
#24 0x0000559212bd65f8 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (.part.165) Job.cpp:0:0
#25 0x0000559212baf669 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3703669)
#26 0x0000559212bb088f clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x370488f)
#27 0x0000559212bc04f5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x37144f5)
#28 0x00005592103bbed4 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0xf0fed4)
#29 0x00007f337adf00b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#30 0x000055921049dc2a _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0xff1c2a)
clang-13: error: clang frontend command failed with exit code 139 (use -v to see invocation)
ASM generation compiler returned: 139
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: /opt/compiler-explorer/clang-trunk-20210218/bin/clang-13 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -main-file-name example.cpp -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -resource-dir /opt/compiler-explorer/clang-trunk-20210218/lib/clang/13.0.0 -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/11.0.0/../../../../include/c++/11.0.0 -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/11.0.0/../../../../include/c++/11.0.0/x86_64-linux-gnu -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/11.0.0/../../../../include/c++/11.0.0/backward -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/clang-trunk-20210218/lib/clang/13.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir=/home/ce -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -o /tmp/example-b5eef3.o -x c++ <source>
1.  <eof> parser at end of file
2.  Code generation
3.  Running pass 'Function Pass Manager' on module '<source>'.
4.  Running pass 'Fast Register Allocator' on function '@main'
 #0 0x0000563524506b2c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk-20210218/bin/clang-13+0x3061b2c)
 #1 0x00005635245048d4 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-trunk-20210218/bin/clang-13+0x305f8d4)
 #2 0x0000563524504a43 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f3d7d3c23c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #4 0x0000563523c07bf4 (anonymous namespace)::RegAllocFast::allocVirtReg(llvm::MachineInstr&, (anonymous namespace)::RegAllocFast::LiveReg&, llvm::Register, bool) RegAllocFast.cpp:0:0
 #5 0x0000563523c0a1c6 (anonymous namespace)::RegAllocFast::allocateInstruction(llvm::MachineInstr&) RegAllocFast.cpp:0:0
 #6 0x0000563523c0c519 (anonymous namespace)::RegAllocFast::runOnMachineFunction(llvm::MachineFunction&) RegAllocFast.cpp:0:0
 #7 0x000056352395d008 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk-20210218/bin/clang-13+0x24b8008)
 #8 0x0000563523d54f27 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk-20210218/bin/clang-13+0x28aff27)
 #9 0x0000563523d55641 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk-20210218/bin/clang-13+0x28b0641)
#10 0x0000563523d5429f llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk-20210218/bin/clang-13+0x28af29f)
#11 0x00005635247b2692 (anonymous namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) BackendUtil.cpp:0:0
#12 0x00005635247b6755 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/opt/compiler-explorer/clang-trunk-20210218/bin/clang-13+0x3311755)
#13 0x000056352538452a clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk-20210218/bin/clang-13+0x3edf52a)
#14 0x0000563526156069 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk-20210218/bin/clang-13+0x4cb1069)
#15 0x00005635253845e2 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk-20210218/bin/clang-13+0x3edf5e2)
#16 0x0000563524d812e1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk-20210218/bin/clang-13+0x38dc2e1)
#17 0x0000563524d18013 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk-20210218/bin/clang-13+0x3873013)
#18 0x0000563524e487c3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk-20210218/bin/clang-13+0x39a37c3)
#19 0x000056352249af8c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk-20210218/bin/clang-13+0xff5f8c)
#20 0x00005635224970ad ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#21 0x00005635223b3f12 main (/opt/compiler-explorer/clang-trunk-20210218/bin/clang-13+0xf0ef12)
#22 0x00007f3d7ce730b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#23 0x0000563522496c2a _start (/opt/compiler-explorer/clang-trunk-20210218/bin/clang-13+0xff1c2a)
clang-13: error: unable to execute command: Segmentation fault (core dumped)
clang-13: error: clang frontend command failed due to signal (use -v to see invocation)
Execution build compiler returned: 254
Endilll commented 1 year ago

The original test case is still crashing on post-17 trunk: https://godbolt.org/z/aGsKq33xn

clang++: /root/llvm-project/llvm/include/llvm/IR/IRBuilder.h:1993:
llvm::Value* llvm::IRBuilderBase::CreateZExtOrTrunc(llvm::Value*, llvm::Type*, const llvm::Twine&):
Assertion `V->getType()->isIntOrIntVectorTy() && DestTy->isIntOrIntVectorTy() && "Can only zero extend/truncate integers!"' 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 -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -x c -Wno-implicit-int -Wno-implicit-function-declaration <source>
1.  <eof> parser at end of file
2.  <source>:2:5: LLVM IR generation of declaration 'main'
3.  <source>:2:5: Generating code for declaration 'main'
 #0 0x00000000036afc28 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36afc28)
 #1 0x00000000036ad8ec llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36ad8ec)
 #2 0x00000000035f6d08 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f478fd8b420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f478f84e00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #5 0x00007f478f82d859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x00007f478f82d729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #7 0x00007f478f83efd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #8 0x00000000039bba72 EmitAsmStores(clang::CodeGen::CodeGenFunction&, clang::AsmStmt const&, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::Type*>, llvm::ArrayRef<llvm::Type*>, llvm::ArrayRef<clang::CodeGen::LValue>, llvm::ArrayRef<clang::QualType>, llvm::BitVector const&, llvm::BitVector const&) CGStmt.cpp:0:0
 #9 0x00000000039c8511 clang::CodeGen::CodeGenFunction::EmitAsmStmt(clang::AsmStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x39c8511)
#10 0x00000000039cae0b clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x39cae0b)
#11 0x00000000039d113c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x39d113c)
#12 0x0000000003a2eab6 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a2eab6)
#13 0x0000000003a41c5a clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a41c5a)
#14 0x0000000003aa2fe3 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3aa2fe3)
#15 0x0000000003a9e0d5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a9e0d5)
#16 0x0000000003a9e69b clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a9e69b)
#17 0x0000000003aa7b13 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#18 0x00000000049126c6 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#19 0x00000000049032d8 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49032d8)
#20 0x0000000005e04a04 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5e04a04)
#21 0x000000000490f578 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x490f578)
#22 0x0000000004177f89 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4177f89)
#23 0x00000000040f818e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40f818e)
#24 0x00000000042561fe clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42561fe)
#25 0x0000000000bd6ea0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbd6ea0)
#26 0x0000000000bcf0ca ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#27 0x0000000003f59309 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
#28 0x00000000035f71b4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x35f71b4)
#29 0x0000000003f598ff 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
#30 0x0000000003f21c85 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f21c85)
#31 0x0000000003f226ed 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+++0x3f226ed)
#32 0x0000000003f2a615 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f2a615)
#33 0x0000000000bd4cac clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbd4cac)
#34 0x0000000000ad14a1 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xad14a1)
#35 0x00007f478f82f083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#36 0x0000000000bcebae _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbcebae)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
llvmbot commented 1 year ago

@llvm/issue-subscribers-backend-x86