in compiler_gym/envs/gcc/gcc.py [0:0]
def _fix_options(options: List[Option]) -> List[Option]:
"""Fixes for things that seem not to be true in the help."""
def keep(option: Option) -> bool:
# Ignore -flive-patching
if isinstance(option, GccFlagEnumOption):
if option.name == "live-patching":
return False
return True
options = [opt for opt in options if keep(opt)]
for i, option in enumerate(options):
if isinstance(option, GccParamIntOption):
# Some things say they can have -1, but can't
if option.name in [
"logical-op-non-short-circuit",
"prefetch-minimum-stride",
"sched-autopref-queue-depth",
"vect-max-peeling-for-alignment",
]:
option.min = 0
elif isinstance(option, GccFlagOption):
# -fhandle-exceptions renamed to -fexceptions
if option.name == "handle-exceptions":
option.name = "exceptions"
# Some flags have no -fno- version
if option.name in [
"stack-protector-all",
"stack-protector-explicit",
"stack-protector-strong",
]:
option.no_fno = True
# -fno-threadsafe-statics should have the no- removed
if option.name == "no-threadsafe-statics":
option.name = "threadsafe-statics"
elif isinstance(option, GccFlagIntOption):
# -fpack-struct has to be a small positive power of two
if option.name == "pack-struct":
values = [str(1 << j) for j in range(5)]
options[i] = GccFlagEnumOption("pack-struct", values)
return options