Issue |
123809
|
Summary |
Segmentation Fault in X86TTIImpl::getCastInstrCost during Loop Vectorization of asn1_compiler.c (Linux Kernel 6.13)
|
Labels |
new issue
|
Assignees |
|
Reporter |
ms178
|
**Description:**
I am encountering a segmentation fault while compiling the `asn1_compiler` component of the Linux kernel 6.13 using a recent development snapshot of LLVM. The crash occurs during the loop vectorization optimization pass and appears to be related to the cost model for cast instructions on x86.
**Environment:**
* **LLVM Version:** 20.0.0git (commit: e4f03b158c97098e1835cc1f00d0175398974f98)
* **Target:** x86_64-pc-linux-gnu
* **Host System:** CachyOS
* **Target CPU:** Intel Raptor Lake
* **Kernel:** Linux Kernel 6.13 (CachyOS patched)
**Steps to Reproduce:**
1. Clone the CachyOS Linux kernel 6.13 source code. I am using some extra patches available [in my repo](https://github.com/ms178/archpkgbuilds/tree/main/packages/linux-cachyos).
2. Configure the kernel build with LLVM as the compiler.
3. Build the kernel.
**Expected Behavior:**
The `asn1_compiler` should compile successfully without any errors.
**Actual Behavior:**
The compilation crashes with a segmentation fault during the optimization of `scripts/asn1_compiler.c`.
Stack trace:
```
HOSTCC scripts/asn1_compiler
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /home/marcus/llvm20/bin/clang-20 -cc1 -triple x86_64-pc-linux-gnu -emit-obj -dumpdir scripts/asn1_compiler- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name asn1_compiler.c -function-alignment 5 -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -ffp-contract=fast -fno-rounding-math -ffp-exception-behavior=ignore -mconstructor-aliases -funwind-tables=2 -target-cpu raptorlake -target-feature +prfchw -target-feature -cldemote -target-feature +avx -target-feature +sahf -target-feature -xop -target-feature +crc32 -target-feature -amx-fp8 -target-feature +xsaves -target-feature -avx512fp16 -target-feature -usermsr -target-feature -sm4 -target-feature -egpr -target-feature +sse4.1 -target-feature -avx512ifma -target-feature +xsave -target-feature +sse4.2 -target-feature -tsxldtrk -target-feature -sm3 -target-feature +ptwrite -target-feature +widekl -target-feature -movrs -target-feature +invpcid -target-feature +64bit -target-feature +xsavec -target-feature -avx10.1-512 -target-feature -avx512vpopcntdq -target-feature +cmov -target-feature -avx512vp2intersect -target-feature -avx512cd -target-feature +movbe -target-feature -avxvnniint8 -target-feature -ccmp -target-feature -amx-int8 -target-feature +kl -target-feature -avx10.1-256 -target-feature -sha512 -target-feature +avxvnni -target-feature -rtm -target-feature +adx -target-feature +avx2 -target-feature +hreset -target-feature +movdiri -target-feature +serialize -target-feature +vpclmulqdq -target-feature -avx512vl -target-feature -uintr -target-feature -cf -target-feature +clflushopt -target-feature -raoint -target-feature -cmpccxadd -target-feature +bmi -target-feature -amx-tile -target-feature +sse -target-feature -avx10.2-256 -target-feature +gfni -target-feature -avxvnniint16 -target-feature -amx-fp16 -target-feature -zu -target-feature -ndd -target-feature +xsaveopt -target-feature +rdrnd -target-feature -avx512f -target-feature -amx-bf16 -target-feature -avx512bf16 -target-feature -avx512vnni -target-feature -push2pop2 -target-feature +cx8 -target-feature -avx512bw -target-feature +sse3 -target-feature +pku -target-feature -nf -target-feature -amx-tf32 -target-feature -amx-avx512 -target-feature +fsgsbase -target-feature -clzero -target-feature -mwaitx -target-feature -lwp -target-feature +lzcnt -target-feature +sha -target-feature +movdir64b -target-feature -ppx -target-feature -wbnoinvd -target-feature -enqcmd -target-feature -amx-transpose -target-feature -avx10.2-512 -target-feature -avxneconvert -target-feature -tbm -target-feature -pconfig -target-feature -amx-complex -target-feature +ssse3 -target-feature +cx16 -target-feature +fma -target-feature +popcnt -target-feature -avxifma -target-feature +f16c -target-feature -avx512bitalg -target-feature -rdpru -target-feature +clwb -target-feature +mmx -target-feature +sse2 -target-feature +rdseed -target-feature -avx512vbmi2 -target-feature -prefetchi -target-feature -amx-movrs -target-feature +rdpid -target-feature -fma4 -target-feature -avx512vbmi -target-feature +shstk -target-feature +vaes -target-feature +waitpkg -target-feature -sgx -target-feature +fxsr -target-feature -avx512dq -target-feature -sse4a -target-feature +aes -target-feature +bmi2 -target-feature +pclmul -tune-cpu raptorlake -debugger-tuning=gdb -fdebug-compilation-dir=/tmp/makepkg/linux-cachyos/src/linux-6.13 -ffunction-sections -fdata-sections -fsplit-machine-functions -fcoverage-compilation-dir=/tmp/makepkg/linux-cachyos/src/linux-6.13 -resource-dir /home/marcus/llvm20/lib/clang/20 -dependency-file scripts/.asn1_compiler.d -MT scripts/asn1_compiler -I ./scripts/include -I ./include -internal-isystem /home/marcus/llvm20/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../x86_64-pc-linux-gnu/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -source-date-epoch 1737487879 -O3 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wno-error -w -std=gnu11 -ferror-limit 19 -fcf-protection=none -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -mprefer-vector-width=256 -mllvm -inline-threshold=1000 -mllvm -extra-vectorizer-passes -mllvm -enable-cond-stores-vec -mllvm -slp-vectorize-hor-store -mllvm -enable-loopinterchange -mllvm -enable-loop-distribute -mllvm -enable-unroll-and-jam -mllvm -enable-loop-flatten -mllvm -unroll-runtime-multi-exit -mllvm -aggressive-ext-opt -mllvm -enable-interleaved-mem-accesses -mllvm -enable-masked-interleaved-mem-accesses -mllvm -adce-remove-loops -mllvm -enable-ext-tsp-block-placement -mllvm -enable-gvn-hoist -mllvm -enable-dfa-jump-thread -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/asn1_compiler-456ed7.o -x c scripts/asn1_compiler.c
1. <eof> parser at end of file
2. Optimizer
3. Running pass "function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,extra-vector-passes,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,early-cse<>,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop(loop-unroll-and-jam),loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)" on module "scripts/asn1_compiler.c"
4. Running pass "loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>" on function "main"
#0 0x00005e1b5aed88c2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) Signals.cpp:0:0
#1 0x00005e1b5aed8ccf SignalHandler(int) Signals.cpp:0:0
#2 0x00007762de845f50 (/usr/lib/libc.so.6+0x45f50)
#3 0x00005e1b58dd7acd llvm::X86TTIImpl::getCastInstrCost(unsigned int, llvm::Type*, llvm::Type*, llvm::TargetTransformInfo::CastContextHint, llvm::TargetTransformInfo::TargetCostKind, llvm::Instruction const*) (.cold) X86TargetTransformInfo.cpp:0:0
#4 0x00005e1b5bc88c83 llvm::VPWidenCastRecipe::computeCost(llvm::ElementCount, llvm::VPCostContext&) const (/home/marcus/llvm20/bin/clang-20+0xce88c83)
#5 0x00005e1b5bc8322b llvm::VPRecipeBase::cost(llvm::ElementCount, llvm::VPCostContext&) (/home/marcus/llvm20/bin/clang-20+0xce8322b)
#6 0x00005e1b5bc761c3 llvm::VPBasicBlock::cost(llvm::ElementCount, llvm::VPCostContext&) (/home/marcus/llvm20/bin/clang-20+0xce761c3)
#7 0x00005e1b5bc7637d llvm::VPRegionBlock::cost(llvm::ElementCount, llvm::VPCostContext&) (/home/marcus/llvm20/bin/clang-20+0xce7637d)
#8 0x00005e1b5bc23e9c llvm::LoopVectorizationPlanner::cost(llvm::VPlan&, llvm::ElementCount) const LoopVectorize.cpp:0:0
#9 0x00005e1b5bc24265 llvm::LoopVectorizationPlanner::computeBestVF() LoopVectorize.cpp:0:0
#10 0x00005e1b5bc52312 llvm::LoopVectorizePass::processLoop(llvm::Loop*) LoopVectorize.cpp:0:0
#11 0x00005e1b59b252c1 llvm::LoopVectorizePass::runImpl(llvm::Function&) LoopVectorize.cpp:0:0
#12 0x00005e1b599aed27 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (.cold) bolt-pseudo.o:0:0
#13 0x00005e1b58af07cd llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilder.cpp:0:0
#14 0x00005e1b57cfc769 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/marcus/llvm20/bin/clang-20+0x8efc769)
#15 0x00005e1b57cfc11b llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) AMDGPUTargetMachine.cpp:0:0
#16 0x00005e1b57faea24 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/marcus/llvm20/bin/clang-20+0x91aea24)
#17 0x00005e1b57fae6a9 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) AMDGPUTargetMachine.cpp:0:0
#18 0x00005e1b57fb7744 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/marcus/llvm20/bin/clang-20+0x91b7744)
#19 0x00005e1b586a8fdf (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(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>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0
#20 0x00005e1b585c1fef clang::emitBackendOutput(clang::CompilerInstance&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/home/marcus/llvm20/bin/clang-20+0x97c1fef)
#21 0x00005e1b59a64ca2 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/marcus/llvm20/bin/clang-20+0xac64ca2)
#22 0x00005e1b57d7a684 clang::ParseAST(clang::Sema&, bool, bool) (/home/marcus/llvm20/bin/clang-20+0x8f7a684)
#23 0x00005e1b5873281e clang::FrontendAction::Execute() (/home/marcus/llvm20/bin/clang-20+0x993281e)
#24 0x00005e1b5869a9ab clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/marcus/llvm20/bin/clang-20+0x989a9ab)
#25 0x00005e1b5869ad9c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/marcus/llvm20/bin/clang-20+0x989ad9c)
#26 0x00005e1b58698b4e cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/marcus/llvm20/bin/clang-20+0x9898b4e)
#27 0x00005e1b5869a2f1 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#28 0x00005e1b58697d19 clang_main(int, char**, llvm::ToolContext const&) (/home/marcus/llvm20/bin/clang-20+0x9897d19)
#29 0x00005e1b52a9b752 (/home/marcus/llvm20/bin/clang-20+0x3c9b752)
#30 0x00007762de826187 (/usr/lib/libc.so.6+0x26187)
#31 0x00007762de826237 __libc_start_main (/usr/lib/libc.so.6+0x26237)
#32 0x00005e1b533bce71 _start (/home/marcus/llvm20/bin/clang-20+0x45bce71)
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 20.0.0git (https://github.com/llvm/llvm-project.git e4f03b158c97098e1835cc1f00d0175398974f98)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /home/marcus/llvm20/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/asn1_compiler-82f6f2.c
clang: note: diagnostic msg: /tmp/asn1_compiler-82f6f2.sh
clang: note: diagnostic msg:
********************
make[2]: *** [scripts/Makefile.host:114: scripts/asn1_compiler] Fehler 1
make[1]: *** [/tmp/makepkg/linux-cachyos/src/linux-6.13/Makefile:1255: scripts] Fehler 2
make: *** [Makefile:251: __sub-make] Fehler 2
```
[asn1_compiler-82f6f2.c.txt](https://github.com/user-attachments/files/18495726/asn1_compiler-82f6f2.c.txt)
[asn1_compiler-82f6f2.sh.txt](https://github.com/user-attachments/files/18495727/asn1_compiler-82f6f2.sh.txt)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs