Skip to content

Commit a7988a1

Browse files
authored
Merge pull request #4989 from lplarson/swift-3.0-branch-pgo-support
[3.0] [build-script] Add clang PGO support
2 parents d150eca + cb343e2 commit a7988a1

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
@@ -784,6 +784,12 @@ class BuildScriptInvocation(object):
784784
if args.dry_run:
785785
impl_args += ["--dry-run"]
786786

787+
if args.clang_profile_instr_use:
788+
impl_args += [
789+
"--clang-profile-instr-use=%s" %
790+
os.path.abspath(args.clang_profile_instr_use)
791+
]
792+
787793
if args.lit_args:
788794
impl_args += ["--llvm-lit-args=%s" % args.lit_args]
789795

@@ -1922,6 +1928,11 @@ details of the setups of other systems or automated environments.""")
19221928
const='full',
19231929
dest='lto_type')
19241930

1931+
parser.add_argument(
1932+
"--clang-profile-instr-use",
1933+
help="profile file to use for clang PGO",
1934+
metavar="PATH")
1935+
19251936
default_max_lto_link_job_counts = host.max_lto_link_job_counts()
19261937
parser.add_argument(
19271938
"--llvm-max-parallel-lto-link-jobs",

utils/build-script-impl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ KNOWN_SETTINGS=(
225225
only-execute "all" "Only execute the named action (see implementation)"
226226
llvm-lit-args "" "If set, override the lit args passed to LLVM"
227227
llvm-targets-to-build "X86;ARM;AArch64;PowerPC;SystemZ" "The code generators that LLVM should build"
228+
clang-profile-instr-use "" "If set, profile file to use for clang PGO"
228229
build-toolchain-only "" "If set, only build the necessary tools to build an external toolchain"
229230
)
230231

@@ -787,6 +788,12 @@ function set_build_options_for_host() {
787788
-DLLVM_LIT_ARGS="${LLVM_LIT_ARGS}"
788789
)
789790
fi
791+
792+
if [[ "${CLANG_PROFILE_INSTR_USE}" ]]; then
793+
llvm_cmake_options+=(
794+
-DLLVM_PROFDATA_FILE="${CLANG_PROFILE_INSTR_USE}"
795+
)
796+
fi
790797
}
791798

792799
function configure_default_options() {

0 commit comments

Comments
 (0)