From d8b5868b6213624d2409d9ff40f6ad5b5ed46d37 Mon Sep 17 00:00:00 2001 From: Diab Neiroukh Date: Sat, 28 Jan 2023 23:06:24 +0100 Subject: [PATCH] kbuild: Add support for Clang's polyhedral loop optimizer * Default N --- Makefile | 15 +++++++++++++++ arch/Kconfig | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/Makefile b/Makefile index ea1e01e57..45458a8de 100755 --- a/Makefile +++ b/Makefile @@ -721,6 +721,21 @@ KBUILD_CFLAGS += $(call cc-option,-fno-reorder-blocks,) \ $(call cc-option,-fno-partial-inlining) endif +ifdef CONFIG_LLVM_POLLY +KBUILD_CFLAGS += -mllvm -polly \ + -mllvm -polly-ast-use-context \ + -mllvm -polly-invariant-load-hoisting \ + -mllvm -polly-run-inliner \ + -mllvm -polly-vectorizer=stripmine +# Polly may optimise loops with dead paths beyound what the linker +# # can understand. This may negate the effect of the linker's DCE +# # so we tell Polly to perfom proven DCE on the loops it optimises +# # in order to preserve the overall effect of the linker's DCE. +ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION +KBUILD_CFLAGS += -mllvm -polly-run-dce +endif +endif + ifneq ($(CONFIG_FRAME_WARN),0) KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN}) endif diff --git a/arch/Kconfig b/arch/Kconfig index 8a5149f87..cb54b5c44 100755 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -594,6 +594,15 @@ 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)" + default n + 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