Rename PGO profile file name
PGO profile files are tied to their base revisions, and don't need
regeneration after cherry-picks. With the current naming scheme using
the long version (e.g. 8.0.7.profdata), the profile file needs to be
renamed every time we bump up the patch level during a respin of the
toolchain.
Let's change profile-file names to svn revision with trailing alphabet
suffix stripped (e.g. for r1234c, use r1234.profdata) to avoid these
unnecessary renames.
Test: python build.py --check-pgo-profile fails with old profile file
and passes with renamed profile.
Test: python toolchain/llvm/android/test_compiler.py --build-only
--target aosp_marlin-eng --no-clean-built-target
--generate-clang-profile --no-pgo ./
Change-Id: Ib72d7e5e9f040bc9e01d328fb024a258e95b12c3
diff --git a/build.py b/build.py
index 7ab4829..e05be00 100755
--- a/build.py
+++ b/build.py
@@ -22,6 +22,7 @@
import logging
import os
import shutil
+import string
import subprocess
import textwrap
import utils
@@ -86,8 +87,11 @@
return extract_clang_version(clang_install).long_version()
-def pgo_profdata_file(version_str):
- profdata_file = '%s.profdata' % version_str
+def pgo_profdata_filename():
+ base_revision = android_version.svn_revision.rstrip(string.ascii_lowercase)
+ return '%s.profdata' % base_revision
+
+def pgo_profdata_file(profdata_file):
profile = utils.android_path('prebuilts', 'clang', 'host', 'linux-x86',
'profiles', profdata_file)
return profile if os.path.exists(profile) else None
@@ -1503,13 +1507,13 @@
build_stage1(stage1_install, args.build_name,
build_llvm_tools=instrumented)
- long_version = extract_clang_long_version(stage1_install)
- profdata = pgo_profdata_file(long_version)
+ profdata_filename = pgo_profdata_filename()
+ profdata = pgo_profdata_file(profdata_filename)
# Do not use PGO profiles if profdata file doesn't exist unless failure
# is explicitly requested via --check-pgo-profile.
if profdata is None and args.check_pgo_profile:
raise RuntimeError('Profdata file does not exist for ' +
- long_version)
+ profdata_filename)
build_stage2(stage1_install, stage2_install, STAGE2_TARGETS,
args.build_name, args.enable_assertions,
diff --git a/test_compiler.py b/test_compiler.py
index 2c84131..50ec8ce 100755
--- a/test_compiler.py
+++ b/test_compiler.py
@@ -51,8 +51,7 @@
stage1_install = utils.out_path('stage1-install')
profdata = os.path.join(stage1_install, 'bin', 'llvm-profdata')
- long_version = build.extract_clang_long_version(stage1_install)
- profdata_file = '%s.profdata' % long_version
+ profdata_file = build.pgo_profdata_filename()
dist_dir = os.environ.get('DIST_DIR', utils.out_path())
out_file = os.path.join(dist_dir, profdata_file)