Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when building Linux with latest LLVM (and CLang) #72026

Closed
alex-s168 opened this issue Nov 11, 2023 · 38 comments
Closed

Error when building Linux with latest LLVM (and CLang) #72026

alex-s168 opened this issue Nov 11, 2023 · 38 comments
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] llvm:SelectionDAG SelectionDAGISel as well

Comments

@alex-s168
Copy link

alex-s168 commented Nov 11, 2023

When trying to build linux zen (6.5/main) with LLVM (commit 05738a3), I get this error:

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: ld.lld -m elf_x86_64 -mllvm -import-instr-limit=5 -z noexecstack -r -o vmlinux.o -T .tmp_initcalls.lds --whole-archive vmlinux.a --no-whole-archive --start-group --end-group
1.	Running pass 'Function Pass Manager' on module 'ld-temp.o'.
2.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@ip6_rcv_core'
 #0 0x000055698fdff53e llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/local/bin/lld+0x382253e)
 #1 0x000055698fdfc9db SignalHandler(int) Signals.cpp:0:0
 #2 0x00007faca405c710 (/usr/lib/libc.so.6+0x3e710)
 #3 0x00007faca40bb575 __libc_realloc (/usr/lib/libc.so.6+0x9d575)
 #4 0x000055698fd69dc4 llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long) (/usr/local/bin/lld+0x378cdc4)
 #5 0x00005569925c73b4 llvm::SUnit::addPred(llvm::SDep const&, bool) (/usr/local/bin/lld+0x5fea3b4)
 #6 0x0000556991fb830a llvm::ScheduleDAGSDNodes::AddSchedEdges() (/usr/local/bin/lld+0x59db30a)
 #7 0x0000556991fb09d2 (anonymous namespace)::ScheduleDAGRRList::Schedule() ScheduleDAGRRList.cpp:0:0
 #8 0x0000556991f9bf2e llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/usr/local/bin/lld+0x59bef2e)
 #9 0x0000556991f9e86f llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/usr/local/bin/lld+0x59c186f)
#10 0x0000556991fa0e0a llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#11 0x0000556991ac6d40 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#12 0x00005569923b93c8 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#13 0x0000556993dfc271 llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/local/bin/lld+0x781f271)
#14 0x0000556993dfc5bc llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/local/bin/lld+0x781f5bc)
#15 0x0000556993dfcfbe llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/local/bin/lld+0x781ffbe)
#16 0x000055699211bcac codegen(llvm::lto::Config const&, llvm::TargetMachine*, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex const&) LTOBackend.cpp:0:0
#17 0x000055699211c3df llvm::lto::backend(llvm::lto::Config const&, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex&) (/usr/local/bin/lld+0x5b3f3df)
#18 0x000055699210edf2 llvm::lto::LTO::runRegularLTO(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>) (/usr/local/bin/lld+0x5b31df2)
#19 0x000055699210f35b llvm::lto::LTO::run(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, std::function<llvm::Expected<std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>> (unsigned int, llvm::StringRef, llvm::Twine const&)>) (/usr/local/bin/lld+0x5b3235b)
#20 0x000055699002d915 lld::elf::BitcodeCompiler::compile() (/usr/local/bin/lld+0x3a50915)
#21 0x000055698ff4e6ff void lld::elf::LinkerDriver::compileBitcodeFiles<llvm::object::ELFType<(llvm::endianness)1, true>>(bool) (/usr/local/bin/lld+0x39716ff)
#22 0x000055698ff5bed1 lld::elf::LinkerDriver::link(llvm::opt::InputArgList&) (/usr/local/bin/lld+0x397eed1)
#23 0x000055698ff5dfaf lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) (/usr/local/bin/lld+0x3980faf)
#24 0x000055698ff5f77b lld::elf::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (/usr/local/bin/lld+0x398277b)
#25 0x000055698fe011cc lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>, bool) (/usr/local/bin/lld+0x38241cc)
#26 0x000055698fd408b6 lld_main(int, char**, llvm::ToolContext const&) (/usr/local/bin/lld+0x37638b6)
#27 0x000055698fd40b1f main (/usr/local/bin/lld+0x3763b1f)
#28 0x00007faca4045cd0 (/usr/lib/libc.so.6+0x27cd0)
#29 0x00007faca4045d8a __libc_start_main (/usr/lib/libc.so.6+0x27d8a)
#30 0x000055698fd400a5 _start (/usr/local/bin/lld+0x37630a5)

I think I should probably not use the latest LLVM but the CI for that commit said that all tests were completed successfully.

@github-actions github-actions bot added the clang Clang issues not falling into any other category label Nov 11, 2023
@EugeneZelenko EugeneZelenko added backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid] and removed clang Clang issues not falling into any other category labels Nov 11, 2023
@llvmbot
Copy link
Member

llvmbot commented Nov 11, 2023

@llvm/issue-subscribers-backend-x86

Author: alex_s168 (SuperCraftAlex)

When trying to build linux with LLVM (commit 05738a3), I get this error: ``` PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0. Program arguments: ld.lld -m elf_x86_64 -mllvm -import-instr-limit=5 -z noexecstack -r -o vmlinux.o -T .tmp_initcalls.lds --whole-archive vmlinux.a --no-whole-archive --start-group --end-group 1. Running pass 'Function Pass Manager' on module 'ld-temp.o'. 2. Running pass 'X86 DAG->DAG Instruction Selection' on function '@ip6_rcv_core' #0 0x000055698fdff53e llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/local/bin/lld+0x382253e) #1 0x000055698fdfc9db SignalHandler(int) Signals.cpp:0:0 #2 0x00007faca405c710 (/usr/lib/libc.so.6+0x3e710) #3 0x00007faca40bb575 __libc_realloc (/usr/lib/libc.so.6+0x9d575) #4 0x000055698fd69dc4 llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long) (/usr/local/bin/lld+0x378cdc4) #5 0x00005569925c73b4 llvm::SUnit::addPred(llvm::SDep const&, bool) (/usr/local/bin/lld+0x5fea3b4) #6 0x0000556991fb830a llvm::ScheduleDAGSDNodes::AddSchedEdges() (/usr/local/bin/lld+0x59db30a) #7 0x0000556991fb09d2 (anonymous namespace)::ScheduleDAGRRList::Schedule() ScheduleDAGRRList.cpp:0:0 #8 0x0000556991f9bf2e llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/usr/local/bin/lld+0x59bef2e) #9 0x0000556991f9e86f llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/usr/local/bin/lld+0x59c186f) #10 0x0000556991fa0e0a llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0 #11 0x0000556991ac6d40 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0 #12 0x00005569923b93c8 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0 #13 0x0000556993dfc271 llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/local/bin/lld+0x781f271) #14 0x0000556993dfc5bc llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/local/bin/lld+0x781f5bc) #15 0x0000556993dfcfbe llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/local/bin/lld+0x781ffbe) #16 0x000055699211bcac codegen(llvm::lto::Config const&, llvm::TargetMachine*, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex const&) LTOBackend.cpp:0:0 #17 0x000055699211c3df llvm::lto::backend(llvm::lto::Config const&, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex&) (/usr/local/bin/lld+0x5b3f3df) #18 0x000055699210edf2 llvm::lto::LTO::runRegularLTO(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>) (/usr/local/bin/lld+0x5b31df2) #19 0x000055699210f35b llvm::lto::LTO::run(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, std::function<llvm::Expected<std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>> (unsigned int, llvm::StringRef, llvm::Twine const&)>) (/usr/local/bin/lld+0x5b3235b) #20 0x000055699002d915 lld::elf::BitcodeCompiler::compile() (/usr/local/bin/lld+0x3a50915) #21 0x000055698ff4e6ff void lld::elf::LinkerDriver::compileBitcodeFiles<llvm::object::ELFType<(llvm::endianness)1, true>>(bool) (/usr/local/bin/lld+0x39716ff) #22 0x000055698ff5bed1 lld::elf::LinkerDriver::link(llvm::opt::InputArgList&) (/usr/local/bin/lld+0x397eed1) #23 0x000055698ff5dfaf lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) (/usr/local/bin/lld+0x3980faf) #24 0x000055698ff5f77b lld::elf::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (/usr/local/bin/lld+0x398277b) #25 0x000055698fe011cc lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>, bool) (/usr/local/bin/lld+0x38241cc) #26 0x000055698fd408b6 lld_main(int, char**, llvm::ToolContext const&) (/usr/local/bin/lld+0x37638b6) #27 0x000055698fd40b1f main (/usr/local/bin/lld+0x3763b1f) #28 0x00007faca4045cd0 (/usr/lib/libc.so.6+0x27cd0) #29 0x00007faca4045d8a __libc_start_main (/usr/lib/libc.so.6+0x27d8a) #30 0x000055698fd400a5 _start (/usr/local/bin/lld+0x37630a5) ``` I think I should probably not use the latest LLVM but the CI for that commit said that all tests were completed successfully.

@EugeneZelenko EugeneZelenko added incomplete Issue not complete (e.g. missing a reproducer, build arguments, etc.) LTO Link time optimization (regular/full LTO or ThinLTO) labels Nov 11, 2023
@nathanchance
Copy link
Member

When trying to build linux zen (6.5/main) with LLVM (commit 05738a3), I get this error:

Can you post your .config file and Linux kernel build command? I cannot reproduce this with Arch Linux's configuration + CONFIG_LTO_CLANG_FULL=y with Zen's source @ zen-kernel/zen-kernel@7c9dcf6 and LLVM @ 05738a3.

$ git show -s --format='%h ("%s")'
7c9dcf6494cf ("Merge v6.5.11 into 6.5/main")

$ clang --version | head -1
clang version 18.0.0 (https://github.com/llvm/llvm-project 05738a38820ffbe5b95e747db0e19b1104fc29f8)

$ curl -LSso .config https://gitlab.archlinux.org/archlinux/packaging/packages/linux-zen/-/raw/main/config

$ scripts/config -d LTO_NONE -e LTO_CLANG_FULL

$ make -skj"$(nproc)" ARCH=x86_64 LLVM=1 olddefconfig vmlinux

$ rg CONFIG_LTO .config
881:CONFIG_LTO=y
882:CONFIG_LTO_CLANG=y
886:# CONFIG_LTO_NONE is not set
887:CONFIG_LTO_CLANG_FULL=y
888:# CONFIG_LTO_CLANG_THIN is not set

@vtta
Copy link

vtta commented Nov 30, 2023

Another failed attempt here with clang 17.0.5 and linux v6.6 and LTO off:

+ /usr/bin/time --verbose make WERROR=0 LLVM=-17 CFLAGS=-w HOSTCC=clang HOSTCXX=clang++ CC=clang AS=llvm-as LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump READELF=llvm-readelf CONFIG_RUST=y MRPROPER=no CLEAN=no
 -C /data/projects/kernel/vtta O=/data/projects/kernel/build/vtta -j 1 bzImage modules compile_commands.json rust-analyzer
make: Entering directory '/data/projects/kernel/vtta'
make[1]: Entering directory '/data/projects/kernel/build/vtta'
  GEN     Makefile
  CALL    /data/projects/kernel/vtta/scripts/checksyscalls.sh
  DESCEND objtool
make[5]: 'install_headers' is up to date.
  DESCEND bpf/resolve_btfids
make[5]: 'install_headers' is up to date.
  CC      arch/x86/kvm/../../../virt/kvm/async_pf.o
  CC      arch/x86/kvm/../../../virt/kvm/pfncache.o
  CC      arch/x86/kvm/x86.o
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 -Wp,-MMD,arch/x86/kvm/.x86.o.d -nostdinc -I/data/projects/kernel/vtta/arch/x86/include -I./arch/x86/include/generated -I/data/projects/kernel/vtta/include -I./include -I/data/projects/kernel/vtta/arch/x86/include/uapi -I.
/arch/x86/include/generated/uapi -I/data/projects/kernel/vtta/include/uapi -I./include/generated/uapi -include /data/projects/kernel/vtta/include/linux/compiler-version.h -include /data/projects/kernel/vtta/include/linux/kconfig.h -include /data/projects
/kernel/vtta/include/linux/compiler_types.h -D__KERNEL__ --target=x86_64-linux-gnu -fintegrated-as -Werror=unknown-warning-option -Werror=ignored-optimization-argument -Werror=option-ignored -Werror=unused-command-line-argument -fmacro-prefix-map=/data/p
rojects/kernel/vtta/= -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=branch -fno-jump-tables -m64 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mstack-al
ignment=8 -mskip-rax-setup -march=core2 -mno-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -O2 -fstack-protector -fno-stack-clash-protection -fzero-call-used-regs=used-gpr -pg -mfentry -DCC_USI
NG_NOP_MCOUNT -DCC_USING_FENTRY -falign-functions=64 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -Wall -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security 
-Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wframe-larger-than=1024 -Wno-gnu -Wno-unused-but-set-variable -Wno-unused-const-variable -Wvla -Wno-pointer-sign -Wcast-function-type -Wimplicit-fallthrough -Werror=date-time -Werror=incomp
atible-pointer-types -Wenum-conversion -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-pointer-to-enum-cast -Wno-tautological-constant-out-of-range-compare -Wno-unaligned-access -Wno-cast-function-type-strict -Wno-missing-field-initializers 
-Wno-type-limits -Wno-shift-negative-value -Wno-initializer-overrides -Wno-sign-compare -g -gdwarf-5 -I /data/projects/kernel/vtta/arch/x86/kvm -Werror -I /data/projects/kernel/vtta/arch/x86/kvm -I ./arch/x86/kvm -DKBUILD_MODFILE=\"arch/x86/kvm/kvm\" -DK
BUILD_BASENAME=\"x86\" -DKBUILD_MODNAME=\"kvm\" -D__KBUILD_MODNAME=kmod_kvm -c -o arch/x86/kvm/x86.o /data/projects/kernel/vtta/arch/x86/kvm/x86.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '/data/projects/kernel/vtta/arch/x86/kvm/x86.c'.
4.      Running pass 'Prologue/Epilogue Insertion & Frame Finalization' on function '@kvm_check_nested_events'
 #0 0x00007f08ad44d6d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/lib/Support/Unix/Signals.inc:602:13
 #1 0x00007f08ad44ba70 llvm::sys::RunSignalHandlers() /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/lib/Support/Signals.cpp:105:18
 #2 0x00007f08ad3a6c79 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/lib/Support/CrashRecoveryContext.cpp:73:5
 #3 0x00007f08ad3a6c79 CrashRecoverySignalHandler(int) /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/lib/Support/CrashRecoveryContext.cpp:390:51
 #4 0x00007f08ac58e720 __restore_rt libc_sigaction.c:0:0
 #5 0x00007f08ad8f1f11 llvm::BitVector::reset(unsigned int) /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/include/llvm/ADT/BitVector.h:398:30
 #6 0x00007f08ad8f1f11 (anonymous namespace)::PEI::insertZeroCallUsedRegs(llvm::MachineFunction&) /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/lib/CodeGen/PrologEpilogInserter.cpp:1291:22
 #7 0x00007f08ad8f1f11 (anonymous namespace)::PEI::insertPrologEpilogCode(llvm::MachineFunction&) /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/lib/CodeGen/PrologEpilogInserter.cpp:1169:3
 #8 0x00007f08ad8f1f11 (anonymous namespace)::PEI::runOnMachineFunction(llvm::MachineFunction&) /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/lib/CodeGen/PrologEpilogInserter.cpp:263:5
 #9 0x00007f08ad7e409f llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/lib/CodeGen/MachineFunctionPass.cpp:0:13
#10 0x00007f08ad581016 llvm::FPPassManager::runOnFunction(llvm::Function&) /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/lib/IR/LegacyPassManager.cpp:1435:27
#11 0x00007f08ad586a83 llvm::FPPassManager::runOnModule(llvm::Module&) /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/lib/IR/LegacyPassManager.cpp:1481:13
#12 0x00007f08ad5816b1 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/lib/IR/LegacyPassManager.cpp:0:27
#13 0x00007f08ad5816b1 llvm::legacy::PassManagerImpl::run(llvm::Module&) /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/lib/IR/LegacyPassManager.cpp:535:44
#14 0x00007f08b53ccac4 llvm::TimeTraceScope::~TimeTraceScope() /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/include/llvm/Support/TimeProfiler.h:155:9
#15 0x00007f08b53ccac4 (anonymous namespace)::EmitAssemblyHelper::RunCodegenPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<
llvm::ToolOutputFile>>&) /builddir/build/BUILD/llvm-project-17.0.5.src/clang/lib/CodeGen/BackendUtil.cpp:1116:3
#16 0x00007f08b53ccac4 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) /builddir/build/BUILD/llvm-project-17.0.5.src/clang/lib/CodeGen/B
ackendUtil.cpp:1137:3
#17 0x00007f08b53ccac4 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>>) /builddir/build/BUILD/llvm-project-17.0.5.src/clang/lib/CodeGen/BackendUtil.cpp:1299:13
#18 0x00007f08b5733b4d std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>::~unique_ptr() /usr/lib64/gcc/x86_64-generic-linux/13/../../../../include/c++/13/bits/unique_ptr.h:403:6
#19 0x00007f08b5733b4d clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /builddir/build/BUILD/llvm-project-17.0.5.src/clang/lib/CodeGen/CodeGenAction.cpp:386:7
#20 0x00007f08b44b2a56 __gnu_cxx::__normal_iterator<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback>>*, std::vector<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<c
lang::TemplateInstantiationCallback>>, std::allocator<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback>>>>>::__normal_iterator(std::unique_ptr<clang::TemplateInstantiationCallback, std::defaul
t_delete<clang::TemplateInstantiationCallback>>* const&) /usr/lib64/gcc/x86_64-generic-linux/13/../../../../include/c++/13/bits/stl_iterator.h:1077:20
#21 0x00007f08b44b2a56 std::vector<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback>>, std::allocator<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateI
nstantiationCallback>>>>::begin() /usr/lib64/gcc/x86_64-generic-linux/13/../../../../include/c++/13/bits/stl_vector.h:871:16
#22 0x00007f08b44b2a56 void clang::finalize<std::vector<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback>>, std::allocator<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_de
lete<clang::TemplateInstantiationCallback>>>>>(std::vector<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback>>, std::allocator<std::unique_ptr<clang::TemplateInstantiationCallback, std::default
_delete<clang::TemplateInstantiationCallback>>>>&, clang::Sema const&) /builddir/build/BUILD/llvm-project-17.0.5.src/clang/include/clang/Sema/TemplateInstCallback.h:54:16
#23 0x00007f08b44b2a56 clang::ParseAST(clang::Sema&, bool, bool) /builddir/build/BUILD/llvm-project-17.0.5.src/clang/lib/Parse/ParseAST.cpp:183:3
#24 0x00007f08b60b1a87 clang::FrontendAction::Execute() /builddir/build/BUILD/llvm-project-17.0.5.src/clang/lib/Frontend/FrontendAction.cpp:1063:10
#25 0x00007f08b602bff4 llvm::Error::getPtr() const /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/include/llvm/Support/Error.h:273:12
#26 0x00007f08b602bff4 llvm::Error::operator bool() /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/include/llvm/Support/Error.h:233:16
#27 0x00007f08b602bff4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /builddir/build/BUILD/llvm-project-17.0.5.src/clang/lib/Frontend/CompilerInstance.cpp:1053:23
#28 0x00007f08b6124344 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /builddir/build/BUILD/llvm-project-17.0.5.src/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:272:25
#29 0x00005649cc27fc89 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /builddir/build/BUILD/llvm-project-17.0.5.src/clang/tools/driver/cc1_main.cpp:249:15
#30 0x00005649cc27d7c3 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /builddir/build/BUILD/llvm-project-17.0.5.src/clang/tools/driver/driver.cpp:366:12
#31 0x00007f08b5d08239 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_0::operator()() const /builddir/build/BUILD/llvm-pr
oject-17.0.5.src/clang/lib/Driver/Job.cpp:440:30
#32 0x00007f08b5d08239 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::$_0>(lo
ng) /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#33 0x00007f08ad3a6a5c llvm::function_ref<void ()>::operator()() const /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/include/llvm/ADT/STLFunctionalExtras.h:0:12
#34 0x00007f08ad3a6a5c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/lib/Support/CrashRecoveryContext.cpp:426:3
#35 0x00007f08b5d07ade clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const /builddir/build/BUILD/llvm-project-17.0.5.src/clang/li
b/Driver/Job.cpp:440:7
#36 0x00007f08b5cd225e clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const /builddir/build/BUILD/llvm-project-17.0.5.src/clang/lib/Driver/Compilation.cpp:199:15
#37 0x00007f08b5cd249e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const /builddir/build/BUILD/llvm-project-17.0.5.src/clang/lib/Driver/Compilation.cp
p:253:13
#38 0x00007f08b5ced10e llvm::SmallVectorBase<unsigned int>::empty() const /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/include/llvm/ADT/SmallVector.h:94:46
#39 0x00007f08b5ced10e clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) /builddir/build/BUILD/llvm-project-17.0.5.src/clang/lib/Driver/Driver.cpp:1906:23
#40 0x00005649cc27d136 clang_main(int, char**, llvm::ToolContext const&) /builddir/build/BUILD/llvm-project-17.0.5.src/clang/tools/driver/driver.cpp:542:21
#41 0x00005649cc2898c1 main /builddir/build/BUILD/llvm-project-17.0.5.src/llvm/clr-build/tools/clang/tools/driver/clang-driver.cpp:15:3
#42 0x00007f08ac574d77 __libc_start_call_main /builddir/build/BUILD/glibc-2.38/csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#43 0x00007f08ac574e35 call_init /builddir/build/BUILD/glibc-2.38/csu/../csu/libc-start.c:128:20
#44 0x00007f08ac574e35 __libc_start_main@GLIBC_2.2.5 /builddir/build/BUILD/glibc-2.38/csu/../csu/libc-start.c:347:5
#45 0x00005649cc27a1c1 _start /builddir/build/BUILD/glibc-2.38/csu/../sysdeps/x86_64/start.S:117:0
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 17.0.5
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
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/x86-f3aa9f.c
clang: note: diagnostic msg: /tmp/x86-f3aa9f.sh
clang: note: diagnostic msg: 

********************
make[5]: *** [/data/projects/kernel/vtta/scripts/Makefile.build:243: arch/x86/kvm/x86.o] Error 1
make[4]: *** [/data/projects/kernel/vtta/scripts/Makefile.build:480: arch/x86/kvm] Error 2
make[3]: *** [/data/projects/kernel/vtta/scripts/Makefile.build:480: arch/x86] Error 2
make[2]: *** [/data/projects/kernel/vtta/Makefile:1913: .] Error 2
make[1]: *** [/data/projects/kernel/vtta/Makefile:234: __sub-make] Error 2
make[1]: Leaving directory '/data/projects/kernel/build/vtta'
make: *** [Makefile:234: __sub-make] Error 2
make: Leaving directory '/data/projects/kernel/vtta'
Command exited with non-zero status 2
        Command being timed: "make WERROR=0 LLVM=-17 CFLAGS=-w HOSTCC=clang HOSTCXX=clang++ CC=clang AS=llvm-as LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump READELF=llvm-readelf CONFIG_RUST=y MRPROPER=no CLEA
N=no -C /data/projects/kernel/vtta O=/data/projects/kernel/build/vtta -j 1 bzImage modules compile_commands.json rust-analyzer"
        User time (seconds): 9.24
        System time (seconds): 3.52
        Percent of CPU this job got: 96%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:13.20
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 604544
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 4301
        Minor (reclaiming a frame) page faults: 470178
        Voluntary context switches: 5872
        Involuntary context switches: 163
        Swaps: 0
        File system inputs: 0
        File system outputs: 2568
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 2
$ rg CONFIG_LTO .config
799:CONFIG_LTO_NONE=y
800:# CONFIG_LTO_CLANG_FULL is not set
801:# CONFIG_LTO_CLANG_THIN is not set

.config
x86-f3aa9f.tgz

@nathanchance
Copy link
Member

@vtta I am not sure your crash is the same issue as the one initially reported here, as it is reproducible on release/17.x but not main, which doesn't line up with the OP. I bisected the fix for your crash to f800c1f but unfortunately, as far as I am aware, there are no further planned updates to release/17.x, so there isn't much to do about it. You can disable CONFIG_ZERO_CALL_USED_REGS to avoid it if you are not able to patch your LLVM with that fix.

@vtta
Copy link

vtta commented Dec 1, 2023

@vtta I am not sure your crash is the same issue as the one initially reported here, as it is reproducible on release/17.x but not main, which doesn't line up with the OP. I bisected the fix for your crash to f800c1f but unfortunately, as far as I am aware, there are no further planned updates to release/17.x, so there isn't much to do about it. You can disable CONFIG_ZERO_CALL_USED_REGS to avoid it if you are not able to patch your LLVM with that fix.

Thanks for the fix, I can compile with CONFIG_ZERO_CALL_USED_REGS disabled. The llvm I am using is from clearlinux, I have created an issue on their site.

@KyunLFA
Copy link

KyunLFA commented Dec 2, 2023

Hey,

I think I narrowed down the issue that is affecting the kernel compile here.
The problem is when LLVM Clang tries to compile C files under net/ipv6 with the Zen(1-4) scheduler model. Given linux-next 1st of Dec 2023, LLVM commit b6d0ee05, and error


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 -Wp,-MMD,net/ipv6/.ip6_input.o.d -nostdinc -I./arch/x86/include -I./arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ --target=x86_64-linux-gnu -fintegrated-as -Werror=unknown-warning-option -Werror=ignored-optimization-argument -Werror=option-ignored -Werror=unused-command-line-argument -fmacro-prefix-map=./= -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=branch -fno-jump-tables -m64 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mstack-alignment=8 -mskip-rax-setup -march=znver4 -mno-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -O3 -mllvm -polly -fno-semantic-interposition -pipe -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fno-stack-clash-protection -fsanitize=kcfi -falign-functions=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -Wall -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wno-gnu -Wno-unused-but-set-variable -Wno-unused-const-variable -Wvla -Wno-pointer-sign -Wcast-function-type -Wimplicit-fallthrough -Werror=date-time -Werror=incompatible-pointer-types -Wenum-conversion -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-format-overflow -Wno-format-truncation -Wno-pointer-to-enum-cast -Wno-tautological-constant-out-of-range-compare -Wno-unaligned-access -Wno-cast-function-type-strict -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-initializer-overrides -Wno-sign-compare -DRANDSTRUCT -frandomize-layout-seed-file=./scripts/basic/randstruct.seed -DKBUILD_MODFILE=\"net/ipv6/ipv6\" -DKBUILD_BASENAME=\"ip6_input\" -DKBUILD_MODNAME=\"ipv6\" -D__KBUILD_MODNAME=kmod_ipv6 -c -o net/ipv6/ip6_input.o net/ipv6/ip6_input.c
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'net/ipv6/ip6_input.c'.
4.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@ip6_rcv_core'
 #0 0x00007ff03dcbdf3d llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/bin/../lib/libLLVM-18.so+0x26bdf3d)
 #1 0x00007ff03dcbbb64 llvm::sys::RunSignalHandlers() (/usr/bin/../lib/libLLVM-18.so+0x26bbb64)
 #2 0x00007ff03dbfb0b6 (/usr/bin/../lib/libLLVM-18.so+0x25fb0b6)
 #3 0x00007ff03b2437c0 (/usr/bin/../lib/libc.so.6+0x437c0)
 #4 0x00007ff03e3ca82e llvm::SUnit::setHeightDirty() (/usr/bin/../lib/libLLVM-18.so+0x2dca82e)
 #5 0x00007ff03e3ca5b3 llvm::SUnit::addPred(llvm::SDep const&, bool) (/usr/bin/../lib/libLLVM-18.so+0x2dca5b3)
 #6 0x00007ff03e6987cb llvm::ScheduleDAGSDNodes::AddSchedEdges() (/usr/bin/../lib/libLLVM-18.so+0x30987cb)
 #7 0x00007ff03e68bcf9 (/usr/bin/../lib/libLLVM-18.so+0x308bcf9)
 #8 0x00007ff03e74aa52 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/usr/bin/../lib/libLLVM-18.so+0x314aa52)
 #9 0x00007ff03e749dd7 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/usr/bin/../lib/libLLVM-18.so+0x3149dd7)
#10 0x00007ff03e747ba9 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/usr/bin/../lib/libLLVM-18.so+0x3147ba9)
#11 0x00007ff03ff39ee6 (/usr/bin/../lib/libLLVM-18.so+0x4939ee6)
#12 0x00007ff03e1905b6 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/usr/bin/../lib/libLLVM-18.so+0x2b905b6)
#13 0x00007ff03de535e3 llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/bin/../lib/libLLVM-18.so+0x28535e3)
#14 0x00007ff03de5a923 llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/bin/../lib/libLLVM-18.so+0x285a923)
#15 0x00007ff03de5436e llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/bin/../lib/libLLVM-18.so+0x285436e)
#16 0x00007ff04356abb8 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::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/usr/bin/../lib/libclang-cpp.so.18+0x276abb8)
#17 0x00007ff043920020 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/bin/../lib/libclang-cpp.so.18+0x2b20020)
#18 0x00007ff0423da746 clang::ParseAST(clang::Sema&, bool, bool) (/usr/bin/../lib/libclang-cpp.so.18+0x15da746)
#19 0x00007ff044456ccd clang::FrontendAction::Execute() (/usr/bin/../lib/libclang-cpp.so.18+0x3656ccd)
#20 0x00007ff0443c1303 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/bin/../lib/libclang-cpp.so.18+0x35c1303)
#21 0x00007ff0444cec03 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/bin/../lib/libclang-cpp.so.18+0x36cec03)
#22 0x000056258e910d00 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang-18+0x11d00)
#23 0x000056258e90e69b (/usr/bin/clang-18+0xf69b)
#24 0x00007ff04400abdd (/usr/bin/../lib/libclang-cpp.so.18+0x320abdd)
#25 0x00007ff03dbfae83 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/bin/../lib/libLLVM-18.so+0x25fae83)
#26 0x00007ff04400a404 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const (/usr/bin/../lib/libclang-cpp.so.18+0x320a404)
#27 0x00007ff043fc9fe9 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/usr/bin/../lib/libclang-cpp.so.18+0x31c9fe9)
#28 0x00007ff043fca23e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&, bool) const (/usr/bin/../lib/libclang-cpp.so.18+0x31ca23e)
#29 0x00007ff043feaf00 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&) (/usr/bin/../lib/libclang-cpp.so.18+0x31eaf00)
#30 0x000056258e90daa0 clang_main(int, char**, llvm::ToolContext const&) (/usr/bin/clang-18+0xeaa0)
#31 0x000056258e91cb06 main (/usr/bin/clang-18+0x1db06)
#32 0x00007ff03b227f50 (/usr/bin/../lib/libc.so.6+0x27f50)
#33 0x00007ff03b22800a __libc_start_main (/usr/bin/../lib/libc.so.6+0x2800a)
#34 0x000056258e90a7a5 _start (/usr/bin/clang-18+0xb7a5)
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 18.0.0 (/home/smol/.cache/paru/clone/llvm-git/llvm-project b6d0ee056d247e1ecfd4ecd3f97fb2d31740d79b)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /sbin
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/ip6_input-bf5cb7.c
clang: note: diagnostic msg: /tmp/ip6_input-bf5cb7.sh
clang: note: diagnostic msg:

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

, deleting all compiler arguments except -march=znver4 yields the same error. Deleting it solves the error. Replacing -march= with any non-AMD CPU including x86 feature levels fixes the problem. Using x86-64-v4 and manually adding gfni and shstk instructions (which are AFAI-could-find the remaining instructions in znver4 not in x86-64-v4) also passes. Merely disabling CONFIG_ZERO_CALL_USED_REGS does not fix. But choosing znver1-4 triggers the error.

Anyone want to try to reproduce and investigate further?

@RKSimon
Copy link
Collaborator

RKSimon commented Dec 4, 2023

I'm not familiar enough with linux kernel builds to reproduce this, but if its happening with any znver* model suggests it could be something to do with the PostRAScheduler which AMD models enable by default.

@nathanchance
Copy link
Member

I can reproduce this now, I'll try to have a trivial reproducer later today.

@nathanchance
Copy link
Member

@RKSimon I bisected this issue to d96529a.

# bad: [01e40a8a3d40d7595d2cd95363c27d84b31e5cd2] [mlir][ArmSME] Remove ArmSMETypeConverter (and configure LLVM one instead) (#73639)
# good: [1f057e365f1fdd630c023a990e84e95a6c792e4d] [X86] AMD Zen 4 Initial enablement
git bisect start '01e40a8a3d40d7595d2cd95363c27d84b31e5cd2' '1f057e365f1fdd630c023a990e84e95a6c792e4d'
# good: [fcc9fa55a76a009ececfb1656142d3d7b0842489] [RISCV] Reduce the number of ExtInfo_rr permutations in tablegen.
git bisect good fcc9fa55a76a009ececfb1656142d3d7b0842489
# good: [e6d305e64fd39f0199b79d19dbc0d012efd83259] Add support of Windows Trace Logging macros
git bisect good e6d305e64fd39f0199b79d19dbc0d012efd83259
# good: [24f03d9b19dda40f757341ffa1ea89faa64cfbde] [clangd] Use llvm::erase_value (NFC)
git bisect good 24f03d9b19dda40f757341ffa1ea89faa64cfbde
# bad: [d51dd892ad451c9cebc43f4de5d2758c423a91c4] [Driver][LTO] Copy fix empty stats filename to AIX (#71738)
git bisect bad d51dd892ad451c9cebc43f4de5d2758c423a91c4
# bad: [df4cf0b937fdbcfad407883b74b56ded981b2d9c] [clang-tidy] Fixes a typo in the help message.
git bisect bad df4cf0b937fdbcfad407883b74b56ded981b2d9c
# good: [740582fa4c9512b34128dc97b2eff56820984421] [mlir][sparse] test for linalg tensor semantics (#70254)
git bisect good 740582fa4c9512b34128dc97b2eff56820984421
# good: [505e32302c07b9081fa1bc05daf72bafed6ca29a] [Test] NFC. Add missing "REQUIRES: x86-registered-target" to LoopStrengthReduce/scev-incorrect-nuw-inference.ll
git bisect good 505e32302c07b9081fa1bc05daf72bafed6ca29a
# bad: [0f8615f4dc568f4d7cbf73580eef3e78f64f3bd0] [flang][openacc][openmp] Set correct location on atomic operations (#70680)
git bisect bad 0f8615f4dc568f4d7cbf73580eef3e78f64f3bd0
# bad: [77c63391979ba2a7e5ab37ddf4714547c4f17f0a] [MLIR][mlir-opt] Add `registerationAndParseCLIOptions` for `MlirOptMain`. (#70581)
git bisect bad 77c63391979ba2a7e5ab37ddf4714547c4f17f0a
# good: [49ae2efb809db20603d500f02dd278247b542c73] [RISCV][GISel] Support G_FMA/NEG/ABS/SQRT/MAXNUM/MINNUM for F and D extension.
git bisect good 49ae2efb809db20603d500f02dd278247b542c73
# bad: [d96529af3c362c53ef2e8c883a9e571fb3626927] [DAG] Attempt shl narrowing in SimplifyDemandedBits (REAPPLIED)
git bisect bad d96529af3c362c53ef2e8c883a9e571fb3626927
# good: [35649c639cd3780652156f8aaca610d0a5f578b3] [MLIR][LLVM] Deprecate typed pointer operation builder (#70576)
git bisect good 35649c639cd3780652156f8aaca610d0a5f578b3
# good: [47793481a4dac8b23fbdface9679835ea551a86c] [mlir][tosa] Fix not to crash with large permutation indexes  (#69857)
git bisect good 47793481a4dac8b23fbdface9679835ea551a86c
# good: [f8fe40090ab302921bc4b83969bfec8b31c902aa] [clang][Interp][NFC] Make IntegralAP::isSigned() constexpr
git bisect good f8fe40090ab302921bc4b83969bfec8b31c902aa
# good: [3f64c0fc48c5b2efc5b9ba11351647d515f23418] [clang-tidy] Fix readability-avoid-const-params-in-decls - point to the correct const location (#69103)
git bisect good 3f64c0fc48c5b2efc5b9ba11351647d515f23418
# first bad commit: [d96529af3c362c53ef2e8c883a9e571fb3626927] [DAG] Attempt shl narrowing in SimplifyDemandedBits (REAPPLIED)

C reproducer from cvise:

enum {
  IPSTATS_MIB_NUM,
  IPSTATS_MIB_INPKTS,
  IPSTATS_MIB_OUTBCASTOCTETS,
  IPSTATS_MIB_CSUMERRORS,
  IPSTATS_MIB_NOECTPKTS,
  __IPSTATS_MIB_MAX
};
struct {
  long mibs[__IPSTATS_MIB_MAX];
} ip6_rcv_core__idev_0;
enum { SKB_DROP_REASON_NOT_SPECIFIED } ipv6_get_dsfield_ipv6h;
enum { INET_ECN_MASK = 3 } __in6_dev_get_dev;
int __in6_dev_get_dev_0;
char ip6_rcv_core___trans_tmp_6;
long ip6_rcv_core_pto_val__() {
  ({
    typeof(__in6_dev_get_dev_0) *__UNIQUE_ID_rcu783 = ({
      *(volatile typeof(_Generic(__in6_dev_get_dev,
          default: &__in6_dev_get_dev_0)) *)0;
    });
    __UNIQUE_ID_rcu783;
  });
  ip6_rcv_core___trans_tmp_6 = ipv6_get_dsfield_ipv6h >> 4;
  asm("add"
      "%[val]"
      ", "
      "var"
      : "+m"(ip6_rcv_core__idev_0.mibs[IPSTATS_MIB_NOECTPKTS +
                                       (ip6_rcv_core___trans_tmp_6 &
                                        INET_ECN_MASK)])
      : [val] "re"(ip6_rcv_core_pto_val__));
  return 0;
}
$ clang --target=x86_64-linux-gnu -O2 -c -o /dev/null ip6_input.i
ip6_input.i:22:5: warning: expression result unused [-Wunused-value]
   22 |     __UNIQUE_ID_rcu783;
      |     ^~~~~~~~~~~~~~~~~~
1 warning generated.

$ clang --target=x86_64-linux-gnu -march=znver4 -O2 -c -o /dev/null ip6_input.i
ip6_input.i:22:5: warning: expression result unused [-Wunused-value]
   22 |     __UNIQUE_ID_rcu783;
      |     ^~~~~~~~~~~~~~~~~~
clang: /home/nathan/tmp/cvise.P6kdzs0Ins/src/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:9853: SDValue llvm::SelectionDAG::getNode(unsigned int, const SDLoc &, SDVTList, ArrayRef<SDValue>, const SDNodeFlags): Assertion `Op.getOpcode() != ISD::DELETED_NODE && "Operand is DELETED_NODE!"' 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: clang --target=x86_64-linux-gnu -march=znver4 -O2 -c -o /dev/null ip6_input.i
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'ip6_input.i'.
4.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@ip6_rcv_core_pto_val__'
 #0 0x0000000002bf566c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x2bf566c)
 #1 0x0000000002bf3578 llvm::sys::RunSignalHandlers() (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x2bf3578)
 #2 0x0000000002b7b680 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x0000ffff92b117a0 (linux-vdso.so.1+0x7a0)
 #4 0x0000ffff924f1a40 __pthread_kill_implementation (/lib64/libc.so.6+0x91a40)
 #5 0x0000ffff924a5840 gsignal (/lib64/libc.so.6+0x45840)
 #6 0x0000ffff92490288 abort (/lib64/libc.so.6+0x30288)
 #7 0x0000ffff9249e580 __assert_fail_base (/lib64/libc.so.6+0x3e580)
 #8 0x0000ffff9249e5f4 (/lib64/libc.so.6+0x3e5f4)
 #9 0x0000000003b4b628 llvm::SelectionDAG::getNode(unsigned int, llvm::SDLoc const&, llvm::SDVTList, llvm::ArrayRef<llvm::SDValue>, llvm::SDNodeFlags) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x3b4b628)
#10 0x0000000003b6dfe0 llvm::SelectionDAGISel::Select_INLINEASM(llvm::SDNode*) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x3b6dfe0)
#11 0x0000000001dfb1b8 (anonymous namespace)::X86DAGToDAGISel::Select(llvm::SDNode*) X86ISelDAGToDAG.cpp:0:0
#12 0x0000000003b6a6b4 llvm::SelectionDAGISel::DoInstructionSelection() (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x3b6a6b4)
#13 0x0000000003b69748 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x3b69748)
#14 0x0000000003b6752c llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x3b6752c)
#15 0x0000000003b64670 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x3b64670)
#16 0x0000000001df31ec (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#17 0x00000000021daee0 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x21daee0)
#18 0x000000000272a2e0 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x272a2e0)
#19 0x0000000002731e1c llvm::FPPassManager::runOnModule(llvm::Module&) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x2731e1c)
#20 0x000000000272abf0 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x272abf0)
#21 0x00000000033099f4 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>>) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x33099f4)
#22 0x0000000003736eac clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) CodeGenAction.cpp:0:0
#23 0x00000000043ee5a4 clang::ParseAST(clang::Sema&, bool, bool) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x43ee5a4)
#24 0x00000000036683f4 clang::FrontendAction::Execute() (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x36683f4)
#25 0x00000000035f11b8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x35f11b8)
#26 0x0000000003730620 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x3730620)
#27 0x0000000001b9b1f0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x1b9b1f0)
#28 0x0000000001b97c48 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#29 0x00000000034b49b0 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::$_0>(long) Job.cpp:0:0
#30 0x0000000002b7b3d4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x2b7b3d4)
#31 0x00000000034b3fe4 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x34b3fe4)
#32 0x000000000347bcb0 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x347bcb0)
#33 0x000000000347bf00 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x347bf00)
#34 0x00000000034941d8 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x34941d8)
#35 0x0000000001b97098 clang_main(int, char**, llvm::ToolContext const&) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x1b97098)
#36 0x0000000001ba574c main (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x1ba574c)
#37 0x0000ffff924909dc __libc_start_call_main (/lib64/libc.so.6+0x309dc)
#38 0x0000ffff92490ab0 __libc_start_main@GLIBC_2.17 (/lib64/libc.so.6+0x30ab0)
#39 0x0000000001b945f0 _start (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/clang-18+0x1b945f0)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
ClangBuiltLinux clang version 18.0.0 (https://github.com/llvm/llvm-project d96529af3c362c53ef2e8c883a9e571fb3626927)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin
clang: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.

LLVM IR reproducer from llvm-reduce:

target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.anon = type { [5 x i64] }

@ip6_rcv_core__idev_0 = external global %struct.anon

define i64 @ip6_rcv_core_pto_val__() {
entry:
  %0 = load i32, ptr null, align 4
  %shr = lshr i32 %0, 1
  %and = and i32 %shr, 1
  %add = or i32 %and, 4
  %idxprom = zext i32 %add to i64
  %arrayidx = getelementptr [5 x i64], ptr @ip6_rcv_core__idev_0, i64 0, i64 %idxprom
  tail call void asm "add$1, var", "=*m,re,*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %arrayidx, ptr @ip6_rcv_core_pto_val__, ptr elementtype(i64) %arrayidx)
  ret i64 0
}
$ llc -o /dev/null reduced.ll
llc: /home/nathan/tmp/cvise.P6kdzs0Ins/src/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:9853: SDValue llvm::SelectionDAG::getNode(unsigned int, const SDLoc &, SDVTList, ArrayRef<SDValue>, const SDNodeFlags): Assertion `Op.getOpcode() != ISD::DELETED_NODE && "Operand is DELETED_NODE!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: llc -o /dev/null reduced.ll
1.	Running pass 'Function Pass Manager' on module 'reduced.ll'.
2.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@ip6_rcv_core_pto_val__'
 #0 0x00000000024c4450 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/llc+0x24c4450)
 #1 0x00000000024c22bc llvm::sys::RunSignalHandlers() (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/llc+0x24c22bc)
 #2 0x00000000024c4cf8 SignalHandler(int) Signals.cpp:0:0
 #3 0x0000ffff860ad7a0 (linux-vdso.so.1+0x7a0)
 #4 0x0000ffff85a81a40 __pthread_kill_implementation (/lib64/libc.so.6+0x91a40)
 #5 0x0000ffff85a35840 gsignal (/lib64/libc.so.6+0x45840)
 #6 0x0000ffff85a20288 abort (/lib64/libc.so.6+0x30288)
 #7 0x0000ffff85a2e580 __assert_fail_base (/lib64/libc.so.6+0x3e580)
 #8 0x0000ffff85a2e5f4 (/lib64/libc.so.6+0x3e5f4)
 #9 0x00000000022fd730 llvm::SelectionDAG::getNode(unsigned int, llvm::SDLoc const&, llvm::SDVTList, llvm::ArrayRef<llvm::SDValue>, llvm::SDNodeFlags) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/llc+0x22fd730)
#10 0x000000000232146c llvm::SelectionDAGISel::Select_INLINEASM(llvm::SDNode*) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/llc+0x232146c)
#11 0x00000000014444e8 (anonymous namespace)::X86DAGToDAGISel::Select(llvm::SDNode*) X86ISelDAGToDAG.cpp:0:0
#12 0x000000000231db30 llvm::SelectionDAGISel::DoInstructionSelection() (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/llc+0x231db30)
#13 0x000000000231cbc4 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/llc+0x231cbc4)
#14 0x000000000231a9a8 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/llc+0x231a9a8)
#15 0x0000000002317aec llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/llc+0x2317aec)
#16 0x000000000143c51c (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#17 0x0000000001950c6c llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/llc+0x1950c6c)
#18 0x0000000001e55888 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/llc+0x1e55888)
#19 0x0000000001e5d480 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/llc+0x1e5d480)
#20 0x0000000001e56228 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/llc+0x1e56228)
#21 0x00000000011ca440 main (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/llc+0x11ca440)
#22 0x0000ffff85a209dc __libc_start_call_main (/lib64/libc.so.6+0x309dc)
#23 0x0000ffff85a20ab0 __libc_start_main@GLIBC_2.17 (/lib64/libc.so.6+0x30ab0)
#24 0x00000000011c5630 _start (/home/nathan/tmp/cvise.P6kdzs0Ins/install/llvm-bad/bin/llc+0x11c5630)

@nathanchance nathanchance removed incomplete Issue not complete (e.g. missing a reproducer, build arguments, etc.) LTO Link time optimization (regular/full LTO or ThinLTO) labels Dec 5, 2023
@RKSimon RKSimon self-assigned this Dec 5, 2023
@RKSimon
Copy link
Collaborator

RKSimon commented Dec 5, 2023

SimplifyDemandedBits is awesome at shaking down code :-|

@KyunLFA
Copy link

KyunLFA commented Dec 10, 2023

@RKSimon I see there are some new branches on your fork of llvm-project dating pretty close to the issue being (self)assigned to you, but I don't see any of them clearly labeled to be related to this, could you please elaborate on those if possible, or give any pointers as how to best work around this issue for experimenting purposes?

@RKSimon RKSimon removed their assignment Dec 10, 2023
@RKSimon
Copy link
Collaborator

RKSimon commented Dec 10, 2023

Haven't had time to look at this in depth. Returning to the pool if you want to give it a go

@KyunLFA
Copy link

KyunLFA commented Dec 10, 2023

My bad, I gave the wrong idea. I wasn't trying to demand/coerce you to progress on the matter, simply I wasn't sure if one of those branches contained the fix since they were created around the same time, hence the "elaborate on those".

As for me, I'm not, well, I could try to just fix conflicts from reverting the problematic commit (which I gave up quickly at before since I don't know enough about the codebase), but I wouldn't dare publish that (laugh), I'm not a contributor yet alone a proper dev.

I'm sorry that I gave the impression. If you so choose feel free to take up the issue again at your own pace.

@berolinux
Copy link

Probably a duplicate of #50640

@berolinux
Copy link

Further reduced test case:

long a[1];
char b();
void c() { asm("" : "+m"(a[1 + (b() & 1)])); }

@FireBurn
Copy link

This bug has been open for 5 months, is it any closer to being resolved? If it was bisected to d96529a should that be reverted again?

@eXt73
Copy link

eXt73 commented May 12, 2024

Today's kernel compilation attempt with LLVM/clang/lld 18.1.6 ... flags for zen-3, Full-LTO, etc. ... and this error still occurs = under 17.0.6 everything is ok:

ld.lld-18: warning: <unknown>:0:0: stack frame size (1352) exceeds limit (1024) in function 'kvm_hv_flush_tlb'
ld.lld-18: warning: <unknown>:0:0: stack frame size (1080) exceeds limit (1024) in function 'do_sys_poll'
ld.lld-18: warning: <unknown>:0:0: stack frame size (1288) exceeds limit (1024) in function 'HUF_readCTable'
ld.lld-18: warning: <unknown>:0:0: stack frame size (1224) exceeds limit (1024) in function 'try_to_generate_entropy'
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: ld.lld-18 -m elf_x86_64 -mllvm -import-instr-limit=5 -z noexecstack -r -o vmlinux.o -T .tmp_initcalls.lds --whole-archive vmlinux.a --no-whole-archive --start-group --end-group
1.      Running pass 'Function Pass Manager' on module 'ld-temp.o'.
2.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@ip6_rcv_core'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  libLLVM.so.18.1 0x00007fbc347946d6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 54
1  libLLVM.so.18.1 0x00007fbc34792690 llvm::sys::RunSignalHandlers() + 80
2  libLLVM.so.18.1 0x00007fbc34794d9b
3  libc.so.6       0x00007fbc33242520
4  libc.so.6       0x00007fbc332a5795 realloc + 85
5  libLLVM.so.18.1 0x00007fbc3472f3fd llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long) + 93
6  libLLVM.so.18.1 0x00007fbc34cfc669 llvm::SUnit::addPred(llvm::SDep const&, bool) + 505
7  libLLVM.so.18.1 0x00007fbc34f456af llvm::ScheduleDAGSDNodes::AddSchedEdges() + 847
8  libLLVM.so.18.1 0x00007fbc34f3c4d6
9  libLLVM.so.18.1 0x00007fbc34fe9f18 llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 1608
10 libLLVM.so.18.1 0x00007fbc34fe8f92 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 4354
11 libLLVM.so.18.1 0x00007fbc34fe714e llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 1726
12 libLLVM.so.18.1 0x00007fbc3746cb8f
13 libLLVM.so.18.1 0x00007fbc34b54fe4 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 852
14 libLLVM.so.18.1 0x00007fbc348db00f llvm::FPPassManager::runOnFunction(llvm::Function&) + 687
15 libLLVM.so.18.1 0x00007fbc348e0903 llvm::FPPassManager::runOnModule(llvm::Module&) + 51
16 libLLVM.so.18.1 0x00007fbc348db704 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 1012
17 libLLVM.so.18.1 0x00007fbc35d8a78a
18 libLLVM.so.18.1 0x00007fbc35d898f3 llvm::lto::backend(llvm::lto::Config const&, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex&) + 307
19 libLLVM.so.18.1 0x00007fbc35d7d860 llvm::lto::LTO::runRegularLTO(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>) + 1328
20 libLLVM.so.18.1 0x00007fbc35d7d085 llvm::lto::LTO::run(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, std::function<llvm::Expected<std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>> (unsigned int, llvm::StringRef, llvm::Twine const&)>) + 629
21 ld.lld-18       0x00005605f9315244 lld::elf::BitcodeCompiler::compile() + 1156
22 ld.lld-18       0x00005605f929d116 void lld::elf::LinkerDriver::compileBitcodeFiles<llvm::object::ELFType<(llvm::endianness)1, true>>(bool) + 214
23 ld.lld-18       0x00005605f9299a95 lld::elf::LinkerDriver::link(llvm::opt::InputArgList&) + 17541
24 ld.lld-18       0x00005605f928c762 lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) + 4498
25 ld.lld-18       0x00005605f928b587 lld::elf::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) + 1863
26 ld.lld-18       0x00005605f91dda79 lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>, bool) + 1801
27 ld.lld-18       0x00005605f91dcdc6 lld_main(int, char**, llvm::ToolContext const&) + 310
28 ld.lld-18       0x00005605f91dd336 main + 102
29 libc.so.6       0x00007fbc33229d90
30 libc.so.6       0x00007fbc33229e40 __libc_start_main + 128
31 ld.lld-18       0x00005605f91dca05 _start + 37
Bus error
make[3]: *** [scripts/Makefile.vmlinux_o:62: vmlinux.o] Błąd 135
make[2]: *** [/usr/src/linux-headers-6.8.9-ext73-108.10-ryzen-3/Makefile:1143: vmlinux_o] Błąd 2
make[1]: *** [Makefile:240: __sub-make] Błąd 2
make[1]: Opuszczenie katalogu '/usr/src/linux-headers-6.8.9-ext73-108.10-ryzen-3'
make: *** [debian/ruleset/targets/common.mk:301: debian/stamp/build/kernel] Błąd 2

@EugeneZelenko EugeneZelenko added the LTO Link time optimization (regular/full LTO or ThinLTO) label May 12, 2024
@FireBurn
Copy link

@tstellar @tstellarAMD is someone from AMD able to take a look at this?

@Nanotwerp
Copy link

Nanotwerp commented May 14, 2024

@eXt73 @FireBurn This will be fixed by #85081. Until it's (hopefully) merged, you can apply it as a patch to LLVM and compile it.

@eXt73
Copy link

eXt73 commented May 14, 2024

@eXt73 @FireBurn This will be fixed by #85081. Until it's (hopefully) merged, can apply it as a patch to LLVM and compile it.

thanks for info, I hope it will be implemented as soon as possible :)

@Mekapaedia
Copy link

The repro at https://godbolt.org/z/En7dccW9P now compiles correctly with trunk (you may need to rerun the compilation after opening the link but it does work) - could this issue now be closed?

@eXt73
Copy link

eXt73 commented Jul 17, 2024

The repro at https://godbolt.org/z/En7dccW9P now compiles correctly with trunk (you may need to rerun the compilation after opening the link but it does work) - could this issue now be closed?

but the mainline still does not work correctly - I tested with yesterday's compilation 18.1.8 ... errors again

@Mekapaedia
Copy link

The repro at https://godbolt.org/z/En7dccW9P now compiles correctly with trunk (you may need to rerun the compilation after opening the link but it does work) - could this issue now be closed?

but the mainline still does not work correctly - I tested with yesterday's compilation 18.1.8 ... errors again

It has just been commited, you may not see this fix until 19 is released. If the trunk builds correctly, though, the issue can be closed

@nathanchance
Copy link
Member

I tested at 3fae555 (which includes 46505b3) and the build completes fine now. I think all issues related to this can now be closed.

@EugeneZelenko EugeneZelenko added llvm:SelectionDAG SelectionDAGISel as well and removed backend:X86 LTO Link time optimization (regular/full LTO or ThinLTO) labels Jul 17, 2024
@StatusCode404
Copy link

18.1.8 can't build linux-6.6.43 which is an LTS kernel.
Fixes should be back-ported to v18; to a v18.1.9. Otherwise you have an entire version that can't build a kernel for zen!

This is my build command...

time (KCFLAGS="-O3 -w -feliminate-unused-debug-types -fstack-protector-strong -fstack-clash-protection -D_FORTIFY_SOURCE=2 -fasynchronous-unwind-tables -fno-semantic-interposition -fno-trapping-math -ffat-lto-objects -march=znver3 -mtune=znver3  -pipe -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wp,-D_GLIBCXX_ASSERTIONS" KCPPFLAGS="-O3 -w -feliminate-unused-debug-types -fstack-protector-strong -fstack-clash-protection -D_FORTIFY_SOURCE=2 -fasynchronous-unwind-tables -fno-semantic-interposition -fno-trapping-math -ffat-lto-objects -march=znver3 -mtune=znver3 -pipe -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wp,-D_GLIBCXX_ASSERTIONS" make LLVM=1 LLVM_IAS=1 bindeb-pkg -j$(nproc) LOCALVERSION=-danglingpointer-znver3-clang)

@RKSimon
Copy link
Collaborator

RKSimon commented Aug 4, 2024

FYI @tru - I think I know what the answer will be - but we're hitting a lot of reports regarding 18.x not building the linux kernel with some -march combos.

@nathanchance
Copy link
Member

FYI @tru - I think I know what the answer will be - but we're hitting a lot of reports regarding 18.x not building the linux kernel with some -march combos.

I don't really have a strong opinion but I want to clarify that this is largely self inflicted on the part of kernel builders, as the upstream kernel does not have any uses of -march=znver. They are either applying these flags via KCFLAGS like the build command above or applying an out of tree patch to achieve this via Kconfig. I think if folks really care about optimizing for their particular CPU, it does not seem like too much of an ask to have them rebuild their toolchains (or just upgrade to LLVM 19).

@aruhier
Copy link

aruhier commented Aug 4, 2024

@nathanchance I would agree if the patch was complicated to backport, here I don't understand the reason of pushing back: Arch and Gentoo (and probably other linux distributions) are already backporting the patch, it applies well on 18.1: https://gitlab.archlinux.org/archlinux/packaging/packages/llvm/-/blob/main/PKGBUILD?ref_type=heads#L18, https://gitweb.gentoo.org/repo/gentoo.git/commit/sys-devel/llvm?id=0324fa3c789398654e760d47b826e831000e0b91.

@nathanchance
Copy link
Member

@nathanchance I would agree if the patch was complicated to backport, here I don't understand the reason of pushing back: Arch and Gentoo (and probably other linux distributions) are already backporting the patch, it applies well on 18.1: ...

I am not pushing back on backporting the patch altogether; if the release managers feel this is worthy of a new release, I am not going to argue with that. I am merely clarifying that this is an issue that one has to go out of their way to hit and building the kernel without that specific -march value does not impact the usability of the kernel, so I am not sure this issue is "critical" enough to warrant a new release of a version that is no longer supported on paper. Again, not my call, but I want to make sure that all the facts are available for them to make that decision.

@tru
Copy link
Collaborator

tru commented Aug 5, 2024

It would be norm breaking to release a new 18.x now, it doesn't seem like a security issue or a fatal error that leads to some really bad outcomes especially when there are workarounds.

Releasing a new version of LLVM is a pretty intensive process and we are currently focusing on the LLVM 19 release. So I will not have the extra bandwidth to do it. If @tstellar have the time and think it should prioritized I won't block a new 18 release, but if it was only up to me I would say that we don't do it.

@tstellar
Copy link
Collaborator

tstellar commented Aug 5, 2024

It sounds like this can be worked-around by using -march=x86-64-v4 . How much performance difference is there between -march=x86_64-v4 and -march=znver4 ?

@FireBurn
Copy link

FireBurn commented Aug 5, 2024

@tstellar if you do cut another release can you also make sure #93206 is included. I think all off these patches have been cherry-picked to Android's NDK 27 if that helps sway you

@xdevs23
Copy link

xdevs23 commented Feb 5, 2025

Hey,

I think I narrowed down the issue that is affecting the kernel compile here. The problem is when LLVM Clang tries to compile C files under net/ipv6 with the Zen(1-4) scheduler model. Given linux-next 1st of Dec 2023, LLVM commit b6d0ee05, and error
[...]
, deleting all compiler arguments except -march=znver4 yields the same error. Deleting it solves the error. Replacing -march= with any non-AMD CPU including x86 feature levels fixes the problem. Using x86-64-v4 and manually adding gfni and shstk instructions (which are AFAI-could-find the remaining instructions in znver4 not in x86-64-v4) also passes. Merely disabling CONFIG_ZERO_CALL_USED_REGS does not fix. But choosing znver1-4 triggers the error.

Anyone want to try to reproduce and investigate further?

I've set it to Zen 1 and am getting the same error on NixOS with clang 18.1.8 and Linux 6.13 (with -O3 enabled):

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: /nix/store/n266hs15lrsvb3h2nyiasj0gyxzxgxrc-clang-18.1.8/bin/clang @/tmp/nix-shell-6241-0/cc-params.WK0QOQ
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'net/ipv6/ip6_input.c'.
4.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@ip6_rcv_core'
 #0 0x00007f44bf4dd2de llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/libLLVM.so.18.1+0xedd2de)
 #1 0x00007f44bf4db04c llvm::sys::CleanupOnSignal(unsigned long) (/usr/lib/libLLVM.so.18.1+0xedb04c)
 #2 0x00007f44bf3cd498 CrashRecoverySignalHandler(int) (/usr/lib/libLLVM.so.18.1+0xdcd498)
 #3 0x00007f44be047620 __restore_rt (/usr/lib/libc.so.6+0x40620)
 #4 0x00007f44be0a8e15 __libc_realloc (/usr/lib/libc.so.6+0xa1e15)
 #5 0x00007f44bf443574 llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long) (/usr/lib/libLLVM.so.18.1+0xe43574)
 #6 0x00007f44bfc4ba44 llvm::SUnit::addPred(llvm::SDep const&, bool) (/usr/lib/libLLVM.so.18.1+0x164ba44)
 #7 0x00007f44bff71caa llvm::ScheduleDAGSDNodes::AddSchedEdges() (/usr/lib/libLLVM.so.18.1+0x1971caa)
 #8 0x00007f44bff69d22 (anonymous namespace)::ScheduleDAGRRList::Schedule() (/usr/lib/libLLVM.so.18.1+0x1969d22)
 #9 0x00007f44c004e59e llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/usr/lib/libLLVM.so.18.1+0x1a4e59e)
#10 0x00007f44c0050e37 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/usr/lib/libLLVM.so.18.1+0x1a50e37)
#11 0x00007f44c005338a llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) (/usr/lib/libLLVM.so.18.1+0x1a5338a)
#12 0x00007f44c33e4850 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/usr/lib/libLLVM.so.18.1+0x4de4850)
#13 0x00007f44bfa07378 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) (/usr/lib/libLLVM.so.18.1+0x1407378)
#14 0x00007f44bf687d19 llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/lib/libLLVM.so.18.1+0x1087d19)
#15 0x00007f44bf68806c llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/lib/libLLVM.so.18.1+0x108806c)
#16 0x00007f44bf688a6e llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib/libLLVM.so.18.1+0x1088a6e)
#17 0x00007f44c90ac396 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/nix/store/flqqrbm3pv9mcxf7xg1j6ssmfwxwrsdx-clang-18.1.8-lib/lib/libclang-cpp.so.18.1+0x1eac396)
#18 0x00007f44c90ac992 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*) (/nix/store/flqqrbm3pv9mcxf7xg1j6ssmfwxwrsdx-clang-18.1.8-lib/lib/libclang-cpp.so.18.1+0x1eac992)
#19 0x00007f44c951025e clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/nix/store/flqqrbm3pv9mcxf7xg1j6ssmfwxwrsdx-clang-18.1.8-lib/lib/libclang-cpp.so.18.1+0x231025e)
#20 0x00007f44c7e11ec9 clang::ParseAST(clang::Sema&, bool, bool) (/nix/store/flqqrbm3pv9mcxf7xg1j6ssmfwxwrsdx-clang-18.1.8-lib/lib/libclang-cpp.so.18.1+0xc11ec9)
#21 0x00007f44c9ed14d9 clang::FrontendAction::Execute() (/nix/store/flqqrbm3pv9mcxf7xg1j6ssmfwxwrsdx-clang-18.1.8-lib/lib/libclang-cpp.so.18.1+0x2cd14d9)
#22 0x00007f44c9e4c179 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/nix/store/flqqrbm3pv9mcxf7xg1j6ssmfwxwrsdx-clang-18.1.8-lib/lib/libclang-cpp.so.18.1+0x2c4c179)
#23 0x00007f44c9f5e4bb clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/nix/store/flqqrbm3pv9mcxf7xg1j6ssmfwxwrsdx-clang-18.1.8-lib/lib/libclang-cpp.so.18.1+0x2d5e4bb)
#24 0x0000000000416a46 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/nix/store/n266hs15lrsvb3h2nyiasj0gyxzxgxrc-clang-18.1.8/bin/clang+0x416a46)
#25 0x000000000040edea ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) (/nix/store/n266hs15lrsvb3h2nyiasj0gyxzxgxrc-clang-18.1.8/bin/clang+0x40edea)
#26 0x00007f44c9a97a29 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) (/nix/store/flqqrbm3pv9mcxf7xg1j6ssmfwxwrsdx-clang-18.1.8-lib/lib/libclang-cpp.so.18.1+0x2897a29)
#27 0x00007f44bf3cd8d3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/lib/libLLVM.so.18.1+0xdcd8d3)
#28 0x00007f44c9a98131 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) (/nix/store/flqqrbm3pv9mcxf7xg1j6ssmfwxwrsdx-clang-18.1.8-lib/lib/libclang-cpp.so.18.1+0x2898131)
#29 0x00007f44c9a5eee4 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/nix/store/flqqrbm3pv9mcxf7xg1j6ssmfwxwrsdx-clang-18.1.8-lib/lib/libclang-cpp.so.18.1+0x285eee4)
#30 0x00007f44c9a5fa0d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/nix/store/flqqrbm3pv9mcxf7xg1j6ssmfwxwrsdx-clang-18.1.8-lib/lib/libclang-cpp.so.18.1+0x285fa0d)
#31 0x00007f44c9a725f4 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/nix/store/flqqrbm3pv9mcxf7xg1j6ssmfwxwrsdx-clang-18.1.8-lib/lib/libclang-cpp.so.18.1+0x28725f4)
#32 0x00000000004140a2 clang_main(int, char**, llvm::ToolContext const&) (/nix/store/n266hs15lrsvb3h2nyiasj0gyxzxgxrc-clang-18.1.8/bin/clang+0x4140a2)
#33 0x000000000040e106 main (/nix/store/n266hs15lrsvb3h2nyiasj0gyxzxgxrc-clang-18.1.8/bin/clang+0x40e106)
#34 0x00007f44be03127e __libc_start_call_main (/usr/lib/libc.so.6+0x2a27e)
#35 0x00007f44be031339 __libc_start_main@GLIBC_2.2.5 (/usr/lib/libc.so.6+0x2a339)
#36 0x000000000040e165 _start (/nix/store/n266hs15lrsvb3h2nyiasj0gyxzxgxrc-clang-18.1.8/bin/clang+0x40e165)
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 18.1.8
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /nix/store/n266hs15lrsvb3h2nyiasj0gyxzxgxrc-clang-18.1.8/bin

@RKSimon
Copy link
Collaborator

RKSimon commented Feb 5, 2025

@xdevs23 Are you using -march=native or -march=x86-64-v4 ? The latter should avoid the issue.

@xdevs23
Copy link

xdevs23 commented Feb 5, 2025

@RKSimon

Are you using -march=native or -march=x86-64-v4 ? The latter should avoid the issue.

Using CONFIG_MZEN=y, but yeah, I know how to work around it, I just wanted to add my 2 cents for the record.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] llvm:SelectionDAG SelectionDAGISel as well
Projects
None yet
Development

No branches or pull requests