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: Adithya R <gh0strider.2k18.reborn@gmail.com>
This commit is contained in:
Danny Lin 2019-07-31 22:26:08 -07:00 committed by Ksawlii
parent eb9bf79ea9
commit 3c4fb71b04
2 changed files with 18 additions and 0 deletions

View file

@ -808,6 +808,16 @@ else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
KBUILD_CFLAGS += -Os
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

@ -738,6 +738,14 @@ config CFI_PERMISSIVE
warning instead of a kernel panic. This option is useful for finding
CFI violations during development.
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