diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -267,32 +267,26 @@ : KeyPathAndMacro<"MigratorOpts.", base, "MIGRATOR_"> {} // A boolean option which is opt-in in CC1. The positive option exists in CC1 and -// Args.hasArg(OPT_ffoo) is used to check that the flag is enabled. +// Args.hasArg(OPT_ffoo) can be used to check that the flag is enabled. // This is useful if the option is usually disabled. +// Use this only when the option cannot be declared via BoolFOption. multiclass OptInFFlag flags=[], - KeyPathAndMacro kpm = EmptyKPM, - list enablers = []> { + string help="", list flags=[]> { def f#NAME : Flag<["-"], "f"#name>, Flags, - Group, HelpText, - MarshallingInfoFlag, - ImpliedByAnyOf; + Group, HelpText; def fno_#NAME : Flag<["-"], "fno-"#name>, Flags, - Group, HelpText; + Group, HelpText; } // A boolean option which is opt-out in CC1. The negative option exists in CC1 and -// Args.hasArg(OPT_fno_foo) is used to check that the flag is disabled. +// Args.hasArg(OPT_fno_foo) can be used to check that the flag is disabled. +// Use this only when the option cannot be declared via BoolFOption. multiclass OptOutFFlag flags=[], - KeyPathAndMacro kpm = EmptyKPM, - list disablers = []> { + string help="", list flags=[]> { def f#NAME : Flag<["-"], "f"#name>, Flags, Group, HelpText; def fno_#NAME : Flag<["-"], "fno-"#name>, Flags, - Group, HelpText, - MarshallingInfoFlag, - ImpliedByAnyOf; + Group, HelpText; } //===----------------------------------------------------------------------===// @@ -891,9 +885,10 @@ NegFlag>; def : Flag<["-"], "fcuda-rdc">, Alias; def : Flag<["-"], "fno-cuda-rdc">, Alias; -defm cuda_short_ptr : OptInFFlag<"cuda-short-ptr", - "Use 32-bit pointers for accessing const/local/shared address spaces", "", "", - [], TargetOpts<"NVPTXUseShortPointers">>; +defm cuda_short_ptr : BoolFOption<"cuda-short-ptr", + TargetOpts<"NVPTXUseShortPointers">, DefaultFalse, + PosFlag, + NegFlag>; def rocm_path_EQ : Joined<["--"], "rocm-path=">, Group, HelpText<"ROCm installation path, used for finding and automatically linking required bitcode libraries.">; def rocm_device_lib_path_EQ : Joined<["--"], "rocm-device-lib-path=">, Group, @@ -1379,8 +1374,11 @@ Values<"ignore,maytrap,strict">, NormalizedValuesScope<"LangOptions">, NormalizedValues<["FPE_Ignore", "FPE_MayTrap", "FPE_Strict"]>, MarshallingInfoEnum, "FPE_Ignore">; -defm fast_math : OptInFFlag<"fast-math", "Allow aggressive, lossy floating-point optimizations", "", "", [], - LangOpts<"FastMath">, [cl_fast_relaxed_math.KeyPath]>; +defm fast_math : BoolFOption<"fast-math", + LangOpts<"FastMath">, DefaultFalse, + PosFlag, + NegFlag>; def menable_unsafe_fp_math : Flag<["-"], "menable-unsafe-fp-math">, Flags<[CC1Option]>, HelpText<"Allow unsafe floating-point math optimizations which may decrease precision">, MarshallingInfoFlag>, @@ -1397,7 +1395,10 @@ CodeGenOpts<"NoUseJumpTables">, DefaultFalse, NegFlag, PosFlag, BothFlags<[], " jump tables for lowering switches">>; -defm force_enable_int128 : OptInFFlag<"force-enable-int128", "Enable", "Disable", " support for int128_t type", [], TargetOpts<"ForceEnableInt128">>; +defm force_enable_int128 : BoolFOption<"force-enable-int128", + TargetOpts<"ForceEnableInt128">, DefaultFalse, + PosFlag, NegFlag, + BothFlags<[], " support for int128_t type">>; defm keep_static_consts : BoolFOption<"keep-static-consts", CodeGenOpts<"KeepStaticConsts">, DefaultFalse, PosFlag, NegFlag, @@ -1604,12 +1605,17 @@ Group; def fassociative_math : Flag<["-"], "fassociative-math">, Group; def fno_associative_math : Flag<["-"], "fno-associative-math">, Group; -defm reciprocal_math : OptInFFlag<"reciprocal-math", "Allow division operations to be reassociated", "", "", [], - LangOpts<"AllowRecip">, [menable_unsafe_fp_math.KeyPath]>; +defm reciprocal_math : BoolFOption<"reciprocal-math", + LangOpts<"AllowRecip">, DefaultFalse, + PosFlag, + NegFlag>; def fapprox_func : Flag<["-"], "fapprox-func">, Group, Flags<[CC1Option, NoDriverOption]>, MarshallingInfoFlag>, ImpliedByAnyOf<[menable_unsafe_fp_math.KeyPath]>; -defm finite_math_only : OptInFFlag<"finite-math-only", "", "", "", [], - LangOpts<"FiniteMathOnly">, [cl_finite_math_only.KeyPath, ffast_math.KeyPath]>; +defm finite_math_only : BoolFOption<"finite-math-only", + LangOpts<"FiniteMathOnly">, DefaultFalse, + PosFlag, + NegFlag>; defm signed_zeros : BoolFOption<"signed-zeros", LangOpts<"NoSignedZero">, DefaultFalse, NegFlag, AliasArgs<["full"]>, HelpText<"Enable cf-protection in 'full' mode">; -defm xray_instrument : OptInFFlag<"xray-instrument", "Generate XRay instrumentation sleds on function entry and exit", "", "", [], LangOpts<"XRayInstrument">>; +defm xray_instrument : BoolFOption<"xray-instrument", + LangOpts<"XRayInstrument">, DefaultFalse, + PosFlag, + NegFlag>; def fxray_instruction_threshold_EQ : JoinedOrSeparate<["-"], "fxray-instruction-threshold=">, @@ -1765,16 +1774,29 @@ Group, Flags<[CC1Option]>, HelpText<"List of modes to link in by default into XRay instrumented binaries.">; -defm xray_always_emit_customevents : OptInFFlag<"xray-always-emit-customevents", - "Always emit __xray_customevent(...) calls even if the containing function is not always instrumented", "", "", [], LangOpts<"XRayAlwaysEmitCustomEvents">>; +defm xray_always_emit_customevents : BoolFOption<"xray-always-emit-customevents", + LangOpts<"XRayAlwaysEmitCustomEvents">, DefaultFalse, + PosFlag, + NegFlag>; -defm xray_always_emit_typedevents : OptInFFlag<"xray-always-emit-typedevents", - "Always emit __xray_typedevent(...) calls even if the containing function is not always instrumented", "", "", [], LangOpts<"XRayAlwaysEmitTypedEvents">>; +defm xray_always_emit_typedevents : BoolFOption<"xray-always-emit-typedevents", + LangOpts<"XRayAlwaysEmitTypedEvents">, DefaultFalse, + PosFlag, + NegFlag>; + +defm xray_ignore_loops : BoolFOption<"xray-ignore-loops", + CodeGenOpts<"XRayIgnoreLoops">, DefaultFalse, + PosFlag, + NegFlag>; -defm xray_ignore_loops : OptInFFlag<"xray-ignore-loops", - "Don't instrument functions with loops unless they also meet the minimum function size", "", "", [], CodeGenOpts<"XRayIgnoreLoops">>; -defm xray_function_index : OptOutFFlag<"xray-function-index", "", - "Omit function index section at the expense of single-function patching performance", "", [], CodeGenOpts<"XRayOmitFunctionIndex">>; +defm xray_function_index : BoolFOption<"xray-function-index", + CodeGenOpts<"XRayOmitFunctionIndex">, DefaultTrue, + NegFlag, + PosFlag>; def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group, Flags<[CC1Option]>, @@ -1906,9 +1928,11 @@ def fprebuilt_module_path : Joined<["-"], "fprebuilt-module-path=">, Group, Flags<[NoXarchOption, CC1Option]>, MetaVarName<"">, HelpText<"Specify the prebuilt module path">; -defm prebuilt_implicit_modules : OptInFFlag<"prebuilt-implicit-modules", - "Look up implicit modules in the prebuilt module path", "", "", - [NoXarchOption, CC1Option], HeaderSearchOpts<"EnablePrebuiltImplicitModules">>; +defm prebuilt_implicit_modules : BoolFOption<"prebuilt-implicit-modules", + HeaderSearchOpts<"EnablePrebuiltImplicitModules">, DefaultFalse, + PosFlag, + NegFlag, BothFlags<[NoXarchOption, CC1Option]>>; + def fmodules_prune_interval : Joined<["-"], "fmodules-prune-interval=">, Group, Flags<[CC1Option]>, MetaVarName<"">, HelpText<"Specify the interval (in seconds) between attempts to prune the module cache">, @@ -2110,9 +2134,10 @@ defm objc_convert_messages_to_runtime_calls : BoolFOption<"objc-convert-messages-to-runtime-calls", CodeGenOpts<"ObjCConvertMessagesToRuntimeCalls">, DefaultTrue, NegFlag, PosFlag>; -defm objc_arc_exceptions : OptInFFlag<"objc-arc-exceptions", - "Use EH-safe code when synthesizing retains and releases in -fobjc-arc", - "", "", [], CodeGenOpts<"ObjCAutoRefCountExceptions">>; +defm objc_arc_exceptions : BoolFOption<"objc-arc-exceptions", + CodeGenOpts<"ObjCAutoRefCountExceptions">, DefaultFalse, + PosFlag, + NegFlag>; def fobjc_atdefs : Flag<["-"], "fobjc-atdefs">, Group; def fobjc_call_cxx_cdtors : Flag<["-"], "fobjc-call-cxx-cdtors">, Group; defm objc_exceptions : BoolFOption<"objc-exceptions", @@ -2561,7 +2586,10 @@ CodeGenOpts<"NoZeroInitializedInBSS">, DefaultFalse, NegFlag, PosFlag>; -defm function_sections : OptInFFlag<"function-sections", "Place each function in its own section">; +defm function_sections : BoolFOption<"function-sections", + CodeGenOpts<"FunctionSections">, DefaultFalse, + PosFlag, + NegFlag>; def fbasic_block_sections_EQ : Joined<["-"], "fbasic-block-sections=">, Group, Flags<[CC1Option, CC1AsOption]>, HelpText<"Place each function's basic blocks in unique sections (ELF Only) : all | labels | none | list=">, diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1383,9 +1383,6 @@ GenerateArg(Args, OPT_ftime_report, SA); } - if (Opts.FunctionSections) - GenerateArg(Args, OPT_ffunction_sections, SA); - if (Opts.PrepareForLTO && !Opts.PrepareForThinLTO) GenerateArg(Args, OPT_flto, SA); @@ -1676,9 +1673,6 @@ } } - // Basic Block Sections implies Function Sections. - Opts.FunctionSections = Args.hasArg(OPT_ffunction_sections); - Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ); Opts.PrepareForThinLTO = false; if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {