diff --git a/libcxx/utils/libcxx/test/dsl.py b/libcxx/utils/libcxx/test/dsl.py index 9a97e61efbe7d..63fb580923467 100644 --- a/libcxx/utils/libcxx/test/dsl.py +++ b/libcxx/utils/libcxx/test/dsl.py @@ -511,6 +511,28 @@ def pretty(self, config, litParams): return "add {} to %{{compile_flags}}".format(self._getFlag(config)) +class AddBenchmarkCompileFlag(ConfigAction): + """ + This action adds the given flag to the %{benchmark_flags} substitution. + + The flag can be a string or a callable, in which case it is called with the + configuration to produce the actual flag (as a string). + """ + + def __init__(self, flag): + self._getFlag = lambda config: flag(config) if callable(flag) else flag + + def applyTo(self, config): + flag = self._getFlag(config) + _ensureFlagIsSupported(config, flag) + config.substitutions = _appendToSubstitution( + config.substitutions, "%{benchmark_flags}", flag + ) + + def pretty(self, config, litParams): + return "add {} to %{{benchmark_flags}}".format(self._getFlag(config)) + + class AddLinkFlag(ConfigAction): """ This action appends the given flag to the %{link_flags} substitution. diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py index 93dc3a8be3f08..512531f59f343 100644 --- a/libcxx/utils/libcxx/test/params.py +++ b/libcxx/utils/libcxx/test/params.py @@ -195,11 +195,12 @@ def getSuitableClangTidy(cfg): ), Parameter( name="optimization", - choices=["none", "speed", "size"], + choices=["default", "none", "speed", "size"], type=str, help="The optimization level to use when compiling the test suite.", - default="none", + default="default", # defaults, test -> none, benchmarks -> speed actions=lambda opt: filter(None, [ + AddBenchmarkCompileFlag(lambda cfg: getSpeedOptimizationFlag(cfg)) if opt == "default" else None, AddCompileFlag(lambda cfg: getSpeedOptimizationFlag(cfg)) if opt == "speed" else None, AddCompileFlag(lambda cfg: getSizeOptimizationFlag(cfg)) if opt == "size" else None, AddFeature(f'optimization={opt}'),