Skip to content

Commit b6d73ce

Browse files
authored
Merge pull request #4977 from lplarson/pgo-support
[build-script] Add clang PGO support
2 parents 489e805 + 0c3c02b commit b6d73ce

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

utils/build-script

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,12 @@ class BuildScriptInvocation(object):
810810
if args.dry_run:
811811
impl_args += ["--dry-run"]
812812

813+
if args.clang_profile_instr_use:
814+
impl_args += [
815+
"--clang-profile-instr-use=%s" %
816+
os.path.abspath(args.clang_profile_instr_use)
817+
]
818+
813819
if args.lit_args:
814820
impl_args += ["--llvm-lit-args=%s" % args.lit_args]
815821

@@ -1985,6 +1991,11 @@ details of the setups of other systems or automated environments.""")
19851991
const='full',
19861992
dest='lto_type')
19871993

1994+
parser.add_argument(
1995+
"--clang-profile-instr-use",
1996+
help="profile file to use for clang PGO",
1997+
metavar="PATH")
1998+
19881999
default_max_lto_link_job_counts = host.max_lto_link_job_counts()
19892000
parser.add_argument(
19902001
"--llvm-max-parallel-lto-link-jobs",

utils/build-script-impl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ KNOWN_SETTINGS=(
237237
user-config-args "" "**Renamed to --extra-cmake-options**: User-supplied arguments to cmake when used to do configuration."
238238
only-execute "all" "Only execute the named action (see implementation)"
239239
llvm-lit-args "" "If set, override the lit args passed to LLVM"
240+
clang-profile-instr-use "" "If set, profile file to use for clang PGO"
240241
coverage-db "" "If set, coverage database to use when prioritizing testing"
241242
build-toolchain-only "" "If set, only build the necessary tools to build an external toolchain"
242243
)
@@ -740,6 +741,12 @@ function set_build_options_for_host() {
740741
)
741742
fi
742743

744+
if [[ "${CLANG_PROFILE_INSTR_USE}" ]]; then
745+
llvm_cmake_options+=(
746+
-DLLVM_PROFDATA_FILE="${CLANG_PROFILE_INSTR_USE}"
747+
)
748+
fi
749+
743750
swift_cmake_options+=(
744751
-DCOVERAGE_DB="${COVERAGE_DB}"
745752
)

0 commit comments

Comments
 (0)