| 1 | # SPDX-License-Identifier: GPL-2.0 |
| 2 | |
| 3 | # Enable available and selected Clang AutoFDO features. |
| 4 | |
| 5 | CFLAGS_AUTOFDO_CLANG := -fdebug-info-for-profiling -mllvm -enable-fs-discriminator=true -mllvm -improved-fs-discriminator=true |
| 6 | |
| 7 | ifndef CONFIG_DEBUG_INFO |
| 8 | CFLAGS_AUTOFDO_CLANG += -gmlt |
| 9 | endif |
| 10 | |
| 11 | ifdef CLANG_AUTOFDO_PROFILE |
| 12 | CFLAGS_AUTOFDO_CLANG += -fprofile-sample-use=$(CLANG_AUTOFDO_PROFILE) -ffunction-sections |
| 13 | CFLAGS_AUTOFDO_CLANG += -fsplit-machine-functions |
| 14 | endif |
| 15 | |
| 16 | ifdef 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 |
| 22 | endif |
| 23 | |
| 24 | export CFLAGS_AUTOFDO_CLANG |