Hello, currently autoprofiled bootstrap produces auto-profiles for cc1 and cc1plus binaries. Those are used to build respective frontend files. For backend cc1plus.fda is used. This does not work well with LTO bootstrap where cc1plus backend is untrained since it is used only for parsing and ealry opts. As a result all binaries gets most of the backend optimized for size rather then speed.
This patch adds lto1.fda and then combines all of cc1, cc1plus and lto1 into all.fda that is used compiling common modules. This is more or less equivalent to what -fprofile-use effectively uses modulo that with -fprofile-use we know number of runs of evety object file and scale accordingly at LTO time. There is comment disabling lto1 profiling claiming it does not work. Indeed I get an ICE which I fixed in separate patch. autoprofiledbootstrapped x86_64-linux with the extra fix, profiledbootstrap is running, OK if it passes? gcc/ChangeLog: * Makefile.in (ALL_FDAS): New variable. (ALL_HOST_BACKEND_OBJ): Use all.fda instead of cc1plus.fda (all.fda): New target. gcc/c/ChangeLog: * Make-lang.in: Add c_FDAS. gcc/cp/ChangeLog: * Make-lang.in: Add c++_FDAS. gcc/lto/ChangeLog: * Make-lang.in: Add lto1_FDAS. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index d5ceccc424b..a9dd07f7532 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1895,6 +1895,9 @@ OBJS-libcommon-target = $(common_out_object_file) prefix.o \ # This lists all host objects for the front ends. ALL_HOST_FRONTEND_OBJS = $(foreach v,$(CONFIG_LANGUAGES),$($(v)_OBJS)) +# All auto-profile files +ALL_FDAS = $(foreach v,$(CONFIG_LANGUAGES),$($(v)_FDAS)) + ALL_HOST_BACKEND_OBJS = $(GCC_OBJS) $(OBJS) $(OBJS-libcommon) \ $(OBJS-libcommon-target) main.o c-family/cppspec.o \ $(COLLECT2_OBJS) $(EXTRA_GCC_OBJS) $(GCOV_OBJS) $(GCOV_DUMP_OBJS) \ @@ -1905,8 +1908,8 @@ ALL_HOST_BACKEND_OBJS = $(GCC_OBJS) $(OBJS) $(OBJS-libcommon) \ # is likely the most exercised during the build ifeq ($(if $(wildcard ../stage_current),$(shell cat \ ../stage_current)),stageautofeedback) -$(ALL_HOST_BACKEND_OBJS): ALL_COMPILERFLAGS += -fauto-profile=cc1plus.fda -$(ALL_HOST_BACKEND_OBJS): cc1plus.fda +$(ALL_HOST_BACKEND_OBJS): ALL_COMPILERFLAGS += -fauto-profile=all.fda +$(ALL_HOST_BACKEND_OBJS): all.fda endif # This lists all host object files, whether they are included in this @@ -4727,6 +4730,9 @@ paranoia.o: $(srcdir)/../contrib/paranoia.cc $(CONFIG_H) $(SYSTEM_H) $(TREE_H) paranoia: paranoia.o real.o $(LIBIBERTY) g++ -o $@ paranoia.o real.o $(LIBIBERTY) +all.fda: $(ALL_FDAS) + $(PROFILE_MERGER) $(ALL_FDAS) --output_file all.fda -gcov_version 2 + # These exist for maintenance purposes. CTAGS=@CTAGS@ diff --git a/gcc/c/Make-lang.in b/gcc/c/Make-lang.in index 2517b64439f..049fe12a3ea 100644 --- a/gcc/c/Make-lang.in +++ b/gcc/c/Make-lang.in @@ -58,6 +58,7 @@ C_AND_OBJC_OBJS = attribs.o c/c-errors.o c/c-decl.o c/c-typeck.o \ # Language-specific object files for C. C_OBJS = c/c-lang.o c-family/stub-objc.o $(C_AND_OBJC_OBJS) c_OBJS = $(C_OBJS) cc1-checksum.o c/gccspec.o +c_FDAS = cc1.fda # Use strict warnings for this front end. c-warn = $(STRICT_WARN) diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index dae3c6846e0..d47d096c886 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -123,6 +123,8 @@ CXX_OBJS = cp/cp-lang.o c-family/stub-objc.o $(CXX_AND_OBJCXX_OBJS) c++_OBJS = $(CXX_OBJS) cc1plus-checksum.o cp/g++spec.o +c++_FDAS = cc1plus.fda + # Use strict warnings for this front end. cp-warn = $(STRICT_WARN) diff --git a/gcc/lto/Make-lang.in b/gcc/lto/Make-lang.in index 553e6ddd0d2..a7dd7526bc7 100644 --- a/gcc/lto/Make-lang.in +++ b/gcc/lto/Make-lang.in @@ -26,18 +26,15 @@ LTO_DUMP_INSTALL_NAME := $(shell echo lto-dump|sed '$(program_transform_name)') # The LTO-specific object files inclued in $(LTO_EXE). LTO_OBJS = lto/lto-lang.o lto/lto.o lto/lto-object.o attribs.o lto/lto-partition.o lto/lto-symtab.o lto/lto-common.o lto_OBJS = $(LTO_OBJS) +lto_FDAS = lto1.fda LTO_DUMP_OBJS = lto/lto-lang.o lto/lto-object.o attribs.o lto/lto-partition.o lto/lto-symtab.o lto/lto-dump.o lto/lto-common.o lto_dump_OBJS = $(LTO_DUMP_OBJS) -# this is only useful in a LTO bootstrap, but this does not work right -# now. Should reenable after this is fixed, but only when LTO bootstrap -# is enabled. - -#ifeq ($(if $(wildcard ../stage_current),$(shell cat \ -# ../stage_current)),stageautofeedback) -#$(LTO_OBJS): CFLAGS += -fauto-profile=lto1.fda -#$(LTO_OBJS): lto1.fda -#endif +ifeq ($(if $(wildcard ../stage_current),$(shell cat \ + ../stage_current)),stageautofeedback) +$(LTO_OBJS): CFLAGS += -fauto-profile=lto1.fda +$(LTO_OBJS): lto1.fda +endif # Rules