llvm / llvm-project

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

Clang-18 crash: cannot lower memory intrinsic in address space 256. #73275

Open iamanonymouscs opened 11 months ago

iamanonymouscs commented 11 months ago

Clang-18 with -O3 -fsanitize-stats -c crashes on the test case. Compiler explorer: https://godbolt.org/z/Ydf9Mrnvs

$cat mutant.c
void foo(unsigned char __seg_gs *a, unsigned char c, long n)
{
  for (long i = 0; i < n; ++i)
    a[i] = c;
}

$clang-18 -O3 -fsanitize-stats -c mutant.c
fatal error: error in backend: cannot lower memory intrinsic in address space 256
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: clang-18 -O3 -fsanitize-stats -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 '@foo'
 #0 0x00007f306f94e266 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xd2b266)
 #1 0x00007f306f94c170 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xd29170)
 #2 0x00007f306f94d8c4 llvm::sys::CleanupOnSignal(unsigned long) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xd2a8c4)
 #3 0x00007f306f89b9ae (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xc789ae)
 #4 0x00007f306f89b96b (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xc7896b)
 #5 0x00007f306f948a67 llvm::sys::Process::Exit(int, bool) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xd25a67)
 #6 0x000055836735ec23 (/usr/lib/llvm-18/bin/clang+0x13c23)
 #7 0x00007f306f8a9c4f llvm::report_fatal_error(llvm::Twine const&, bool) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xc86c4f)
 #8 0x00007f307017104c (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0x154e04c)
 #9 0x00007f3070129658 llvm::SelectionDAGBuilder::visitIntrinsicCall(llvm::CallInst const&, unsigned int) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0x1506658)
#10 0x00007f30700fae0b llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0x14d7e0b)
#11 0x00007f30701962a6 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void, true>, false, true>, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void, true>, false, true>, bool&) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0x15732a6)
#12 0x00007f3070195b71 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0x1572b71)
#13 0x00007f3070193cf6 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0x1570cf6)
#14 0x00007f307252c52f (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0x390952f)
#15 0x00007f306fd02552 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0x10df552)
#16 0x00007f306fa940df llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xe710df)
#17 0x00007f306fa99dc3 llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xe76dc3)
#18 0x00007f306fa947d4 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xe717d4)
#19 0x00007f307813109f 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>>) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x1ade09f)
#20 0x00007f30784c75fe (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x1e745fe)
#21 0x00007f30770e3866 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0xa90866)
#22 0x00007f3078f3b645 clang::FrontendAction::Execute() (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x28e8645)
#23 0x00007f3078eb9cc4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x2866cc4)
#24 0x00007f3078fb61c0 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x29631c0)
#25 0x000055836735e837 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-18/bin/clang+0x13837)
#26 0x000055836735b905 (/usr/lib/llvm-18/bin/clang+0x10905)
#27 0x00007f3078b51909 (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x24fe909)
#28 0x00007f306f89b94c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xc7894c)
#29 0x00007f3078b512ae clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x24fe2ae)
#30 0x00007f3078b190f1 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x24c60f1)
#31 0x00007f3078b1933e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x24c633e)
#32 0x00007f3078b3539c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x24e239c)
#33 0x000055836735b25c clang_main(int, char**, llvm::ToolContext const&) (/usr/lib/llvm-18/bin/clang+0x1025c)
#34 0x0000558367368f32 main (/usr/lib/llvm-18/bin/clang+0x1df32)
#35 0x00007f306de32c87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0
#36 0x00005583673581ea _start (/usr/lib/llvm-18/bin/clang+0xd1ea)
clang-18: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Ubuntu clang version 18.0.0 (++20231018091808+48a53509e851-1~exp1~20231018091910.1571)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang-18: note: diagnostic msg: 
********************

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

********************
llvmbot commented 11 months ago

@llvm/issue-subscribers-backend-x86

Author: Anonymous (iamanonymouscs)

Clang-18 with -O3 -fsanitize-stats -c crashes on the test case. Compiler explorer: https://godbolt.org/z/Ydf9Mrnvs ``` $cat mutant.c void foo(unsigned char __seg_gs *a, unsigned char c, long n) { for (long i = 0; i < n; ++i) a[i] = c; } $clang-18 -O3 -fsanitize-stats -c mutant.c fatal error: error in backend: cannot lower memory intrinsic in address space 256 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: clang-18 -O3 -fsanitize-stats -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 '@foo' #0 0x00007f306f94e266 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xd2b266) #1 0x00007f306f94c170 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xd29170) #2 0x00007f306f94d8c4 llvm::sys::CleanupOnSignal(unsigned long) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xd2a8c4) #3 0x00007f306f89b9ae (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xc789ae) #4 0x00007f306f89b96b (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xc7896b) #5 0x00007f306f948a67 llvm::sys::Process::Exit(int, bool) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xd25a67) #6 0x000055836735ec23 (/usr/lib/llvm-18/bin/clang+0x13c23) #7 0x00007f306f8a9c4f llvm::report_fatal_error(llvm::Twine const&, bool) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xc86c4f) #8 0x00007f307017104c (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0x154e04c) #9 0x00007f3070129658 llvm::SelectionDAGBuilder::visitIntrinsicCall(llvm::CallInst const&, unsigned int) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0x1506658) #10 0x00007f30700fae0b llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0x14d7e0b) #11 0x00007f30701962a6 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void, true>, false, true>, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void, true>, false, true>, bool&) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0x15732a6) #12 0x00007f3070195b71 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0x1572b71) #13 0x00007f3070193cf6 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0x1570cf6) #14 0x00007f307252c52f (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0x390952f) #15 0x00007f306fd02552 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0x10df552) #16 0x00007f306fa940df llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xe710df) #17 0x00007f306fa99dc3 llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xe76dc3) #18 0x00007f306fa947d4 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xe717d4) #19 0x00007f307813109f 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>>) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x1ade09f) #20 0x00007f30784c75fe (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x1e745fe) #21 0x00007f30770e3866 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0xa90866) #22 0x00007f3078f3b645 clang::FrontendAction::Execute() (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x28e8645) #23 0x00007f3078eb9cc4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x2866cc4) #24 0x00007f3078fb61c0 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x29631c0) #25 0x000055836735e837 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-18/bin/clang+0x13837) #26 0x000055836735b905 (/usr/lib/llvm-18/bin/clang+0x10905) #27 0x00007f3078b51909 (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x24fe909) #28 0x00007f306f89b94c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xc7894c) #29 0x00007f3078b512ae clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x24fe2ae) #30 0x00007f3078b190f1 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x24c60f1) #31 0x00007f3078b1933e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x24c633e) #32 0x00007f3078b3539c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x24e239c) #33 0x000055836735b25c clang_main(int, char**, llvm::ToolContext const&) (/usr/lib/llvm-18/bin/clang+0x1025c) #34 0x0000558367368f32 main (/usr/lib/llvm-18/bin/clang+0x1df32) #35 0x00007f306de32c87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0 #36 0x00005583673581ea _start (/usr/lib/llvm-18/bin/clang+0xd1ea) clang-18: error: clang frontend command failed with exit code 70 (use -v to see invocation) Ubuntu clang version 18.0.0 (++20231018091808+48a53509e851-1~exp1~20231018091910.1571) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin clang-18: note: diagnostic msg: ******************** PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang-18: note: diagnostic msg: /tmp/mutant-786ce9.c clang-18: note: diagnostic msg: /tmp/mutant-786ce9.sh clang-18: note: diagnostic msg: ******************** ```