1# SPDX-License-Identifier: GPL-2.0 2 3# Enable available and selected Clang AutoFDO features. 4 5CFLAGS_AUTOFDO_CLANG := -fdebug-info-for-profiling -mllvm -enable-fs-discriminator=true -mllvm -improved-fs-discriminator=true 6 7ifndef CONFIG_DEBUG_INFO 8 CFLAGS_AUTOFDO_CLANG += -gmlt 9endif 10 11ifdef CLANG_AUTOFDO_PROFILE 12 CFLAGS_AUTOFDO_CLANG += -fprofile-sample-use=$(CLANG_AUTOFDO_PROFILE) -ffunction-sections 13 CFLAGS_AUTOFDO_CLANG += -fsplit-machine-functions 14endif 15 16ifdef CONFIG_LTO_CLANG_THIN 17 ifdef CLANG_AUTOFDO_PROFILE 18 KBUILD_LDFLAGS += --lto-sample-profile=$(CLANG_AUTOFDO_PROFILE) 19 endif 20 KBUILD_LDFLAGS += --mllvm=-enable-fs-discriminator=true --mllvm=-improved-fs-discriminator=true -plugin-opt=thinlto 21 KBUILD_LDFLAGS += -plugin-opt=-split-machine-functions 22endif 23 24export CFLAGS_AUTOFDO_CLANG 25