Skip to content

Commit bfe7353

Browse files
committed
gh-xxxx: move BOLT arguments to configure
This allows easily customizing the arguments to `llvm-bolt` without having to edit the Makefile. Arguments can be passed to configure and are reflected in configure output, which can be useful for log analysis. When defined in the Makefile we use `?=` syntax so the flags can be overridden via `make VAR=VALUE` syntax or via environment variables. Super useful for iterating on different BOLT flags.
1 parent c003dcb commit bfe7353

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

Makefile.pre.in

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,9 @@ profile-pgo-apply-stamp: profile-pgo-analyze-stamp
695695
# List of binaries that BOLT runs on.
696696
BOLT_BINARIES = $(BUILDPYTHON)
697697

698+
BOLT_INSTRUMENT_FLAGS ?= @BOLT_INSTRUMENT_FLAGS@
699+
BOLT_APPLY_FLAGS ?= @BOLT_APPLY_FLAGS@
700+
698701
# Remove traces of bolt.
699702
.PHONY: clean-bolt
700703
clean-bolt:
@@ -728,7 +731,7 @@ profile-bolt-instrument-stamp: profile-bolt-prebuild-stamp
728731
done
729732
# Ensure prior BOLT state is purged.
730733
$(MAKE) clean-bolt
731-
@LLVM_BOLT@ ./$(BUILDPYTHON) -instrument -instrumentation-file-append-pid -instrumentation-file=$(abspath $(BUILDPYTHON).bolt) -o $(BUILDPYTHON).bolt_inst
734+
@LLVM_BOLT@ ./$(BUILDPYTHON) -instrument -instrumentation-file-append-pid -instrumentation-file=$(abspath $(BUILDPYTHON).bolt) -o $(BUILDPYTHON).bolt_inst $(BOLT_INSTRUMENT_FLAGS)
732735
touch $@
733736

734737
profile-bolt-run-stamp: profile-bolt-instrument-stamp
@@ -740,7 +743,7 @@ profile-bolt-analyze-stamp: profile-bolt-run-stamp
740743
touch $@
741744

742745
profile-bolt-apply-stamp: profile-bolt-analyze-stamp
743-
@LLVM_BOLT@ ./$(BUILDPYTHON) -o $(BUILDPYTHON).bolt -data=$(BUILDPYTHON).fdata -update-debug-sections -reorder-blocks=ext-tsp -reorder-functions=hfsort+ -split-functions=3 -icf=1 -inline-all -split-eh -reorder-functions-use-hot-size -peepholes=all -jump-tables=aggressive -inline-ap -indirect-call-promotion=all -dyno-stats -use-gnu-stack -frame-opt=hot
746+
@LLVM_BOLT@ ./$(BUILDPYTHON) -o $(BUILDPYTHON).bolt -data=$(BUILDPYTHON).fdata $(BOLT_APPLY_FLAGS)
744747
mv $(BUILDPYTHON) $(BUILDPYTHON).prebolt
745748
mv $(BUILDPYTHON).bolt $(BUILDPYTHON)
746749
touch $@

configure

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,6 +2066,22 @@ if test "$Py_BOLT" = 'true' ; then
20662066
fi
20672067
fi
20682068

2069+
AC_ARG_VAR(BOLT_INSTRUMENT_FLAGS, Arguments to llvm-bolt when instrumenting binaries)
2070+
AC_MSG_CHECKING(BOLT_INSTRUMENT_FLAGS)
2071+
if test -z "${BOLT_INSTRUMENT_FLAGS}"
2072+
then
2073+
BOLT_INSTRUMENT_FLAGS=
2074+
fi
2075+
AC_MSG_RESULT($BOLT_INSTRUMENT_FLAGS)
2076+
2077+
AC_ARG_VAR(BOLT_APPLY_FLAGS, Arguments to llvm-bolt when creating a BOLT optimized binary)
2078+
AC_MSG_CHECKING(BOLT_APPLY_FLAGS)
2079+
if test -z "${BOLT_APPLY_FLAGS}"
2080+
then
2081+
BOLT_APPLY_FLAGS="-update-debug-sections -reorder-blocks=ext-tsp -reorder-functions=hfsort+ -split-functions=3 -icf=1 -inline-all -split-eh -reorder-functions-use-hot-size -peepholes=all -jump-tables=aggressive -inline-ap -indirect-call-promotion=all -dyno-stats -use-gnu-stack -frame-opt=hot"
2082+
fi
2083+
AC_MSG_RESULT($BOLT_APPLY_FLAGS)
2084+
20692085
# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
20702086
# merged with this chunk of code?
20712087

0 commit comments

Comments
 (0)