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

Clang Full LTO broken on Linux 5.14.6 with LLVM/Clang 14-git 84b07c9b #1460

Closed
ms178 opened this issue Sep 20, 2021 · 18 comments
Closed

Clang Full LTO broken on Linux 5.14.6 with LLVM/Clang 14-git 84b07c9b #1460

ms178 opened this issue Sep 20, 2021 · 18 comments
Labels
[ARCH] x86_64 This bug impacts ARCH=x86_64 [BUG] llvm (main) A bug in an unreleased version of LLVM (this label is appropriate for regressions) Extra flags The use of additional, non-standard CFLAGS causes this issue [FEATURE] LTO Related to building the kernel with LLVM Link Time Optimization [FIXED][LLVM] 14 This bug was fixed in LLVM 14.x

Comments

@ms178
Copy link

ms178 commented Sep 20, 2021

Hi,

with the attached config and Makefile, I can no longer successfully compile the Linux-Xanmod Kernel 5.14.6 with Full LTO - this is a recent regression, it used to work with 5.14.5 and a LLVM/Clang 14 build one week older than the one mentioned in the title.

The issue occurs when building the modules.

Makefile.txt
config.txt

This is the output I get:

Cannot take the address of an inline asm!
store i32 (i32)* asm "# ALT: oldnstr\0A661:\0A\09call __sw_hweight32\0A662:\0A# ALT: padding\0A.skip -(((6651f-6641f)-(662b-661b)) > 0) * ((6651f-6641f)-(662b-661b)),0x90\0A663:\0A.pushsection .altinstructions,\22a\22\0A .long 661b - .\0A .long 6641f - .\0A .word ( 4*32+23)\0A .byte 663b-661b\0A .byte 6651f-6641f\0A.popsection\0A.pushsection .altinstr_replacement, \22ax\22\0A# ALT: replacement 1\0A6641:\0A\09popcntl $1, $0\0A6651:\0A.popsection\0A", "={ax},{di},{dirflag},{fpsr},~{flags}", i32 (i32)** LTO [M] drivers/input/mouse/elan_i2c.lto.o

%36, align 8

LLVM ERROR: Broken module found, compilation aborted!
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:

  1.  Program arguments: ld.lld -m elf_x86_64 -mllvm -import-instr-limit=5 -r -o drivers/gpu/drm/amd/amdgpu/amdgpu.lto.o --whole-archive drivers/gpu/drm/amd/amdgpu/amdgpu.o
    
#0 0x00007f19ec0d62e3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/bin/../lib/libLLVM-14.so+0x1b7c2e3)
#1 0x00007f19ec0d33f0 llvm::sys::RunSignalHandlers() (/usr/bin/../lib/libLLVM-14.so+0x1b793f0)
#2 0x00007f19ec0d5cca (/usr/bin/../lib/libLLVM-14.so+0x1b7bcca)
#3 0x00007f19ea336870 __restore_rt sigaction.c:0:0
#4 0x00007f19ea193d22 raise (/usr/bin/../lib/libc.so.6+0x3cd22)
#5 0x00007f19ea17d862 abort (/usr/bin/../lib/libc.so.6+0x26862)
#6 0x00007f19ebfe92de (/usr/bin/../lib/libLLVM-14.so+0x1a8f2de)
#7 0x00007f19ebfe9106 (/usr/bin/../lib/libLLVM-14.so+0x1a8f106)
#8 0x00007f19edab8c4d (/usr/bin/../lib/libLLVM-14.so+0x355ec4d)
#9 0x00007f19ec2a1b70 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/usr/bin/../lib/libLLVM-14.so+0x1d47b70)
#10 0x00007f19edab66f0 llvm::lto::opt(llvm::lto::Config const&, llvm::TargetMachine*, unsigned int, llvm::Module&, bool, llvm::ModuleSummaryIndex*, llvm::ModuleSummaryIndex const*, std::vector<unsigned char, std::allocator<unsigned char> > const&) (/usr/bin/../lib/libLLVM-14.so+0x355c6f0)
#11 0x00007f19edab9269 llvm::lto::backend(llvm::lto::Config const&, std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex&) (/usr/bin/../lib/libLLVM-14.so+0x355f269)
#12 0x00007f19edaaaf24 llvm::lto::LTO::runRegularLTO(std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)>) (/usr/bin/../lib/libLLVM-14.so+0x3550f24)
#13 0x00007f19edaaa5ad llvm::lto::LTO::run(std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)>, std::function<std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)> (unsigned int, llvm::StringRef)>) (/usr/bin/../lib/libLLVM-14.so+0x35505ad)
#14 0x000000000054812a lld::elf::BitcodeCompiler::compile() (/usr/bin/lld+0x54812a)
#15 0x00000000004baee6 void lld::elf::LinkerDriver::compileBitcodeFiles<llvm::object::ELFType<(llvm::support::endianness)1, true> >() (/usr/bin/lld+0x4baee6)
#16 0x00000000004a7ef4 void lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::support::endianness)1, true> >(llvm::opt::InputArgList&) (/usr/bin/lld+0x4a7ef4)
#17 0x0000000000492d32 lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) (/usr/bin/lld+0x492d32)
#18 0x000000000048fe89 lld::elf::link(llvm::ArrayRef<char const*>, bool, llvm::raw_ostream&, llvm::raw_ostream&) (/usr/bin/lld+0x48fe89)
#19 0x00000000003ac6a0 (/usr/bin/lld+0x3ac6a0)
#20 0x00000000003acdca main (/usr/bin/lld+0x3acdca)
#21 0x00007f19ea17eb25 __libc_start_main (/usr/bin/../lib/libc.so.6+0x27b25)
#22 0x00000000003aba6e _start (/usr/bin/lld+0x3aba6e)

P.S: I also get the following two stack frame size issues with that build:

ld.lld: warning: stack frame size (1288) exceeds limit (1024) in function 'HUF_readCTable'
ld.lld: warning: stack frame size (1080) exceeds limit (1024) in function 'rtnl_newlink'

@nickdesaulniers nickdesaulniers added [BUG] llvm (main) A bug in an unreleased version of LLVM (this label is appropriate for regressions) [FEATURE] LTO Related to building the kernel with LLVM Link Time Optimization [ARCH] x86_64 This bug impacts ARCH=x86_64 labels Sep 20, 2021
@nickdesaulniers
Copy link
Member

Can you provide the current LLVM SHA that's known bad, and the prior known good version? That should give us a regression window that might be highly relevant to minimize the time spent bisecting, and get something reverted upstream. You should be able to use git reflog to see your prior sha before a git pull.

@nathanchance
Copy link
Member

Alright, I spent a ton of time yesterday trying to bisect LLVM until I came to the conclusion that this appears to be something that has been latent but only got recently exposed by a commit going into stable, as I attempted to bisect LLVM and could reproduce the issue back to July (so your update is not much of a factor I believe). It might be helpful in the future on the initial report to isolate which update truly caused the issue.

For the record, these are the changed flags:

diff --git a/Makefile b/Makefile
index f9c8bbf8cf71..f68b9602ceaf 100644
--- a/Makefile
+++ b/Makefile
@@ -433,13 +433,13 @@ HOSTCXX   = g++
 endif

 export KBUILD_USERCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
-                             -O2 -fomit-frame-pointer -std=gnu89
-export KBUILD_USERLDFLAGS :=
+                             -O3 -march=native -mtune=native -mllvm -polly -mllvm -polly-parallel -fopenmp -mllvm -polly-vectorizer=stripmine -mllvm -polly-omp-backend=LLVM -mllvm -polly-num-threads=24 -mllvm -polly-scheduling=dynamic -mllvm -polly-scheduling-chunksize=1 -mllvm -polly-ast-use-context -mllvm -polly-invariant-load-hoisting -mllvm -polly-opt-fusion=max -mllvm -polly-run-inliner -mllvm -polly-run-dce -fno-math-errno -fno-trapping-math -falign-functions=32 -fno-semantic-interposition -std=gnu2x
+export KBUILD_USERLDFLAGS := -Wl,-O3 -Wl,--as-needed -Wl,-Bsymbolic-functions

 KBUILD_HOSTCFLAGS   := $(KBUILD_USERCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
-KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
-KBUILD_HOSTLDFLAGS  := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
-KBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
+KBUILD_HOSTCXXFLAGS := -O3 -march=native -mtune=native -mllvm -polly -mllvm -polly-parallel -fopenmp -mllvm -polly-vectorizer=stripmine -mllvm -polly-omp-backend=LLVM -mllvm -polly-num-threads=24 -mllvm -polly-scheduling=dynamic -mllvm -polly-scheduling-chunksize=1 -mllvm -polly-ast-use-context -mllvm -polly-invariant-load-hoisting -mllvm -polly-opt-fusion=max -mllvm -polly-run-inliner -mllvm -polly-run-dce -fno-math-errno -fno-trapping-math -falign-functions=32 -fno-semantic-interposition $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
+KBUILD_HOSTLDFLAGS  := -Wl,-O3 -Wl,--as-needed -Wl,-Bsymbolic-functions $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
+KBUILD_HOSTLDLIBS   := -Wl,-O3 -Wl,--as-needed -Wl,-Bsymbolic-functions $(HOST_LFS_LIBS) $(HOSTLDLIBS)

 # Make variables (CC, etc...)
 CPP            = $(CC) -E
@@ -484,10 +484,10 @@ ZSTD              = zstd
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
                  -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
 NOSTDINC_FLAGS :=
-CFLAGS_MODULE   =
+CFLAGS_MODULE   = -O3 -march=native -mtune=native -mllvm -polly -mllvm -polly-parallel -fopenmp -mllvm -polly-vectorizer=stripmine -mllvm -polly-omp-backend=LLVM -mllvm -polly-num-threads=24 -mllvm -polly-scheduling=dynamic -mllvm -polly-scheduling-chunksize=1 -mllvm -polly-ast-use-context -mllvm -polly-invariant-load-hoisting -mllvm -polly-opt-fusion=max -mllvm -polly-run-inliner -mllvm -polly-run-dce -fno-math-errno -fno-trapping-math -falign-functions=32 -fno-semantic-interposition
 AFLAGS_MODULE   =
 LDFLAGS_MODULE  =
-CFLAGS_KERNEL  =
+CFLAGS_KERNEL  = -march=native -mtune=native -mllvm -polly -mllvm -polly-parallel -fopenmp -mllvm -polly-vectorizer=stripmine -mllvm -polly-omp-backend=LLVM -mllvm -polly-num-threads=24 -mllvm -polly-scheduling=dynamic -mllvm -polly-scheduling-chunksize=1 -mllvm -polly-ast-use-context -mllvm -polly-invariant-load-hoisting -mllvm -polly-opt-fusion=max -mllvm -polly-run-inliner -mllvm -polly-run-dce -fno-math-errno -fno-trapping-math -falign-functions=32 -fno-semantic-interposition
 AFLAGS_KERNEL  =
 LDFLAGS_vmlinux =

@@ -766,6 +766,7 @@ ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
 KBUILD_CFLAGS += -O2
 else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3
 KBUILD_CFLAGS += -O3
+KBUILD_CFLAGS += $(call cc-option, -fno-tree-loop-vectorize)
 else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
 KBUILD_CFLAGS += -Os
 endif

They are necessary for reproducing this issue, I do not see this issue without them.

cvise spits out:

$ cat kfd_mqd_manager.i
struct {
  int num_shader_arrays_per_engine;
  int cu_bitmap[]
} mqd_symmetrically_map_cu_mask_cu_info;
mqd_symmetrically_map_cu_mask_cu_info_1,
    mqd_symmetrically_map_cu_mask_cu_info_0, mqd_symmetrically_map_cu_mask_se,
    mqd_symmetrically_map_cu_mask_sh;
mqd_symmetrically_map_cu_mask_cu_per_sh[];
mqd_symmetrically_map_cu_mask_cu() {
  mqd_symmetrically_map_cu_mask_se = 0;
  for (; mqd_symmetrically_map_cu_mask_se <
         mqd_symmetrically_map_cu_mask_cu_info_0;
       mqd_symmetrically_map_cu_mask_se++) {
    mqd_symmetrically_map_cu_mask_sh = 0;
    for (; mqd_symmetrically_map_cu_mask_sh <
           mqd_symmetrically_map_cu_mask_cu_info_1;
         mqd_symmetrically_map_cu_mask_sh++) {
      int res;
      asm("664"
          ":\n"
          : "="
            "a"(res)
          : "D"(mqd_symmetrically_map_cu_mask_cu_info
                    .cu_bitmap[mqd_symmetrically_map_cu_mask_sh]));
      mqd_symmetrically_map_cu_mask_cu_per_sh
          [mqd_symmetrically_map_cu_mask_se +
           mqd_symmetrically_map_cu_mask_sh] = res;
    }
  }
}

$ clang -O2 -flto -mllvm -polly -mllvm -polly-parallel -c -o kfd_mqd_manager.o kfd_mqd_manager.i
...

$ llvm-ar cDPrsT amdgpu.o kfd_mqd_manager.o

$ ld.lld -m elf_x86_64 -mllvm -import-instr-limit=5 -r -o amdgpu.lto.o --whole-archive amdgpu.o
Cannot take the address of an inline asm!
  store i32 (i32)* asm "664:\0A", "={ax},{di},~{dirflag},~{fpsr},~{flags}", i32 (i32)** %14, align 8
LLVM ERROR: Broken module found, compilation aborted!
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.      Program arguments: ld.lld -m elf_x86_64 -mllvm -import-instr-limit=5 -r -o amdgpu.lto.o --whole-archive amdgpu.o
 #0 0x0000000001736673 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/ld.lld+0x1736673)
 #1 0x000000000173442e llvm::sys::RunSignalHandlers() (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/ld.lld+0x173442e)
 #2 0x0000000001736c8a SignalHandler(int) Signals.cpp:0:0
 #3 0x00007fe611417870 __restore_rt sigaction.c:0:0
 #4 0x00007fe610d63d22 raise (/usr/lib/libc.so.6+0x3cd22)
 #5 0x00007fe610d4d862 abort (/usr/lib/libc.so.6+0x26862)
 #6 0x00000000016a89f9 (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/ld.lld+0x16a89f9)
 #7 0x00000000016a8816 (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/ld.lld+0x16a8816)
 #8 0x0000000003cd2b56 (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/ld.lld+0x3cd2b56)
 #9 0x0000000002370c4d llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) LTOBackend.cpp:0:0
#10 0x0000000003ca4664 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/ld.lld+0x3ca4664)
#11 0x000000000236ad5d llvm::lto::opt(llvm::lto::Config const&, llvm::TargetMachine*, unsigned int, llvm::Module&, bool, llvm::ModuleSummaryIndex*, llvm::ModuleSummaryIndex const*, std::vector<unsigned char, std::allocator<unsigned char> > const&) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/ld.lld+0x236ad5d)
#12 0x000000000236b5c1 llvm::lto::backend(llvm::lto::Config const&, std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex&) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/ld.lld+0x236b5c1)
#13 0x000000000235d466 llvm::lto::LTO::runRegularLTO(std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)>) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/ld.lld+0x235d466)
#14 0x000000000235cb32 llvm::lto::LTO::run(std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)>, std::function<std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)> (unsigned int, llvm::StringRef)>) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/ld.lld+0x235cb32)
#15 0x00000000018dac36 lld::elf::BitcodeCompiler::compile() (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/ld.lld+0x18dac36)
#16 0x0000000001838796 void lld::elf::LinkerDriver::compileBitcodeFiles<llvm::object::ELFType<(llvm::support::endianness)1, true> >() (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/ld.lld+0x1838796)
#17 0x0000000001820fe5 void lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::support::endianness)1, true> >(llvm::opt::InputArgList&) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/ld.lld+0x1820fe5)
#18 0x0000000001812629 lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/ld.lld+0x1812629)
#19 0x0000000001810064 lld::elf::link(llvm::ArrayRef<char const*>, bool, llvm::raw_ostream&, llvm::raw_ostream&) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/ld.lld+0x1810064)
#20 0x000000000168a77f lldMain(int, char const**, llvm::raw_ostream&, llvm::raw_ostream&, bool) lld.cpp:0:0
#21 0x000000000168a06d main (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/ld.lld+0x168a06d)
#22 0x00007fe610d4eb25 __libc_start_main (/usr/lib/libc.so.6+0x27b25)
#23 0x0000000001689d5e _start (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/ld.lld+0x1689d5e)

It does appear that LTO is not strictly necessary to reproduce an issue:

$ clang -O2 -mllvm -polly -mllvm -polly-parallel -c -o /dev/null kfd_mqd_manager.i
Cannot take the address of an inline asm!
  store i32 (i32)* asm "664:\0A", "={ax},{di},~{dirflag},~{fpsr},~{flags}", i32 (i32)** %polly.subfn.storeaddr.21, align 8
in function mqd_symmetrically_map_cu_mask_cu
fatal error: error in backend: Broken function found, compilation aborted!
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 -O2 -mllvm -polly -mllvm -polly-parallel -c -o /dev/null kfd_mqd_manager.i
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'kfd_mqd_manager.i'.
4.      Running pass 'Module Verifier' on function '@mqd_symmetrically_map_cu_mask_cu'
 #0 0x0000000002cb92d3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x2cb92d3)
 #1 0x0000000002cb70fe llvm::sys::RunSignalHandlers() (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x2cb70fe)
 #2 0x0000000002c401e3 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) CrashRecoveryContext.cpp:0:0
 #3 0x0000000002c4015f llvm::CrashRecoveryContext::HandleExit(int) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x2c4015f)
 #4 0x0000000002cb3717 llvm::sys::Process::Exit(int, bool) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x2cb3717)
 #5 0x00000000019e4720 llvm::DenseMapBase<llvm::DenseMap<llvm::AliasSetTracker::ASTCallbackVH, llvm::AliasSet::PointerRec*, llvm::AliasSetTracker::ASTCallbackVHDenseMapInfo, llvm::detail::DenseMapPair<llvm::AliasSetTracker::ASTCallbackVH, llvm::AliasSet::PointerRec*> >, llvm::AliasSetTracker::ASTCallbackVH, llvm::AliasSet::PointerRec*, llvm::AliasSetTracker::ASTCallbackVHDenseMapInfo, llvm::detail::DenseMapPair<llvm::AliasSetTracker::ASTCallbackVH, llvm::AliasSet::PointerRec*> >::destroyAll() cc1_main.cpp:0:0
 #6 0x0000000002c44dd2 llvm::report_fatal_error(llvm::Twine const&, bool) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x2c44dd2)
 #7 0x0000000002c44ca6 (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x2c44ca6)
 #8 0x00000000025a001f (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x25a001f)
 #9 0x000000000251a6d8 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x251a6d8)
#10 0x0000000002522ac1 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x2522ac1)
#11 0x000000000251b1d1 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x251b1d1)
#12 0x00000000033cbf2c (anonymous namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) BackendUtil.cpp:0:0
#13 0x00000000033c6707 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/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x33c6707)
#14 0x00000000037f6b10 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) CodeGenAction.cpp:0:0
#15 0x00000000041506f4 clang::ParseAST(clang::Sema&, bool, bool) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x41506f4)
#16 0x0000000003744600 clang::FrontendAction::Execute() (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x3744600)
#17 0x00000000036bd24f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x36bd24f)
#18 0x00000000037f05f7 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x37f05f7)
#19 0x00000000019e43fb cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x19e43fb)
#20 0x00000000019e1f5d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#21 0x00000000035549d2 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
#22 0x0000000002c400f7 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x2c400f7)
#23 0x0000000003554537 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/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x3554537)
#24 0x000000000351c968 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x351c968)
#25 0x000000000351cc37 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x351cc37)
#26 0x0000000003535141 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x3535141)
#27 0x00000000019e1841 main (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x19e1841)
#28 0x00007f62daea1b25 __libc_start_main (/usr/lib/libc.so.6+0x27b25)
#29 0x00000000019ded8e _start (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x19ded8e)
clang-14: error: clang frontend command failed with exit code 70 (use -v to see invocation)
ClangBuiltLinux clang version 14.0.0 (https://github.com/llvm/llvm-project 85b4b21c8bbad346d58a30154d2767c39cf3285a)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin
clang-14: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.

I was only able to reproduce the initial issue with an LLVM build without assertions. If I enable assertions, it fails much earlier:

clang: /home/nathan/cbl/github/tc-build/llvm-project/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp:1112: llvm::BasicBlock *SplitBlockPredecessorsImpl(llvm::BasicBlock *, ArrayRef<llvm::BasicBlock *>, const char *, llvm::DomTreeUpdater *, llvm::DominatorTree *, llvm::LoopInfo *, llvm::MemorySSAUpdater *, bool): Assertion `!isa<CallBrInst>(Preds[i]->getTerminator()) && "Cannot split an edge from a CallBrInst"' 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=./= -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 -integrated-as -Werror=unknown-warning-option -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -falign-loops=1 -mno-80387 -mstack-alignment=8 -mtune=generic -mno-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-address-of-packed-member -O2 -Wframe-larger-than=1024 -fno-stack-protector -Wno-format-invalid-specifier -Wno-gnu -mno-global-merge -Wno-unused-but-set-variable -Wno-unused-const-variable -fomit-frame-pointer -fno-stack-clash-protection -fno-lto -flto -fvisibility=hidden -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 -O3 -march=native -mtune=native -mllvm -polly -mllvm -polly-parallel -fopenmp -mllvm -polly-vectorizer=stripmine -mllvm -polly-omp-backend=LLVM -mllvm -polly-num-threads=24 -mllvm -polly-scheduling=dynamic -mllvm -polly-scheduling-chunksize=1 -mllvm -polly-ast-use-context -mllvm -polly-invariant-load-hoisting -mllvm -polly-opt-fusion=max -mllvm -polly-run-inliner -mllvm -polly-run-dce -fno-math-errno -fno-trapping-math -falign-functions=32 -fno-semantic-interposition -nostdinc -isystem /home/nathan/cbl/github/tc-build/build/llvm/stage1/lib/clang/14.0.0/include -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__ -DMODULE -DKBUILD_BASENAME=\"simple_card_utils\" -DKBUILD_MODNAME=\"snd_soc_simple_card_utils\" -D__KBUILD_MODNAME=kmod_snd_soc_simple_card_utils -c -Wp,-MMD,sound/soc/generic/.simple-card-utils.o.d -fcolor-diagnostics -o sound/soc/generic/simple-card-utils.o sound/soc/generic/simple-card-utils.c
1.	<eof> parser at end of file
2.	Optimizer
 #0 0x0000000002cb3273 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x2cb3273)
 #1 0x0000000002cb109e llvm::sys::RunSignalHandlers() (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x2cb109e)
 #2 0x0000000002c3a183 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) CrashRecoveryContext.cpp:0:0
 #3 0x0000000002c3a2fe CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x00007fe6a1876870 __restore_rt sigaction.c:0:0
 #5 0x00007fe6a1330d22 raise (/usr/lib/libc.so.6+0x3cd22)
 #6 0x00007fe6a131a862 abort (/usr/lib/libc.so.6+0x26862)
 #7 0x00007fe6a131a747 _nl_load_domain.cold loadmsgcat.c:0:0
 #8 0x00007fe6a1329616 (/usr/lib/libc.so.6+0x35616)
 #9 0x0000000002cc7657 SplitBlockPredecessorsImpl(llvm::BasicBlock*, llvm::ArrayRef<llvm::BasicBlock*>, char const*, llvm::DomTreeUpdater*, llvm::DominatorTree*, llvm::LoopInfo*, llvm::MemorySSAUpdater*, bool) BasicBlockUtils.cpp:0:0
#10 0x0000000002cc5f5f llvm::SplitBlockPredecessors(llvm::BasicBlock*, llvm::ArrayRef<llvm::BasicBlock*>, char const*, llvm::DominatorTree*, llvm::LoopInfo*, llvm::MemorySSAUpdater*, bool) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x2cc5f5f)
#11 0x0000000003e0bc5b polly::simplifyRegion(llvm::Region*, llvm::DominatorTree*, llvm::LoopInfo*, llvm::RegionInfo*) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x3e0bc5b)
#12 0x0000000003d4c819 generateCode(polly::Scop&, polly::IslAstInfo&, llvm::LoopInfo&, llvm::DominatorTree&, llvm::ScalarEvolution&, llvm::RegionInfo&) CodeGeneration.cpp:0:0
#13 0x0000000003d4c4cf polly::CodeGenerationPass::run(polly::Scop&, llvm::AnalysisManager<polly::Scop, polly::ScopStandardAnalysisResults&>&, polly::ScopStandardAnalysisResults&, polly::SPMUpdater&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x3d4c4cf)
#14 0x0000000003d3f43d llvm::detail::PassModel<polly::Scop, polly::CodeGenerationPass, llvm::PreservedAnalyses, llvm::AnalysisManager<polly::Scop, polly::ScopStandardAnalysisResults&>, polly::ScopStandardAnalysisResults&, polly::SPMUpdater&>::run(polly::Scop&, llvm::AnalysisManager<polly::Scop, polly::ScopStandardAnalysisResults&>&, polly::ScopStandardAnalysisResults&, polly::SPMUpdater&) RegisterPasses.cpp:0:0
#15 0x0000000003daf0f5 llvm::PassManager<polly::Scop, llvm::AnalysisManager<polly::Scop, polly::ScopStandardAnalysisResults&>, polly::ScopStandardAnalysisResults&, polly::SPMUpdater&>::run(polly::Scop&, llvm::AnalysisManager<polly::Scop, polly::ScopStandardAnalysisResults&>&, polly::ScopStandardAnalysisResults&, polly::SPMUpdater&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x3daf0f5)
#16 0x0000000003d3a640 polly::FunctionToScopPassAdaptor<llvm::PassManager<polly::Scop, llvm::AnalysisManager<polly::Scop, polly::ScopStandardAnalysisResults&>, polly::ScopStandardAnalysisResults&, polly::SPMUpdater&> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) RegisterPasses.cpp:0:0
#17 0x0000000003d3a01d llvm::detail::PassModel<llvm::Function, polly::FunctionToScopPassAdaptor<llvm::PassManager<polly::Scop, llvm::AnalysisManager<polly::Scop, polly::ScopStandardAnalysisResults&>, polly::ScopStandardAnalysisResults&, polly::SPMUpdater&> >, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) RegisterPasses.cpp:0:0
#18 0x000000000254ff21 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x254ff21)
#19 0x00000000033c799d llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) BackendUtil.cpp:0:0
#20 0x00000000025535f4 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x25535f4)
#21 0x00000000033c9c5d llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) BackendUtil.cpp:0:0
#22 0x000000000254ec64 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x254ec64)
#23 0x00000000033be056 (anonymous namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) BackendUtil.cpp:0:0
#24 0x00000000033b8087 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+0x33b8087)
#25 0x00000000037e83f0 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) CodeGenAction.cpp:0:0
#26 0x0000000004141364 clang::ParseAST(clang::Sema&, bool, bool) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x4141364)
#27 0x0000000003735ee0 clang::FrontendAction::Execute() (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x3735ee0)
#28 0x00000000036aeb2f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x36aeb2f)
#29 0x00000000037e1ed7 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x37e1ed7)
#30 0x00000000019dec2b cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x19dec2b)
#31 0x00000000019dc78d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#32 0x00000000035462b2 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
#33 0x0000000002c3a097 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x2c3a097)
#34 0x0000000003545e17 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+0x3545e17)
#35 0x000000000350e248 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x350e248)
#36 0x000000000350e517 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+0x350e517)
#37 0x0000000003526a21 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+0x3526a21)
#38 0x00000000019dc071 main (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x19dc071)
#39 0x00007fe6a131bb25 __libc_start_main (/usr/lib/libc.so.6+0x27b25)
#40 0x00000000019d95be _start (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang+0x19d95be)
clang-14: error: clang frontend command failed with exit code 134 (use -v to see invocation)
ClangBuiltLinux clang version 14.0.0 (https://github.com/llvm/llvm-project 84b07c9b3aa79e073a97290bdd30d98b1941a536)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/nathan/cbl/github/tc-build/build/llvm/stage1/bin
clang-14: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-14: note: diagnostic msg: /tmp/simple-card-utils-126641.c
clang-14: note: diagnostic msg: /tmp/simple-card-utils-126641.sh
clang-14: note: diagnostic msg: 

********************
make[4]: *** [scripts/Makefile.build:271: sound/soc/generic/simple-card-utils.o] Error 134
make[4]: Target '__build' not remade because of errors.
make[3]: *** [scripts/Makefile.build:514: sound/soc/generic] Error 2
make[3]: Target '__build' not remade because of errors.
make[2]: *** [scripts/Makefile.build:514: sound/soc] Error 2
make[2]: Target '__build' not remade because of errors.
make[1]: *** [Makefile:1859: sound] Error 2
make[1]: Target 'all' not remade because of errors.
make: *** [Makefile:351: __build_one_by_one] Error 2
make: Target 'clean' not remade because of errors.
make: Target 'olddefconfig' not remade because of errors.
make: Target 'all' not remade because of errors.

I'll reduce that in a bit.

@nickdesaulniers
Copy link
Member

nickdesaulniers commented Sep 21, 2021

"Cannot split an edge from a CallBrInst"

CallBrInst is the LLVM Instruction used to represent asm goto; yet @nathanchance 's cvise-reduced input doesn't contain asm goto.

@ms178
Copy link
Author

ms178 commented Sep 21, 2021

Can you provide the current LLVM SHA that's known bad, and the prior known good version? That should give us a regression window that might be highly relevant to minimize the time spent bisecting, and get something reverted upstream. You should be able to use git reflog to see your prior sha before a git pull.

I hope that thanks to Nathan's detective work, that it is no longer neccessary as I'd would need to guess anyway. For future bug reports, I'll keep in mind to note the exact version which I am testing with to save some of your time.

@nathanchance
Copy link
Member

"Cannot split an edge from a CallBrInst"

CallBrInst is the LLVM Instruction used to represent asm goto; yet @nathanchance 's cvise-reduced input doesn't contain asm goto.

Sorry, was running out the door for lunch when I wrote that, I should have clarified that we are talking about two different drivers here and two different errors but with the same config and similar flags so the issues might be related? I can spin off this part of the report into a separate issue if you want but I will post it here for now. The reproducer does definitely have asm goto in it but both of these reports depend on the polly options in @ms178 's flags so that is why we have not flushed these out yet (we had a Polly patch submitted upstream by @lazerl0rd but I never got around to testing and reviewing it).

$ cat simple-card-utils.i
struct {
  int num_cpus;
  int num_platforms;
} * asoc_simple_init_priv_dai_link;
int asoc_simple_init_priv_li_2, asoc_simple_init_priv_li_1_0_0,
    asoc_simple_init_priv_li_0;
void asoc_simple_init_priv() {
  int i;
  asm goto("" : : : : l_yes);
l_yes:
  i = 0;
  for (; i < asoc_simple_init_priv_li_0; i++)
    if (asoc_simple_init_priv_li_1_0_0)
      asoc_simple_init_priv_dai_link[i].num_cpus = asoc_simple_init_priv_li_2;
    else
      asoc_simple_init_priv_dai_link[i].num_platforms = 0;
}

$ clang -O2 -mllvm -polly -mllvm -polly-invariant-load-hoisting -c -o /dev/null simple-card-utils.i
clang: /home/nathan/cbl/github/tc-build/llvm-project/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp:1112: llvm::BasicBlock *SplitBlockPredecessorsImpl(llvm::BasicBlock *, ArrayRef<llvm::BasicBlock *>, const char *, llvm::DomTreeUpdater *, llvm::DominatorTree *, llvm::LoopInfo *, llvm::MemorySSAUpdater *, bool): Assertion `!isa<CallBrInst>(Preds[i]->getTerminator()) && "Cannot split an edge from a CallBrInst"' 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 -O2 -mllvm -polly -mllvm -polly-invariant-load-hoisting -c -o /dev/null simple-card-utils.i
1.	<eof> parser at end of file
2.	Optimizer
 #0 0x0000000002cb92d3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x2cb92d3)
 #1 0x0000000002cb70fe llvm::sys::RunSignalHandlers() (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x2cb70fe)
 #2 0x0000000002c401e3 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) CrashRecoveryContext.cpp:0:0
 #3 0x0000000002c4035e CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x00007f9682b54870 __restore_rt sigaction.c:0:0
 #5 0x00007f968260ed22 raise (/usr/lib/libc.so.6+0x3cd22)
 #6 0x00007f96825f8862 abort (/usr/lib/libc.so.6+0x26862)
 #7 0x00007f96825f8747 _nl_load_domain.cold loadmsgcat.c:0:0
 #8 0x00007f9682607616 (/usr/lib/libc.so.6+0x35616)
 #9 0x0000000002ccd6b7 SplitBlockPredecessorsImpl(llvm::BasicBlock*, llvm::ArrayRef<llvm::BasicBlock*>, char const*, llvm::DomTreeUpdater*, llvm::DominatorTree*, llvm::LoopInfo*, llvm::MemorySSAUpdater*, bool) BasicBlockUtils.cpp:0:0
#10 0x0000000002ccbfbf llvm::SplitBlockPredecessors(llvm::BasicBlock*, llvm::ArrayRef<llvm::BasicBlock*>, char const*, llvm::DominatorTree*, llvm::LoopInfo*, llvm::MemorySSAUpdater*, bool) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x2ccbfbf)
#11 0x0000000003e1ae8b polly::simplifyRegion(llvm::Region*, llvm::DominatorTree*, llvm::LoopInfo*, llvm::RegionInfo*) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x3e1ae8b)
#12 0x0000000003d5ba19 generateCode(polly::Scop&, polly::IslAstInfo&, llvm::LoopInfo&, llvm::DominatorTree&, llvm::ScalarEvolution&, llvm::RegionInfo&) CodeGeneration.cpp:0:0
#13 0x0000000003d5b6cf polly::CodeGenerationPass::run(polly::Scop&, llvm::AnalysisManager<polly::Scop, polly::ScopStandardAnalysisResults&>&, polly::ScopStandardAnalysisResults&, polly::SPMUpdater&) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x3d5b6cf)
#14 0x0000000003d4e63d llvm::detail::PassModel<polly::Scop, polly::CodeGenerationPass, llvm::PreservedAnalyses, llvm::AnalysisManager<polly::Scop, polly::ScopStandardAnalysisResults&>, polly::ScopStandardAnalysisResults&, polly::SPMUpdater&>::run(polly::Scop&, llvm::AnalysisManager<polly::Scop, polly::ScopStandardAnalysisResults&>&, polly::ScopStandardAnalysisResults&, polly::SPMUpdater&) RegisterPasses.cpp:0:0
#15 0x0000000003dbe2f5 llvm::PassManager<polly::Scop, llvm::AnalysisManager<polly::Scop, polly::ScopStandardAnalysisResults&>, polly::ScopStandardAnalysisResults&, polly::SPMUpdater&>::run(polly::Scop&, llvm::AnalysisManager<polly::Scop, polly::ScopStandardAnalysisResults&>&, polly::ScopStandardAnalysisResults&, polly::SPMUpdater&) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x3dbe2f5)
#16 0x0000000003d49840 polly::FunctionToScopPassAdaptor<llvm::PassManager<polly::Scop, llvm::AnalysisManager<polly::Scop, polly::ScopStandardAnalysisResults&>, polly::ScopStandardAnalysisResults&, polly::SPMUpdater&> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) RegisterPasses.cpp:0:0
#17 0x0000000003d4921d llvm::detail::PassModel<llvm::Function, polly::FunctionToScopPassAdaptor<llvm::PassManager<polly::Scop, llvm::AnalysisManager<polly::Scop, polly::ScopStandardAnalysisResults&>, polly::ScopStandardAnalysisResults&, polly::SPMUpdater&> >, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) RegisterPasses.cpp:0:0
#18 0x0000000002555d31 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x2555d31)
#19 0x00000000033d601d llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) BackendUtil.cpp:0:0
#20 0x0000000002559404 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x2559404)
#21 0x00000000033d82dd llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) BackendUtil.cpp:0:0
#22 0x0000000002554a74 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x2554a74)
#23 0x00000000033cbea2 (anonymous namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) BackendUtil.cpp:0:0
#24 0x00000000033c6707 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/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x33c6707)
#25 0x00000000037f6b10 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) CodeGenAction.cpp:0:0
#26 0x00000000041506f4 clang::ParseAST(clang::Sema&, bool, bool) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x41506f4)
#27 0x0000000003744600 clang::FrontendAction::Execute() (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x3744600)
#28 0x00000000036bd24f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x36bd24f)
#29 0x00000000037f05f7 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x37f05f7)
#30 0x00000000019e43fb cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x19e43fb)
#31 0x00000000019e1f5d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#32 0x00000000035549d2 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
#33 0x0000000002c400f7 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x2c400f7)
#34 0x0000000003554537 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/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x3554537)
#35 0x000000000351c968 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x351c968)
#36 0x000000000351cc37 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x351cc37)
#37 0x0000000003535141 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x3535141)
#38 0x00000000019e1841 main (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x19e1841)
#39 0x00007f96825f9b25 __libc_start_main (/usr/lib/libc.so.6+0x27b25)
#40 0x00000000019ded8e _start (/home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin/clang-14+0x19ded8e)
clang-14: error: clang frontend command failed with exit code 134 (use -v to see invocation)
ClangBuiltLinux clang version 14.0.0 (https://github.com/llvm/llvm-project 85b4b21c8bbad346d58a30154d2767c39cf3285a)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/nathan/tmp/llvm-85b4b21c8bbad346d58a30154d2767c39cf3285a-assertions/bin
clang-14: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.

@ms178
Copy link
Author

ms178 commented Sep 21, 2021

The reproducer does definitely have asm goto in it but both of these reports depend on the polly options in @ms178 's flags so that is why we have not flushed these out yet (we had a Polly patch submitted upstream by @lazerl0rd but I never got around to testing and reviewing it).

As I am using Polly for quite some time now to build my Kernel (it works fine, with some exceptions as mentioned in #1396), I am more than willing to give you my Tested-by if it helps the upstream process. To throw some numbers into the mix: My heavily tweaked Kernel provides a 2.38x performance improvement vs. the default distro Kernel in my standard game benchmark (Company of Heroes 2 which is heavily CPU-bound, built-in benchmark, 90.5 fps vs. 38 fps, tested on current Manjaro but testing on Ubuntu and openSUSE Tumbleweed revealed similar numbers).

But Polly is only a smaller part of the equation, I can get most of my improvements also on a mainline Kernel with my custom config and some more modest CFLAGS, even with GCC. Hence I suspect that my configuration tweaks and march=native provide most of the benefits but I haven't had the time for a deeper performance analysis yet.

@nickdesaulniers
Copy link
Member

This looks like a compiler bug specific to polly (polly::simplifyRegion).

@ms178
Copy link
Author

ms178 commented Sep 24, 2021

Should I file a bug report on the LLVM bugtracker for this? I just got an account and I've got a couple of other LTO/Polly related findings to share there...

@nickdesaulniers
Copy link
Member

Sure; I'd recommend familiarizing yourself with creduce or cvise to provide concise reproducers before you go and file bugs. Bug reports that ask toolchain devs to clone a bunch of sources probably won't get much feedback otherwise. For instance, Nathan's reproducer above is really good.

@ms178
Copy link
Author

ms178 commented Sep 24, 2021

Thanks for your help, but that is getting into programmer territory which I lack the time to dig deeper into - I filed https://llvm.org/pr51960 and provided two of Nathan's cvise outputs to make the Polly devs aware of the issue and hope that someone finds a fix.

@ms178
Copy link
Author

ms178 commented Sep 24, 2021

From Michael Kruse: "I am working on a fix on Number 1. The assembly string is handled as local value and therefore passed as an argument to the outlined function, but the asm string must be known at the call location at compile-time."

I've filed https://llvm.org/pr51964 for the second issue regarding simple-card-utils

@ms178
Copy link
Author

ms178 commented Sep 26, 2021

@ms178
Copy link
Author

ms178 commented Sep 26, 2021

With LLVM/Clang-14 9820dd970c1b72c7f77fad647b762053e2f60e31 and Linux-Xanmod-Edge 5.14.7, slightly different changes in the Makefile (attached), with FullLTO, the build now breaks with the following modpost errors.

Makefile.txt
`

--- -	2021-09-26 23:57:42.593644645 +0200
+++ /home/marcus/Downloads/linux-xanmod-edge/src/linux-5.14/Makefile	2021-09-26 23:56:58.641216588 +0200
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 VERSION = 5
 PATCHLEVEL = 14
-SUBLEVEL = 7
+SUBLEVEL = 8
 EXTRAVERSION =
 NAME = Opossums on Parade
 
@@ -433,13 +433,13 @@
 endif
 
 export KBUILD_USERCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
-			      -O3 -march=native -mtune=native -mllvm -polly -mllvm -polly-parallel -fopenmp -mllvm -polly-vectorizer=stripmine -mllvm -polly-omp-backend=LLVM -mllvm -polly-num-threads=24 -mllvm -polly-scheduling=dynamic -mllvm -polly-scheduling-chunksize=1 -mllvm -polly-ast-use-context -mllvm -polly-invariant-load-hoisting -mllvm -polly-opt-fusion=max -mllvm -polly-run-inliner -mllvm -polly-run-dce -fno-math-errno -fno-trapping-math -falign-functions=32 -fno-semantic-interposition -std=gnu2x
-export KBUILD_USERLDFLAGS := -Wl,-O3 -Wl,--as-needed -Wl,-Bsymbolic-functions
+			      -O2 -fomit-frame-pointer -std=gnu89
+export KBUILD_USERLDFLAGS :=
 
 KBUILD_HOSTCFLAGS   := $(KBUILD_USERCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
-KBUILD_HOSTCXXFLAGS := -O3 -march=native -mtune=native -mllvm -polly -mllvm -polly-parallel -fopenmp -mllvm -polly-vectorizer=stripmine -mllvm -polly-omp-backend=LLVM -mllvm -polly-num-threads=24 -mllvm -polly-scheduling=dynamic -mllvm -polly-scheduling-chunksize=1 -mllvm -polly-ast-use-context -mllvm -polly-invariant-load-hoisting -mllvm -polly-opt-fusion=max -mllvm -polly-run-inliner -mllvm -polly-run-dce -fno-math-errno -fno-trapping-math -falign-functions=32 -fno-semantic-interposition $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
-KBUILD_HOSTLDFLAGS  := -Wl,-O3 -Wl,--as-needed -Wl,-Bsymbolic-functions $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
-KBUILD_HOSTLDLIBS   := -Wl,-O3 -Wl,--as-needed -Wl,-Bsymbolic-functions $(HOST_LFS_LIBS) $(HOSTLDLIBS)
+KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
+KBUILD_HOSTLDFLAGS  := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
+KBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
 
 # Make variables (CC, etc...)
 CPP		= $(CC) -E
@@ -484,10 +484,10 @@
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
 		  -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
 NOSTDINC_FLAGS :=
-CFLAGS_MODULE   = -O3 -march=native -mtune=native -mllvm -polly -mllvm -polly-parallel -fopenmp -mllvm -polly-vectorizer=stripmine -mllvm -polly-omp-backend=LLVM -mllvm -polly-num-threads=24 -mllvm -polly-scheduling=dynamic -mllvm -polly-scheduling-chunksize=1 -mllvm -polly-ast-use-context -mllvm -polly-invariant-load-hoisting -mllvm -polly-opt-fusion=max -mllvm -polly-run-inliner -mllvm -polly-run-dce -fno-math-errno -fno-trapping-math -falign-functions=32 -fno-semantic-interposition
+CFLAGS_MODULE   =
 AFLAGS_MODULE   =
 LDFLAGS_MODULE  =
-CFLAGS_KERNEL	= -march=native -mtune=native -mllvm -polly -mllvm -polly-parallel -fopenmp -mllvm -polly-vectorizer=stripmine -mllvm -polly-omp-backend=LLVM -mllvm -polly-num-threads=24 -mllvm -polly-scheduling=dynamic -mllvm -polly-scheduling-chunksize=1 -mllvm -polly-ast-use-context -mllvm -polly-invariant-load-hoisting -mllvm -polly-opt-fusion=max -mllvm -polly-run-inliner -mllvm -polly-run-dce -fno-math-errno -fno-trapping-math -falign-functions=32 -fno-semantic-interposition
+CFLAGS_KERNEL	=
 AFLAGS_KERNEL	=
 LDFLAGS_vmlinux =
 
@@ -698,6 +698,15 @@
   CC_FLAGS_FTRACE := -pg
 endif
 
+RETPOLINE_CFLAGS_GCC := -mindirect-branch=thunk-extern -mindirect-branch-register
+RETPOLINE_VDSO_CFLAGS_GCC := -mindirect-branch=thunk-inline -mindirect-branch-register
+RETPOLINE_CFLAGS_CLANG := -mretpoline-external-thunk
+RETPOLINE_VDSO_CFLAGS_CLANG := -mretpoline
+RETPOLINE_CFLAGS := $(call cc-option,$(RETPOLINE_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_CFLAGS_CLANG)))
+RETPOLINE_VDSO_CFLAGS := $(call cc-option,$(RETPOLINE_VDSO_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_VDSO_CFLAGS_CLANG)))
+export RETPOLINE_CFLAGS
+export RETPOLINE_VDSO_CFLAGS
+
 include $(srctree)/arch/$(SRCARCH)/Makefile
 
 ifdef need-config
@@ -757,6 +766,7 @@
 KBUILD_CFLAGS += -O2
 else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3
 KBUILD_CFLAGS += -O3
+KBUILD_CFLAGS += $(call cc-option, -fno-tree-loop-vectorize)
 else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
 KBUILD_CFLAGS += -Os
 endif

ERROR: modpost: "__kmpc_fork_call" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined!
ERROR: modpost: "__kmpc_push_num_threads" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined!
ERROR: modpost: "__kmpc_global_thread_num" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined!
ERROR: modpost: "__kmpc_dispatch_next_8" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined!
ERROR: modpost: "__kmpc_dispatch_init_8" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined!

Michael Kruse suggested to not use -mllvm -polly-parallel - I just wonder why ThinLTO has no problems with this option, but FullLTO does. Removing this option results in a 9% bigger Kernel (vs. a ThinLTO-Kernel with the flags from the Makefile above), but it compiles successfully.

@Meinersbur
Copy link

If ThinLTO 'worked' it just means that that Polly did not find anything worth parallelizing, and thus did not emit calls to __kmpc runtime functions. FullLTO might haven inlined more functions and therefore caused the kernel to be bigger. However, more inlining also means more optimization opportunities such as loop parallelization.

Parallelism in the kernel works very differently than in user mode. you'd need kthreads instead of pthreads. Since OpenMP (-fopenmp) also builds on pthread, it also cannot be used inside the kernel.

In summary, even without parallelization, Polly is not intended for low-level, already hand-optimized code such as you find in an OS kernel. I'd be surprised if you can measure any amount of performance improvement. Of course, it should still not crash or miscompile, hence thanks @ms178 for the bug reports.

@nickdesaulniers
Copy link
Member

@ms178 nice! Thanks for filing those bugs. Looks like both of those are now closed/fixed. Can you rebase your build of LLVM to TOT and report if these issues are all now fixed?

@ms178
Copy link
Author

ms178 commented Sep 27, 2021

@nickdesaulniers I am very happy that we could solve this together, thank you all for your work! As mentioned in my last post, with the suggestion of Michael Kruse to not use Polly's auto-parallelization flags for the Kernel, I can report that my flto-build succeeded succesfully even with the first fix only. As I could not reproduce the second issue at that time, I think that implies that we can close this issue now, right?! Of course I will try out a newer LLVM build somewhen later this week as my day job keeps me busy during the weekdays. I hope you don't mind leaving it open for a couple of days longer as I've seen that the second fix is responsible for some test failures (see: https://reviews.llvm.org/rG91f46bb77e6d56955c3b96e9e844ae6a251c41e9).

For the exact flags used this time, here is the Makefile for reference
Makefile.txt

It boils down to:

' -O3 -march=native -mtune=native -mllvm -polly -mllvm -polly-vectorizer=stripmine -mllvm -polly-scheduling=dynamic -mllvm -polly-scheduling-chunksize=1 -mllvm -polly-ast-use-context -mllvm -polly-invariant-load-hoisting -mllvm -polly-opt-fusion=max -mllvm -polly-run-inliner -mllvm -polly-run-dce -fno-math-errno -fno-trapping-math -falign-functions=32 -fno-semantic-interposition'

I've since noticed that polly-opt-fusion is now obsolete.

@ms178
Copy link
Author

ms178 commented Sep 30, 2021

@nickdesaulniers Testing with d104db531ee6d821d94ffd4bb48fa3929ab01235 revealed no surprises. I get the same modpost errors if compiled with the original build flags I used, but the build finishes successfully without polly-parallel-related flags, hence I am closing this issue.

@ms178 ms178 closed this as completed Sep 30, 2021
@nickdesaulniers nickdesaulniers added the [FIXED][LLVM] 14 This bug was fixed in LLVM 14.x label Sep 30, 2021
@nickdesaulniers
Copy link
Member

thanks for verifying and reporting back, @ms178 !

vijaymalav564 added a commit to vijaymalav564/kernel_realme_sdm660 that referenced this issue Oct 11, 2021
vijaymalav564 added a commit to vijaymalav564/kernel_realme_sdm660 that referenced this issue Oct 11, 2021
vijaymalav564 added a commit to vijaymalav564/kernel_realme_sdm660 that referenced this issue Oct 11, 2021
vijaymalav564 added a commit to vijaymalav564/kernel_realme_sdm660 that referenced this issue Oct 12, 2021
vijaymalav564 added a commit to vijaymalav564/kernel_realme_sdm660 that referenced this issue Oct 12, 2021
vijaymalav564 added a commit to vijaymalav564/kernel_realme_sdm660 that referenced this issue Oct 12, 2021
@nathanchance nathanchance added the Extra flags The use of additional, non-standard CFLAGS causes this issue label Dec 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[ARCH] x86_64 This bug impacts ARCH=x86_64 [BUG] llvm (main) A bug in an unreleased version of LLVM (this label is appropriate for regressions) Extra flags The use of additional, non-standard CFLAGS causes this issue [FEATURE] LTO Related to building the kernel with LLVM Link Time Optimization [FIXED][LLVM] 14 This bug was fixed in LLVM 14.x
Projects
None yet
Development

No branches or pull requests

4 participants