llvm / llvm-project

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

clang 13.0.0 segfault when compiling LLVM's AArch64ISelLowering.cpp for arm-unknown-linux-gnueabihf #53396

Closed vadimcn closed 2 years ago

vadimcn commented 2 years ago

Doesn't happen with optimizations off.

Reproducer attached

Stack dump:
0.  Program arguments: /usr/local/bin/clang++ -x c++ -c /workspace/source/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp -o lib/Target/AArch64/CMakeFiles/LLVMAArch64CodeGen.dir/AArch64ISelLowering.cpp.o -Ilib/Target/AArch64 -I/workspace/source/llvm/lib/Target/AArch64 -Iinclude -I/workspace/source/llvm/include -MD -MF lib/Target/AArch64/CMakeFiles/LLVMAArch64CodeGen.dir/AArch64ISelLowering.cpp.o.d -MT lib/Target/AArch64/CMakeFiles/LLVMAArch64CodeGen.dir/AArch64ISelLowering.cpp.o -DGTEST_HAS_RTTI=0 -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -target arm-linux-gnueabihf -fPIC -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -O2 -g -DNDEBUG -fvisibility=hidden -fno-exceptions -fno-rtti -std=c++14
1.  <eof> parser at end of file
2.  Code generation
3.  Running pass 'Function Pass Manager' on module '/workspace/source/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp'.
4.  Running pass 'ARM Instruction Selection' on function '@_ZN4llvm21AArch64TargetLowering24addTypeForFixedLengthSVEENS_3MVTE'
 #0 0x00000000025f7a63 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/local/bin/clang+++0x25f7a63)
 #1 0x00000000025f5a5e llvm::sys::RunSignalHandlers() (/usr/local/bin/clang+++0x25f5a5e)
 #2 0x00000000025f6f1d llvm::sys::CleanupOnSignal(unsigned long) (/usr/local/bin/clang+++0x25f6f1d)
 #3 0x000000000257c200 (/usr/local/bin/clang+++0x257c200)
 #4 0x00007fb2d39120e0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x110e0)
 #5 0x0000000002580fb4 llvm::FoldingSetBase::RemoveNode(llvm::FoldingSetBase::Node*) (/usr/local/bin/clang+++0x2580fb4)
 #6 0x0000000003259415 llvm::SelectionDAG::MorphNodeTo(llvm::SDNode*, unsigned int, llvm::SDVTList, llvm::ArrayRef<llvm::SDValue>) (/usr/local/bin/clang+++0x3259415)
 #7 0x00000000032731d7 llvm::SelectionDAGISel::MorphNode(llvm::SDNode*, unsigned int, llvm::SDVTList, llvm::ArrayRef<llvm::SDValue>, unsigned int) (/usr/local/bin/clang+++0x32731d7)
 #8 0x0000000003274050 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/usr/local/bin/clang+++0x3274050)
 #9 0x0000000000eecdf3 (/usr/local/bin/clang+++0xeecdf3)
#10 0x000000000326f74f llvm::SelectionDAGISel::DoInstructionSelection() (/usr/local/bin/clang+++0x326f74f)
#11 0x000000000326eda0 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/usr/local/bin/clang+++0x326eda0)
#12 0x000000000326e058 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/usr/local/bin/clang+++0x326e058)
#13 0x000000000326bdc9 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/usr/local/bin/clang+++0x326bdc9)
#14 0x0000000000eea3b1 (/usr/local/bin/clang+++0xeea3b1)
#15 0x0000000001b6e23e llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/usr/local/bin/clang+++0x1b6e23e)
#16 0x0000000001f1a51d llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/local/bin/clang+++0x1f1a51d)
#17 0x0000000001f21333 llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/local/bin/clang+++0x1f21333)
#18 0x0000000001f1ac94 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/local/bin/clang+++0x1f1ac94)
#19 0x000000000281b393 (/usr/local/bin/clang+++0x281b393)
#20 0x00000000028160a7 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/usr/local/bin/clang+++0x28160a7)
#21 0x000000000334a30e (/usr/local/bin/clang+++0x334a30e)
#22 0x0000000003ed2df4 clang::ParseAST(clang::Sema&, bool, bool) (/usr/local/bin/clang+++0x3ed2df4)
#23 0x0000000002da9039 clang::FrontendAction::Execute() (/usr/local/bin/clang+++0x2da9039)
#24 0x0000000002d20ba6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/local/bin/clang+++0x2d20ba6)
#25 0x0000000002e4dd9e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/local/bin/clang+++0x2e4dd9e)
#26 0x00000000009eb1aa cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/local/bin/clang+++0x9eb1aa)
#27 0x00000000009e9678 (/usr/local/bin/clang+++0x9e9678)
#28 0x0000000002bd6692 (/usr/local/bin/clang+++0x2bd6692)
#29 0x000000000257bfad llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/local/bin/clang+++0x257bfad)
#30 0x0000000002bd630a clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/usr/local/bin/clang+++0x2bd630a)
#31 0x0000000002ba777d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/usr/local/bin/clang+++0x2ba777d)
#32 0x0000000002ba79c7 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/usr/local/bin/clang+++0x2ba79c7)
#33 0x0000000002bbe241 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/usr/local/bin/clang+++0x2bbe241)
#34 0x00000000009e8d4d main (/usr/local/bin/clang+++0x9e8d4d)
#35 0x00007fb2d24952e1 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e1)
#36 0x00000000009e6459 _start (/usr/local/bin/clang+++0x9e6459)
clang-13: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 13.0.0
Target: arm-unknown-linux-gnueabihf
Thread model: posix
InstalledDir: /usr/local/bin
llvmbot commented 2 years ago

@llvm/issue-subscribers-backend-aarch64

llvmbot commented 2 years ago

@llvm/issue-subscribers-backend-arm

DavidSpickett commented 2 years ago

I will try to reproduce this today and find out where it started.

DavidSpickett commented 2 years ago

This was fixed by https://reviews.llvm.org/D107476. Which was cherry picked to the 13 branch as https://github.com/llvm/llvm-project/commit/b3dcd156472fbea65dd002cd670c5ae96de0d438. So you can expect this to be fixed in 13.0.1. (or you can try 13.0.1-rc3 from git if you don't want to wait)

DavidSpickett commented 2 years ago

I think a comment from @vadimcn came in on email but didn't make it here for whatever reason.

This was fixed by https://reviews.llvm.org/D107476.

Not sure about that: I'm seeing the same segfault with a freshly compiled clangd from release/13.x branch

Do you have a new reproducer for that and/or the steps you used to do the overall build?

For the record I found that with 13.0.1-rc3 the original reproducer was fixed on an Arm and AArch64 machine. (and confirmed that it did fail prior to the referenced cherry-pick also)

I also tried using 13.0.1 to build itself, with flags to roughly match the reproducer -DCMAKE_C_FLAGS="-target armv6kz-unknown-linux-gnueabihf" -DCMAKE_CXX_FLAGS="-target armv6kz-unknown-linux-gnueabihf" and didn't have any issues.

Which doesn't mean it's not still an issue, so tell me what I'm missing out.

vadimcn commented 2 years ago

@DavidSpickett: That comment was meant for a different bug, so I deleted it when I noticed my mistake. Sorry for the hassle.