kbuild: Add support for LLVM's Polly optimizer

This adds support for compiling the kernel with optimizations offered
by LLVM's polyhedral loop optimizer known as Polly, which can improve
performance by improving cache locality in loops. Note that LLVM is not
compiled with Polly by default -- it must be enabled explicitly.

[ghostrider-reborn]
- Removed polly DCE as it's no longer supported

Signed-off-by: officialputuid <officialputuid@hack.id>
This commit is contained in:
Adithya R
2023-01-21 14:34:45 +00:00
committed by Ansh
parent e4e4a8ab85
commit 2274d80c0f
2 changed files with 18 additions and 0 deletions

View File

@@ -765,6 +765,16 @@ else
KBUILD_CFLAGS += -O3
endif
ifdef CONFIG_LLVM_POLLY
KBUILD_CFLAGS += -mllvm -polly \
-mllvm -polly-run-inliner \
-mllvm -polly-opt-fusion=max \
-mllvm -polly-ast-use-context \
-mllvm -polly-detect-keep-going \
-mllvm -polly-vectorizer=stripmine \
-mllvm -polly-invariant-load-hoisting
endif
# Tell gcc to never replace conditional load with a non-conditional one
KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)

View File

@@ -754,6 +754,14 @@ config SHADOW_CALL_STACK_VMAP
provides better stack exhaustion protection, but increases per-thread
memory consumption as a full page is allocated for each shadow stack.
config LLVM_POLLY
bool "Enable LLVM's polyhedral loop optimizer (Polly)"
help
This option enables LLVM's polyhedral loop optimizer known as Polly.
Polly is able to optimize various loops throughout the kernel for
maximum cache locality. This requires an LLVM toolchain explicitly
compiled with Polly support.
config HAVE_ARCH_WITHIN_STACK_FRAMES
bool
help