Skip to content

clang-20 crashed with target attribute at -O1 level. Assertion `(TLI.getTypeAction(*DAG.getContext(), Op.getValueType()) == TargetLowering::TypeLegal || Op.getOpcode() == ISD::TargetConstant || Op.getOpcode() == ISD::Register) && "Unexpected illegal type!"' failed. #113420

@iamanonymouscs

Description

@iamanonymouscs

clang-20 crashed with target attribute at -O1 level.

Compiler explorer: https://godbolt.org/z/a9T9fseMK

$cat mutant.c
int a, b;
int __attribute__((__target__("avx512bw,no-evex512"))) c() {
  return __builtin_ia32_kunpcksi(a, b);
}

Also crashed on clang-19.

$clang-19 -O1 mutant.c
clang-19: /home/compiler/llvm/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:974: void (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(SDNode *): Assertion `(TLI.getTypeAction(*DAG.getContext(), Op.getValueType()) == TargetLowering::TypeLegal || Op.getOpcode() == ISD::TargetConstant || Op.getOpcode() == ISD::Register) && "Unexpected illegal type!"' 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: /home/software/llvm-trunk-eed7c5e/bin/clang-19 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name mutant.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/code/reduce -fcoverage-compilation-dir=/home/code/reduce -resource-dir /home/software/llvm-trunk-eed7c5e/lib/clang/19 -internal-isystem /home/software/llvm-trunk-eed7c5e/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O1 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/mutant-8f4d41.o -x c mutant.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'mutant.c'.
4.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@c'
 #0 0x00007f166cdd9617 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/software/llvm-trunk-eed7c5e/bin/../lib/libLLVM.so.19.0git+0xffc617)
 #1 0x00007f166cdd5b92 llvm::sys::RunSignalHandlers() (/home/software/llvm-trunk-eed7c5e/bin/../lib/libLLVM.so.19.0git+0xff8b92)
 #2 0x00007f166cdd9d91 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f166b8bd520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f166b9119fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007f166b8bd476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007f166b8a37f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007f166b8a371b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007f166b8b4e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x00007f166e036135 (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) LegalizeDAG.cpp:0:0
#10 0x00007f166e035b55 llvm::SelectionDAG::Legalize() (/home/software/llvm-trunk-eed7c5e/bin/../lib/libLLVM.so.19.0git+0x2258b55)
#11 0x00007f166e2f9a9f llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/home/software/llvm-trunk-eed7c5e/bin/../lib/libLLVM.so.19.0git+0x251ca9f)
#12 0x00007f166e2f76fc llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/software/llvm-trunk-eed7c5e/bin/../lib/libLLVM.so.19.0git+0x251a6fc)
#13 0x00007f166e2efbba llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/software/llvm-trunk-eed7c5e/bin/../lib/libLLVM.so.19.0git+0x2512bba)
#14 0x00007f166e2ebcb3 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/home/software/llvm-trunk-eed7c5e/bin/../lib/libLLVM.so.19.0git+0x250ecb3)
#15 0x00007f166d8086dc llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/software/llvm-trunk-eed7c5e/bin/../lib/libLLVM.so.19.0git+0x1a2b6dc)
#16 0x00007f166d130a4b llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/software/llvm-trunk-eed7c5e/bin/../lib/libLLVM.so.19.0git+0x1353a4b)
#17 0x00007f166d13d9b1 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/software/llvm-trunk-eed7c5e/bin/../lib/libLLVM.so.19.0git+0x13609b1)
#18 0x00007f166d131814 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/software/llvm-trunk-eed7c5e/bin/../lib/libLLVM.so.19.0git+0x1354814)
#19 0x00007f1688ee31eb clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/home/software/llvm-trunk-eed7c5e/bin/../lib/libclang-cpp.so.19.0git+0x36e81eb)
#20 0x00007f1689625e72 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/software/llvm-trunk-eed7c5e/bin/../lib/libclang-cpp.so.19.0git+0x3e2ae72)
#21 0x00007f168665609e clang::ParseAST(clang::Sema&, bool, bool) (/home/software/llvm-trunk-eed7c5e/bin/../lib/libclang-cpp.so.19.0git+0xe5b09e)
#22 0x00007f168af3eed5 clang::FrontendAction::Execute() (/home/software/llvm-trunk-eed7c5e/bin/../lib/libclang-cpp.so.19.0git+0x5743ed5)
#23 0x00007f168adf7cbb clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/software/llvm-trunk-eed7c5e/bin/../lib/libclang-cpp.so.19.0git+0x55fccbb)
#24 0x00007f168b03ffd1 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/software/llvm-trunk-eed7c5e/bin/../lib/libclang-cpp.so.19.0git+0x5844fd1)
#25 0x000055a183cf01bf cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/software/llvm-trunk-eed7c5e/bin/clang-19+0x1d1bf)
#26 0x000055a183ce5a94 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#27 0x000055a183ce42b5 clang_main(int, char**, llvm::ToolContext const&) (/home/software/llvm-trunk-eed7c5e/bin/clang-19+0x112b5)
#28 0x000055a183d0ce25 main (/home/software/llvm-trunk-eed7c5e/bin/clang-19+0x39e25)
#29 0x00007f166b8a4d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#30 0x00007f166b8a4e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#31 0x000055a183ce16d5 _start (/home/software/llvm-trunk-eed7c5e/bin/clang-19+0xe6d5)
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 19.0.0git (https://github.com/llvm/llvm-project.git eed7c5e29c1dc5f78bd01608430e2b4e0c439bb1)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/software/llvm-trunk-eed7c5e/bin
Build config: +assertions
clang: note: diagnostic msg: 
********************

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend:X86crashPrefer [crash-on-valid] or [crash-on-invalid]invalidResolved as invalid, i.e. not a bugllvm:SelectionDAGSelectionDAGISel as well

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions