compilers: Enable PGO for ICC

ICC doesn't use the same -fprofile-generate/-fprofile-use that GCC and
Clang use, instead it has -prof-gen and -prof-use. I've gone ahead and
added the threadsafe option to -prof-gen, as meson currently doesn't
have a way to specify that level of granularity and GCC and Clang's
profiles are threadsafe.
pull/4359/head
Dylan Baker 6 years ago
parent 7329ae3ce6
commit f46adb44bf
  1. 29
      mesonbuild/compilers/compilers.py

@ -457,9 +457,9 @@ def get_base_compile_args(options, compiler):
try:
pgo_val = options['b_pgo'].value
if pgo_val == 'generate':
args.append('-fprofile-generate')
args.extend(compiler.get_profile_generate_args())
elif pgo_val == 'use':
args.extend(['-fprofile-use', '-fprofile-correction'])
args.extend(compiler.get_profile_use_args())
except KeyError:
pass
try:
@ -503,9 +503,9 @@ def get_base_link_args(options, linker, is_shared_module):
try:
pgo_val = options['b_pgo'].value
if pgo_val == 'generate':
args.append('-fprofile-generate')
args.extend(linker.get_profile_generate_args())
elif pgo_val == 'use':
args.extend(['-fprofile-use', '-fprofile-correction'])
args.extend(linker.get_profile_use_args())
except KeyError:
pass
try:
@ -674,7 +674,6 @@ class CompilerArgs(list):
to recursively search for symbols in the libraries. This is not needed
with other linkers.
'''
# A standalone argument must never be deduplicated because it is
# defined by what comes _after_ it. Thus dedupping this:
# -D FOO -D BAR
@ -1258,6 +1257,14 @@ class Compiler:
"""
return 'other'
def get_profile_generate_args(self):
raise EnvironmentException(
'%s does not support get_profile_generate_args ' % self.get_id())
def get_profile_use_args(self):
raise EnvironmentException(
'%s does not support get_profile_use_args ' % self.get_id())
@enum.unique
class CompilerType(enum.Enum):
@ -1498,6 +1505,12 @@ class GnuLikeCompiler(abc.ABC):
def get_argument_syntax(self):
return 'gcc'
def get_profile_generate_args(self):
return ['-fprofile-generate']
def get_profile_use_args(self):
return ['-fprofile-use', '-fprofile-correction']
class GnuCompiler(GnuLikeCompiler):
"""
@ -1779,6 +1792,12 @@ class IntelCompiler(GnuLikeCompiler):
]
return super().compiles(*args, **kwargs)
def get_profile_generate_args(self):
return ['-prof-gen=threadsafe']
def get_profile_use_args(self):
return ['-prof-use']
class ArmCompiler:
# Functionality that is common to all ARM family compilers.

Loading…
Cancel
Save