Commit 2872514e authored by xiongzhou4's avatar xiongzhou4
Browse files

GCC: Add value profile support for kernel.

GCC inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I734PM



---------------------------------

This feature add value profile support for kernel by changing GCOV
option "-fprofile-arcs" to "-fprofile-generate" when the new added
config "PGO_KERNEL" is set to y.

Like GCOV, the symbols required by value profile are migrated from
GCC source codes as they cannot be linked to kernel. Specifically,
from libgcc/libgcov-profiler.c to kernel/gcov/gcc_base.c.

kernel options:
CONFIG_PGO_KERNEL=y

Signed-off-by: default avatarXiong Zhou <xiongzhou4@huawei.com>
Reviewed-by: default avatarLi Yancheng <liyancheng@huawei.com>
parent f3014d9a
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -662,7 +662,12 @@ endif # KBUILD_EXTMOD
# Defaults to vmlinux, but the arch makefile usually adds further targets
all: vmlinux

CFLAGS_GCOV	:= -fprofile-arcs -ftest-coverage \
ifeq ($(CONFIG_PGO_KERNEL),y)
CFLAGS_GCOV := -fprofile-generate
else
CFLAGS_GCOV := -fprofile-arcs
endif
CFLAGS_GCOV += -ftest-coverage \
	$(call cc-option,-fno-tree-loop-im) \
	$(call cc-disable-warning,maybe-uninitialized,)
export CFLAGS_GCOV
+1 −0
Original line number Diff line number Diff line
@@ -7067,6 +7067,7 @@ CONFIG_SECTION_MISMATCH_WARN_ONLY=y
CONFIG_ARCH_WANT_FRAME_POINTERS=y
CONFIG_FRAME_POINTER=y
# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
# CONFIG_PGO_KERNEL is not set
# end of Compile-time checks and compiler options

#
+2 −0
Original line number Diff line number Diff line
@@ -9,3 +9,5 @@ ccflags-y := -D__KVM_VHE_HYPERVISOR__
obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o
obj-y += ../vgic-v3-sr.o ../aarch32.o ../vgic-v2-cpuif-proxy.o ../entry.o \
	 ../fpsimd.o ../hyp-entry.o

GCOV_PROFILE_switch.o := n
+6 −1
Original line number Diff line number Diff line
@@ -4,7 +4,12 @@
#

GPROF_OPT += -pg

ifeq ($(CONFIG_PGO_KERNEL),y)
GCOV_OPT += -fprofile-generate -ftest-coverage
else
GCOV_OPT += -fprofile-arcs -ftest-coverage
endif

CFLAGS-$(CONFIG_GCOV) += $(GCOV_OPT)
CFLAGS-$(CONFIG_GPROF) += $(GPROF_OPT)
+6 −0
Original line number Diff line number Diff line
@@ -22,6 +22,12 @@ $(USER_OBJS) $(UNPROFILE_OBJS): \
	CHECKFLAGS := $(patsubst $(NOSTDINC_FLAGS),,$(CHECKFLAGS))

# The stubs can't try to call mcount or update basic block data
ifeq ($(CONFIG_PGO_KERNEL),y)
define unprofile
	$(patsubst -pg,,$(patsubst -fprofile-generate -ftest-coverage,,$(1)))
endef
else
define unprofile
	$(patsubst -pg,,$(patsubst -fprofile-arcs -ftest-coverage,,$(1)))
endef
endif
Loading