Skip to content

Assertion `(IK == IK_FpInduction || Step->getType()->isIntegerTy()) && "StepValue is not an integer"' failed #1383

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

Closed
nathanchance opened this issue May 22, 2021 · 7 comments
Labels
[BUG] linux-next This is an issue only seen in linux-next [BUG] llvm A bug that should be fixed in upstream LLVM Compiler crash (assertions) This bug makes Clang crash when assertions are enabled, emitting a backtrace [FEATURE] PGO Related to building the kernel with LLVM Profile Guided Optimization [FIXED][LLVM] 13 This bug was fixed in LLVM 13.x Reported upstream This bug was filed on LLVM’s issue tracker, Phabricator, or the kernel mailing list.

Comments

@nathanchance
Copy link
Member

nathanchance commented May 22, 2021

After the PGO patch set was accepted, I see the following crash with x86_64 allmodconfig:

$ make -skj"$(nproc)" LLVM=1 LLVM_IAS=1 O=build/x86_64 distclean allmodconfig fs/gfs2/rgrp.o
clang: /home/nathan/cbl/github/tc-build/llvm-project/llvm/lib/Analysis/IVDescriptors.cpp:959: llvm::InductionDescriptor::InductionDescriptor(llvm::Value *, llvm::InductionDescriptor::InductionKind, const llvm::SCEV *, llvm::BinaryOperator *, SmallVectorImpl<llvm::Instruction *> *): Assertion `(IK == IK_FpInduction || Step->getType()->isIntegerTy()) && "StepValue is not an integer"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang -Qunused-arguments -fmacro-prefix-map=/home/nathan/cbl/src/linux-next/= -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu89 -Werror=unknown-warning-option -integrated-as -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -mno-80387 -mstack-alignment=8 -mtune=generic -mno-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -mretpoline-external-thunk -fno-delete-null-pointer-checks -Wno-frame-address -Wno-address-of-packed-member -O2 -Wframe-larger-than=2048 -fstack-protector-strong -Wno-format-invalid-specifier -Wno-gnu -mno-global-merge -Wno-unused-const-variable -ftrivial-auto-var-init=pattern -fno-stack-clash-protection -pg -mfentry -falign-functions=64 -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-array-bounds -fno-strict-overflow -fno-stack-check -Werror=date-time -Werror=incompatible-pointer-types -Wno-initializer-overrides -Wno-format -Wno-sign-compare -Wno-format-zero-length -Wno-pointer-to-enum-cast -Wno-tautological-constant-out-of-range-compare -fprofile-generate -fsanitize=kernel-address -mllvm -asan-mapping-offset=0xdffffc0000000000 -mllvm -asan-globals=1 -mllvm -asan-instrumentation-with-call-threshold=0 -mllvm -asan-stack=0 --param asan-instrument-allocas=1 -fsanitize=array-bounds -fsanitize=shift -fsanitize=integer-divide-by-zero -fsanitize=object-size -fsanitize=bool -fsanitize=enum -fsanitize-coverage=trace-pc -fsanitize-coverage=trace-cmp -nostdinc -isystem /home/nathan/cbl/github/tc-build/build/llvm/stage1/lib/clang/13.0.0/include -I/home/nathan/cbl/src/linux-next/arch/x86/include -I./arch/x86/include/generated -I/home/nathan/cbl/src/linux-next/include -I./include -I/home/nathan/cbl/src/linux-next/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/home/nathan/cbl/src/linux-next/include/uapi -I./include/generated/uapi -include /home/nathan/cbl/src/linux-next/include/linux/compiler-version.h -include /home/nathan/cbl/src/linux-next/include/linux/kconfig.h -include /home/nathan/cbl/src/linux-next/include/linux/compiler_types.h -D__KERNEL__ -DCONFIG_X86_X32_ABI -DCC_USING_NOP_MCOUNT -DCC_USING_FENTRY -Ifs/gfs2 -I /home/nathan/cbl/src/linux-next/fs/gfs2 -I ./fs/gfs2 -DMODULE -DKBUILD_BASENAME=\"rgrp\" -DKBUILD_MODNAME=\"gfs2\" -D__KBUILD_MODNAME=kmod_gfs2 -c -Wp,-MMD,fs/gfs2/.rgrp.o.d -fcolor-diagnostics -o fs/gfs2/rgrp.o /home/nathan/cbl/src/linux-next/fs/gfs2/rgrp.c
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '/home/nathan/cbl/src/linux-next/fs/gfs2/rgrp.c'.
4.	Running pass 'Loop Pass Manager' on function '@gfs2_rgrp_verify'
5.	Running pass 'Canonicalize Freeze Instructions in Loops' on basic block '%cont21'
 #0 0x0000000002a0e883 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x2a0e883)
 #1 0x0000000002a0c6ee llvm::sys::RunSignalHandlers() (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x2a0c6ee)
 #2 0x00000000029995a3 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) CrashRecoveryContext.cpp:0:0
 #3 0x00000000029996de CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x00007f012020c870 __restore_rt sigaction.c:0:0
 #5 0x00007f011fcc6d22 raise (/usr/lib/libc.so.6+0x3cd22)
 #6 0x00007f011fcb0862 abort (/usr/lib/libc.so.6+0x26862)
 #7 0x00007f011fcb0747 _nl_load_domain.cold loadmsgcat.c:0:0
 #8 0x00007f011fcbf616 (/usr/lib/libc.so.6+0x35616)
 #9 0x0000000001c832d6 llvm::InductionDescriptor::InductionDescriptor(llvm::Value*, llvm::InductionDescriptor::InductionKind, llvm::SCEV const*, llvm::BinaryOperator*, llvm::SmallVectorImpl<llvm::Instruction*>*) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x1c832d6)
#10 0x0000000001c84374 llvm::InductionDescriptor::isInductionPHI(llvm::PHINode*, llvm::Loop const*, llvm::ScalarEvolution*, llvm::InductionDescriptor&, llvm::SCEV const*, llvm::SmallVectorImpl<llvm::Instruction*>*) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x1c84374)
#11 0x0000000002a34cc4 (anonymous namespace)::CanonicalizeFreezeInLoopsImpl::run() CanonicalizeFreezeInLoops.cpp:0:0
#12 0x0000000002a35e4d (anonymous namespace)::CanonicalizeFreezeInLoops::runOnLoop(llvm::Loop*, llvm::LPPassManager&) CanonicalizeFreezeInLoops.cpp:0:0
#13 0x0000000001eb5a93 llvm::LPPassManager::runOnFunction(llvm::Function&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x1eb5a93)
#14 0x0000000002352868 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x2352868)
#15 0x000000000235adb1 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x235adb1)
#16 0x0000000002353331 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x2353331)
#17 0x00000000030e1c46 (anonymous namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) BackendUtil.cpp:0:0
#18 0x00000000030dc547 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> >) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x30dc547)
#19 0x0000000003570ff1 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) CodeGenAction.cpp:0:0
#20 0x0000000003ea8b14 clang::ParseAST(clang::Sema&, bool, bool) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x3ea8b14)
#21 0x00000000034c65d0 clang::FrontendAction::Execute() (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x34c65d0)
#22 0x000000000343adbf clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x343adbf)
#23 0x000000000356aec7 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x356aec7)
#24 0x000000000186f4f1 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x186f4f1)
#25 0x000000000186cf3d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#26 0x00000000032dede2 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const::$_1>(long) Job.cpp:0:0
#27 0x00000000029994b7 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x29994b7)
#28 0x00000000032de947 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x32de947)
#29 0x00000000032a68a8 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x32a68a8)
#30 0x00000000032a6ba7 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x32a6ba7)
#31 0x00000000032bf621 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x32bf621)
#32 0x000000000186c806 main (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x186c806)
#33 0x00007f011fcb1b25 __libc_start_main (/usr/lib/libc.so.6+0x27b25)
#34 0x0000000001869b8e _start (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x1869b8e)
clang-13: error: clang frontend command failed with exit code 134 (use -v to see invocation)
ClangBuiltLinux clang version 13.0.0 (https://github.com/llvm/llvm-project f50b87e9ef42efe80e2b3364df848d102075dd11)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/nathan/cbl/github/tc-build/build/llvm/stage1/bin
clang-13: note: diagnostic msg: 
********************

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

********************
make[4]: *** [/home/nathan/cbl/src/linux-next/scripts/Makefile.build:273: fs/gfs2/rgrp.o] Error 134
make[4]: Target '__build' not remade because of errors.
make[3]: *** [/home/nathan/cbl/src/linux-next/scripts/Makefile.build:534: fs/gfs2] Error 2
make[3]: Target '__build' not remade because of errors.
make[2]: *** [/home/nathan/cbl/src/linux-next/Makefile:1954: fs] Error 2
make[2]: Target 'fs/gfs2/rgrp.o' not remade because of errors.
make[1]: *** [/home/nathan/cbl/src/linux-next/Makefile:353: __build_one_by_one] Error 2
make[1]: Target 'distclean' not remade because of errors.
make[1]: Target 'allmodconfig' not remade because of errors.
make[1]: Target 'fs/gfs2/rgrp.o' not remade because of errors.
make: *** [Makefile:222: __sub-make] Error 2
make: Target 'distclean' not remade because of errors.
make: Target 'allmodconfig' not remade because of errors.
make: Target 'fs/gfs2/rgrp.o' not remade because of errors.

cvise spits out:

$ cat rgrp.i
gfs2_rgrp_verify_rgd_0;
struct gfs2_bitmap *gfs2_rgrp_verify_bi;
struct gfs2_bitmap {
  int bi_bytes
} gfs2_bitcount(char *buffer, int buflen) {
  char *end = buffer + buflen;
  for (; buffer < end; buffer++)
    ;
}
gfs2_rgrp_verify() {
  for (; gfs2_rgrp_verify_rgd_0;)
    gfs2_bitcount(gfs2_rgrp_verify_bi, gfs2_rgrp_verify_bi->bi_bytes);
}
$ clang -fprofile-generate -fsanitize=object-size -mno-sse -O2 -c -o /dev/null rgrp.i
rgrp.i:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
gfs2_rgrp_verify_rgd_0;
^
rgrp.i:4:15: warning: expected ';' at end of declaration list
  int bi_bytes
              ^
              ;
rgrp.i:9:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
rgrp.i:10:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
gfs2_rgrp_verify() {
^
rgrp.i:12:19: warning: incompatible pointer types passing 'struct gfs2_bitmap *' to parameter of type 'char *' [-Wincompatible-pointer-types]
    gfs2_bitcount(gfs2_rgrp_verify_bi, gfs2_rgrp_verify_bi->bi_bytes);
                  ^~~~~~~~~~~~~~~~~~~
rgrp.i:5:23: note: passing argument to parameter 'buffer' here
} gfs2_bitcount(char *buffer, int buflen) {
                      ^
rgrp.i:13:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
clang: /home/nathan/cbl/github/tc-build/llvm-project/llvm/lib/Analysis/IVDescriptors.cpp:959: llvm::InductionDescriptor::InductionDescriptor(llvm::Value *, llvm::InductionDescriptor::InductionKind, const llvm::SCEV *, llvm::BinaryOperator *, SmallVectorImpl<llvm::Instruction *> *): Assertion `(IK == IK_FpInduction || Step->getType()->isIntegerTy()) && "StepValue is not an integer"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: clang -fprofile-generate -fsanitize=object-size -mno-sse -O2 -c -o /dev/null rgrp.i
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'rgrp.i'.
4.	Running pass 'Loop Pass Manager' on function '@gfs2_rgrp_verify'
5.	Running pass 'Canonicalize Freeze Instructions in Loops' on basic block '%for.body'
 #0 0x0000000002a0e883 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x2a0e883)
 #1 0x0000000002a0c6ee llvm::sys::RunSignalHandlers() (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x2a0c6ee)
 #2 0x00000000029995a3 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) CrashRecoveryContext.cpp:0:0
 #3 0x00000000029996de CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x00007f804b63b870 __restore_rt sigaction.c:0:0
 #5 0x00007f804b0f5d22 raise (/usr/lib/libc.so.6+0x3cd22)
 #6 0x00007f804b0df862 abort (/usr/lib/libc.so.6+0x26862)
 #7 0x00007f804b0df747 _nl_load_domain.cold loadmsgcat.c:0:0
 #8 0x00007f804b0ee616 (/usr/lib/libc.so.6+0x35616)
 #9 0x0000000001c832d6 llvm::InductionDescriptor::InductionDescriptor(llvm::Value*, llvm::InductionDescriptor::InductionKind, llvm::SCEV const*, llvm::BinaryOperator*, llvm::SmallVectorImpl<llvm::Instruction*>*) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x1c832d6)
#10 0x0000000001c84374 llvm::InductionDescriptor::isInductionPHI(llvm::PHINode*, llvm::Loop const*, llvm::ScalarEvolution*, llvm::InductionDescriptor&, llvm::SCEV const*, llvm::SmallVectorImpl<llvm::Instruction*>*) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x1c84374)
#11 0x0000000002a34cc4 (anonymous namespace)::CanonicalizeFreezeInLoopsImpl::run() CanonicalizeFreezeInLoops.cpp:0:0
#12 0x0000000002a35e4d (anonymous namespace)::CanonicalizeFreezeInLoops::runOnLoop(llvm::Loop*, llvm::LPPassManager&) CanonicalizeFreezeInLoops.cpp:0:0
#13 0x0000000001eb5a93 llvm::LPPassManager::runOnFunction(llvm::Function&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x1eb5a93)
#14 0x0000000002352868 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x2352868)
#15 0x000000000235adb1 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x235adb1)
#16 0x0000000002353331 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x2353331)
#17 0x00000000030e1c46 (anonymous namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) BackendUtil.cpp:0:0
#18 0x00000000030dc547 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> >) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x30dc547)
#19 0x0000000003570ff1 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) CodeGenAction.cpp:0:0
#20 0x0000000003ea8b14 clang::ParseAST(clang::Sema&, bool, bool) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x3ea8b14)
#21 0x00000000034c65d0 clang::FrontendAction::Execute() (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x34c65d0)
#22 0x000000000343adbf clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x343adbf)
#23 0x000000000356aec7 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x356aec7)
#24 0x000000000186f4f1 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x186f4f1)
#25 0x000000000186cf3d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#26 0x00000000032dede2 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const::$_1>(long) Job.cpp:0:0
#27 0x00000000029994b7 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x29994b7)
#28 0x00000000032de947 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x32de947)
#29 0x00000000032a68a8 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x32a68a8)
#30 0x00000000032a6ba7 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x32a6ba7)
#31 0x00000000032bf621 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x32bf621)
#32 0x000000000186c806 main (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x186c806)
#33 0x00007f804b0e0b25 __libc_start_main (/usr/lib/libc.so.6+0x27b25)
#34 0x0000000001869b8e _start (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x1869b8e)
clang-13: error: clang frontend command failed with exit code 134 (use -v to see invocation)
ClangBuiltLinux clang version 13.0.0 (https://github.com/llvm/llvm-project f50b87e9ef42efe80e2b3364df848d102075dd11)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/nathan/cbl/github/tc-build/build/llvm/stage1/bin
clang-13: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.
$ clang -fsanitize=object-size -mno-sse -O2 -c -o /dev/null rgrp.i
rgrp.i:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
gfs2_rgrp_verify_rgd_0;
^
rgrp.i:4:15: warning: expected ';' at end of declaration list
  int bi_bytes
              ^
              ;
rgrp.i:9:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
rgrp.i:10:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
gfs2_rgrp_verify() {
^
rgrp.i:12:19: warning: incompatible pointer types passing 'struct gfs2_bitmap *' to parameter of type 'char *' [-Wincompatible-pointer-types]
    gfs2_bitcount(gfs2_rgrp_verify_bi, gfs2_rgrp_verify_bi->bi_bytes);
                  ^~~~~~~~~~~~~~~~~~~
rgrp.i:5:23: note: passing argument to parameter 'buffer' here
} gfs2_bitcount(char *buffer, int buflen) {
                      ^
rgrp.i:13:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
6 warnings generated.

My bisect landed on llvm/llvm-project@54b6457 but that seems obvious since the pass was not present before that commit.

Reported on the upstream LLVM issue tracker: https://llvm.org/pr50440

cc @gwelymernans

@nathanchance nathanchance added [BUG] llvm A bug that should be fixed in upstream LLVM Reported upstream This bug was filed on LLVM’s issue tracker, Phabricator, or the kernel mailing list. Compiler crash (assertions) This bug makes Clang crash when assertions are enabled, emitting a backtrace labels May 22, 2021
@nathanchance nathanchance added the [FEATURE] PGO Related to building the kernel with LLVM Profile Guided Optimization label Jun 1, 2021
@nickdesaulniers nickdesaulniers added the [BUG] linux-next This is an issue only seen in linux-next label Jun 3, 2021
@nickdesaulniers
Copy link
Member

nickdesaulniers commented Jun 3, 2021

revert requested in https://llvm.org/pr50573

@nickdesaulniers
Copy link
Member

Eli has 2 patches up for review that fix this:
https://reviews.llvm.org/D103656
https://reviews.llvm.org/D103660

@nickdesaulniers nickdesaulniers added the [PATCH] Submitted A patch has been submitted for review label Jun 4, 2021
@nickdesaulniers
Copy link
Member

nickdesaulniers commented Jun 4, 2021

Since 54b64572407c8305c7bb8cc20c46a5e0c66b2979 first landed in release/11.x, I'm inclined to send a kernel patch that disables CONFIG_GFS2_FS if CONFIG_PGO_CLANG=y and CLANG_VERSION < 13.

Perhaps something like:

diff --git a/fs/gfs2/Kconfig b/fs/gfs2/Kconfig
index 03c966840422..7d8b936291c8 100644
--- a/fs/gfs2/Kconfig
+++ b/fs/gfs2/Kconfig
@@ -28,6 +28,8 @@ config GFS2_FS_LOCKING_DLM
        bool "GFS2 DLM locking"
        depends on (GFS2_FS!=n) && NET && INET && (IPV6 || IPV6=n) && \
                CONFIGFS_FS && SYSFS && (DLM=y || DLM=GFS2_FS)
+       # https://llvm.org/pr50440
+       depends on CC_IS_CLANG=n || (PGO_CLANG=n && CLANG_VERSION >= 130000)
        help
          Multiple node locking module for GFS2

once fixes land upstream.

@nathanchance
Copy link
Member Author

I really do not like that diff for some reason. It feels like a hack to turn off a whole filesystem because of a bug in the compiler but I understand that it is the hand we are dealt. Even then, it should probably be something more like:

depends on !CC_IS_CLANG || (CC_IS_CLANG && !PGO_CLANG) || (PGO_CLANG && CLANG_VERSION >= 130000)

I would personally rather CONFIG_PGO_CLANG be updated to require LLVM 13 if we cannot fix this in time for the 12.0.1 release (the comments on D103660 cast some uncertainty around that), especially since that will give us time to make sure the issue is properly fixed and fuzz CONFIG_PGO_CLANG some more in case we find more bugs that need to be fixed on the compiler side.

Open to discussion around that though once we have an acceptable fix on the compiler side.

@nickdesaulniers
Copy link
Member

We could also have pgo depend on !GFS2_FS || CLANG_VERSION >= 130000, though I think that would disable PGO for allmodconfig builds (though I haven't tried/checked that)

@nathanchance
Copy link
Member Author

diff --git a/kernel/pgo/Kconfig b/kernel/pgo/Kconfig
index d2053df1111c..65efc3fcf554 100644
--- a/kernel/pgo/Kconfig
+++ b/kernel/pgo/Kconfig
@@ -8,7 +8,8 @@ config PGO_CLANG
        bool "Enable clang's PGO-based kernel profiling"
        depends on DEBUG_FS
        depends on ARCH_SUPPORTS_PGO_CLANG
-       depends on CC_IS_CLANG && CLANG_VERSION >= 120000
+       depends on CC_IS_CLANG
+       depends on (CLANG_VERSION >= 120000 && GFS2_FS=n) || (CLANG_VERSION >= 130000)
        help
          This option enables clang's PGO (Profile Guided Optimization) based
          code profiling to better optimize the kernel.

appears to work.

$ clang --version | head -1
ClangBuiltLinux clang version 12.0.0 (https://github.com/llvm/llvm-project d28af7c654d8db0b68c175db5ce212d74fb5e9bc)

$ make -skj"$(nproc)" LLVM=1 LLVM_IAS=1 O=build/x86_64 distclean allmodconfig

$ rg "GFS2|PGO_CLANG" build/x86_64/.config
931:CONFIG_ARCH_SUPPORTS_PGO_CLANG=y
13166:CONFIG_GFS2_FS=m
13167:CONFIG_GFS2_FS_LOCKING_DLM=y
$ clang --version
ClangBuiltLinux clang version 13.0.0 (https://github.com/llvm/llvm-project dc1e7b73b81811b74a4fbde4c5cfab5a3ea7f820)

$ make -skj"$(nproc)" LLVM=1 LLVM_IAS=1 O=build/x86_64 distclean allmodconfig

$ rg "GFS2|PGO_CLANG" build/x86_64/.config
931:CONFIG_ARCH_SUPPORTS_PGO_CLANG=y
932:CONFIG_PGO_CLANG=y
13167:CONFIG_GFS2_FS=m
13168:CONFIG_GFS2_FS_LOCKING_DLM=y

though I think that would disable PGO for allmodconfig builds

Correct, although I think that is fair, nobody is going to run an allmodconfig build so if they want to run CONFIG_PGO_CLANG, they can see the dependencies.

@nathanchance
Copy link
Member Author

llvm/llvm-project@8a567e5 fixed this. PGO is now gated on LLVM 13.0.0 so we do not need to worry about backporting this to LLVM 12.0.0 because there were a few prerequisite patches.

@nathanchance nathanchance added [FIXED][LLVM] 13 This bug was fixed in LLVM 13.x and removed [PATCH] Submitted A patch has been submitted for review labels Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[BUG] linux-next This is an issue only seen in linux-next [BUG] llvm A bug that should be fixed in upstream LLVM Compiler crash (assertions) This bug makes Clang crash when assertions are enabled, emitting a backtrace [FEATURE] PGO Related to building the kernel with LLVM Profile Guided Optimization [FIXED][LLVM] 13 This bug was fixed in LLVM 13.x Reported upstream This bug was filed on LLVM’s issue tracker, Phabricator, or the kernel mailing list.
Projects
None yet
Development

No branches or pull requests

2 participants