Bug 1444171: Generate profiling instrumentation for clang-cl in PGO builds; r=glandium

This commit is contained in:
Nathan Froyd 2018-07-09 18:26:24 -04:00
parent e8a82fdba9
commit 9277d23dba
3 changed files with 14 additions and 1 deletions

View File

@ -157,7 +157,7 @@ endif
# Enable profile-based feedback
ifneq (1,$(NO_PROFILE_GUIDED_OPTIMIZE))
ifdef MOZ_PROFILE_GENERATE
PGO_CFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_GEN_CFLAGS))
PGO_CFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_GEN_CFLAGS) $(COMPUTED_PROFILE_GEN_DYN_CFLAGS))
PGO_LDFLAGS += $(PROFILE_GEN_LDFLAGS)
ifeq (WINNT,$(OS_ARCH))
AR_FLAGS += -LTCG

View File

@ -451,6 +451,7 @@ class CompileFlags(BaseCompileFlags):
('DSO_PIC', context.config.substs.get('DSO_PIC_CFLAGS'),
('CXXFLAGS', 'CFLAGS')),
('RTL', None, ('CXXFLAGS', 'CFLAGS')),
('PROFILE_GEN_DYN_CFLAGS', None, ('PROFILE_GEN_DYN_CFLAGS',)),
('OS_COMPILE_CFLAGS', context.config.substs.get('OS_COMPILE_CFLAGS'),
('CFLAGS',)),
('OS_COMPILE_CXXFLAGS', context.config.substs.get('OS_COMPILE_CXXFLAGS'),

View File

@ -1074,6 +1074,18 @@ class TreeMetadataEmitter(LoggingMixin):
not context.config.substs.get('MOZ_NO_DEBUG_RTL')):
rtl_flag += 'd'
computed_flags.resolve_flags('RTL', [rtl_flag])
# For PGO clang-cl builds, we generate order files in the
# profile generate phase that are subsequently used to link the
# final library. We need to provide flags to the compiler to
# have it instrument functions for generating the data for the
# order file. We'd normally put flags like these in
# PROFILE_GEN_CFLAGS or the like, but we need to only use the
# flags in contexts where we're compiling code for xul.
code_for_xul = context.get('FINAL_LIBRARY', 'notxul') == 'xul'
if context.config.substs.get('CLANG_CL') and code_for_xul:
computed_flags.resolve_flags('PROFILE_GEN_DYN_CFLAGS',
['-Xclang',
'-finstrument-functions-after-inlining'])
if not context.config.substs.get('CROSS_COMPILE'):
computed_host_flags.resolve_flags('RTL', [rtl_flag])