[PATCH] D117266: [gn build] Add support for building using propellor
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 14 10:26:58 PST 2022
aeubanks updated this revision to Diff 400062.
aeubanks added a comment.
add support for PGO
address comments
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D117266/new/
https://reviews.llvm.org/D117266
Files:
llvm/utils/gn/build/BUILD.gn
llvm/utils/gn/build/buildflags.gni
Index: llvm/utils/gn/build/buildflags.gni
===================================================================
--- llvm/utils/gn/build/buildflags.gni
+++ llvm/utils/gn/build/buildflags.gni
@@ -22,6 +22,36 @@
# Max jobs per ThinLTO link.
max_jobs_per_lto_link = 8
+
+ # The current PGO phase.
+ # 0: No PGO.
+ # 1: Build binaries with PGO instrumentation.
+ # 2: Optimize binaries with PGO profile provided via pgo_profile_dir.
+ #
+ # To build with PGO:
+ # 1) Build with `pgo_phase = 1`
+ # 2) Run binary with representative workload, creating *.profraw files
+ # 3) Run `llvm-profdata merge *.profraw -o llvm.profdata`
+ # 4) Build with `pgo_phase = 2` and `pgo_profile_path = "path/to/llvm.profdata"`
+ pgo_phase = 0
+
+ # Path to PGO profile. Only used when pgo_phase = 2.
+ pgo_profile_path = ""
+
+ # The current Propeller phase.
+ # 0: No Propeller.
+ # 1: Build binaries suitable for propeller profile generation.
+ # 2: Optimize binaries with Propeller profiles provided in propeller_profile_dir.
+ #
+ # To build with Propeller:
+ # 1) Build with `propeller_phase = 1`
+ # 2) Run binary with representative workload under `perf record -e cycles:u -j any,u`, creating perf.data
+ # 3) Run `create_llvm_prof --format=propeller --binary=path/to/binary --profile=perf.data --out=cluster.txt --propeller_symorder=symorder.txt` (https://github.com/google/autofdo)
+ # 4) Build with `propeller_phase = 2` and `propeller_profile_dir = path/to/dirwithtxts`
+ propeller_phase = 0
+
+ # Path to propeller profile directory containing cluster.txt and symorder.txt. Only used when propeller_phase = 2.
+ propeller_profile_dir = ""
}
# args that depend on other args must live in a later declare_args() block.
Index: llvm/utils/gn/build/BUILD.gn
===================================================================
--- llvm/utils/gn/build/BUILD.gn
+++ llvm/utils/gn/build/BUILD.gn
@@ -373,6 +373,42 @@
}
}
+ if (pgo_phase != 0) {
+ assert(is_clang && current_os == "linux",
+ "PGO only supported on Linux/Clang")
+ if (pgo_phase == 1) {
+ cflags += [ "-fprofile-generate" ]
+ ldflags += [ "-fprofile-generate" ]
+ } else {
+ assert(pgo_phase == 2, "pgo_phase should be 0, 1, or 2")
+ assert(pgo_profile_path != "", "Need pgo_profile_path for pgo_phase = 2")
+ cflags += [ "-fprofile-instr-use=" + pgo_profile_path ]
+ }
+ }
+
+ if (propeller_phase != 0) {
+ assert(is_clang && current_os == "linux",
+ "Propeller only supported on Linux/Clang")
+ if (propeller_phase == 1) {
+ cflags += [
+ "-funique-internal-linkage-names",
+ "-fbasic-block-sections=labels",
+ ]
+ } else {
+ assert(propeller_phase == 2, "propeller_phase should be 0, 1, or 2")
+ assert(propeller_profile_dir != "",
+ "Need propeller_profile_dir for propeller_phase = 2")
+ cflags += [
+ "-funique-internal-linkage-names",
+ "-fbasic-block-sections=list=" + propeller_profile_dir + "/cluster.txt",
+ ]
+ ldflags += [
+ "-Wl,--symbol-ordering-file=" + propeller_profile_dir + "/symorder.txt",
+ "-Wl,--no-warn-symbol-ordering",
+ ]
+ }
+ }
+
cflags_objcc = cflags_cc
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117266.400062.patch
Type: text/x-patch
Size: 3252 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220114/c1de3122/attachment.bin>
More information about the llvm-commits
mailing list