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 @@ -1162,12 +1162,22 @@ HelpText<"Disable using instrumentation data for profile-guided optimization">; def fno_profile_use : Flag<["-"], "fno-profile-use">, Alias; +defm profile_arcs : BoolFOption<"profile-arcs", + "CodeGenOpts.EmitGcovArcs", DefaultsToFalse, + ChangedBy, ResetBy>; +defm test_coverage : BoolFOption<"test-coverage", + "CodeGenOpts.EmitGcovNotes", DefaultsToFalse, + ChangedBy, ResetBy>; def fprofile_filter_files_EQ : Joined<["-"], "fprofile-filter-files=">, Group, Flags<[CC1Option, CoreOption]>, - HelpText<"Instrument only functions from files where names match any regex separated by a semi-colon">; + HelpText<"Instrument only functions from files where names match any regex separated by a semi-colon">, + MarshallingInfoString<"CodeGenOpts.ProfileFilterFiles">, + ShouldParseIf; def fprofile_exclude_files_EQ : Joined<["-"], "fprofile-exclude-files=">, Group, Flags<[CC1Option, CoreOption]>, - HelpText<"Instrument only functions from files where names don't match all the regexes separated by a semi-colon">; + HelpText<"Instrument only functions from files where names don't match all the regexes separated by a semi-colon">, + MarshallingInfoString<"CodeGenOpts.ProfileExcludeFiles">, + ShouldParseIf; def fprofile_update_EQ : Joined<["-"], "fprofile-update=">, Group, Flags<[CC1Option, CoreOption]>, Values<"atomic,prefer-atomic,single">, MetaVarName<"">, HelpText<"Set update method of profile counters (atomic,prefer-atomic,single)">, @@ -1318,9 +1328,10 @@ def femit_all_decls : Flag<["-"], "femit-all-decls">, Group, Flags<[CC1Option]>, HelpText<"Emit all declarations, even if unused">, MarshallingInfoFlag<"LangOpts->EmitAllDecls">; -def femulated_tls : Flag<["-"], "femulated-tls">, Group, Flags<[CC1Option]>, - HelpText<"Use emutls functions to access thread_local variables">; -def fno_emulated_tls : Flag<["-"], "fno-emulated-tls">, Group, Flags<[CC1Option]>; +defm emulated_tls : BoolFOption<"emulated-tls", + "CodeGenOpts.EmulatedTLS", DefaultsToFalse, + ChangedBy, + ResetBy, BothFlags<[CC1Option]>>; def fencoding_EQ : Joined<["-"], "fencoding=">, Group; def ferror_limit_EQ : Joined<["-"], "ferror-limit=">, Group, Flags<[CoreOption]>; defm exceptions : BoolFOption<"exceptions", @@ -1759,12 +1770,14 @@ def fxray_function_groups : Joined<["-"], "fxray-function-groups=">, Group, Flags<[CC1Option]>, - HelpText<"Only instrument 1 of N groups">; + HelpText<"Only instrument 1 of N groups">, + MarshallingInfoStringInt<"CodeGenOpts.XRayTotalFunctionGroups", "1">; def fxray_selected_function_group : Joined<["-"], "fxray-selected-function-group=">, Group, Flags<[CC1Option]>, - HelpText<"When using -fxray-function-groups, select which group of functions to instrument. Valid range is 0 to fxray-function-groups - 1">; + HelpText<"When using -fxray-function-groups, select which group of functions to instrument. Valid range is 0 to fxray-function-groups - 1">, + MarshallingInfoStringInt<"CodeGenOpts.XRaySelectedFunctionGroup", "0">; defm fine_grained_bitfield_accesses : BoolOption<"fine-grained-bitfield-accesses", @@ -2223,9 +2236,6 @@ "CodeGenOpts.PreserveAsmComments", DefaultsToTrue, ChangedBy, ResetBy>; -defm profile_arcs : BoolFOption<"profile-arcs", - "CodeGenOpts.EmitGcovArcs", DefaultsToFalse, - ChangedBy, ResetBy>; def framework : Separate<["-"], "framework">, Flags<[LinkerInput]>; def frandom_seed_EQ : Joined<["-"], "frandom-seed=">, Group; def freg_struct_return : Flag<["-"], "freg-struct-return">, Group, Flags<[CC1Option]>, @@ -2348,9 +2358,6 @@ HelpText<"Only include passes which match a specified regular expression in the generated optimization record (by default, include all passes)">, MetaVarName<"">; -defm test_coverage : BoolFOption<"test-coverage", - "CodeGenOpts.EmitGcovNotes", DefaultsToFalse, - ChangedBy, ResetBy>; def fvectorize : Flag<["-"], "fvectorize">, Group, HelpText<"Enable the loop vectorization passes">; def fno_vectorize : Flag<["-"], "fno-vectorize">, Group; @@ -2600,7 +2607,8 @@ def gdwarf_5 : Flag<["-"], "gdwarf-5">, Group, HelpText<"Generate source-level debug information with dwarf version 5">; def gdwarf64 : Flag<["-"], "gdwarf64">, Group, Flags<[CC1Option]>, - HelpText<"Enables DWARF64 format for ELF binaries, if debug information emission is enabled.">; + HelpText<"Enables DWARF64 format for ELF binaries, if debug information emission is enabled.">, + MarshallingInfoFlag<"CodeGenOpts.Dwarf64">; def gdwarf32 : Flag<["-"], "gdwarf32">, Group, Flags<[CC1Option]>, HelpText<"Enables DWARF32 format for ELF binaries, if debug information emission is enabled.">; @@ -3172,11 +3180,14 @@ HelpText<"Specifies preferred vector width for auto-vectorization. Defaults to 'none' which allows target specific decisions.">, MarshallingInfoString<"CodeGenOpts.PreferVectorWidth">; def mstack_protector_guard_EQ : Joined<["-"], "mstack-protector-guard=">, Group, Flags<[CC1Option]>, - HelpText<"Use the given guard (global, tls) for addressing the stack-protector guard">; + HelpText<"Use the given guard (global, tls) for addressing the stack-protector guard">, + MarshallingInfoString<"CodeGenOpts.StackProtectorGuard">; def mstack_protector_guard_offset_EQ : Joined<["-"], "mstack-protector-guard-offset=">, Group, Flags<[CC1Option]>, - HelpText<"Use the given offset for addressing the stack-protector guard">; + HelpText<"Use the given offset for addressing the stack-protector guard">, + MarshallingInfoStringInt<"CodeGenOpts.StackProtectorGuardOffset", "(unsigned)-1">; def mstack_protector_guard_reg_EQ : Joined<["-"], "mstack-protector-guard-reg=">, Group, Flags<[CC1Option]>, - HelpText<"Use the given reg for addressing the stack-protector guard">; + HelpText<"Use the given reg for addressing the stack-protector guard">, + MarshallingInfoString<"CodeGenOpts.StackProtectorGuardReg", [{"none"}]>; def mpie_copy_relocations : Flag<["-"], "mpie-copy-relocations">, Alias, Group; def mno_pie_copy_relocations : Flag<["-"], "mno-pie-copy-relocations">, @@ -4385,7 +4396,9 @@ HelpText<"The string to embed in the .LLVM.command.line section.">, MarshallingInfoString<"CodeGenOpts.RecordCommandLine">; def compress_debug_sections_EQ : Joined<["-", "--"], "compress-debug-sections=">, - HelpText<"DWARF debug sections compression type">; + HelpText<"DWARF debug sections compression type">, Values<"none,zlib,zlib-gnu">, + NormalizedValuesScope<"llvm::DebugCompressionType">, NormalizedValues<["None", "Z", "GNU"]>, + MarshallingInfoString<"CodeGenOpts.CompressDebugSections", "None">, AutoNormalizeEnum; def compress_debug_sections : Flag<["-", "--"], "compress-debug-sections">, Alias, AliasArgs<["zlib"]>; def mno_exec_stack : Flag<["-"], "mnoexecstack">, @@ -4462,11 +4475,15 @@ HelpText<"Permit merging of identical functions when optimizing.">, MarshallingInfoFlag<"CodeGenOpts.MergeFunctions">; def coverage_data_file : Separate<["-"], "coverage-data-file">, - HelpText<"Emit coverage data to this filename.">; + HelpText<"Emit coverage data to this filename.">, + MarshallingInfoString<"CodeGenOpts.CoverageDataFile">, + ShouldParseIf; def coverage_data_file_EQ : Joined<["-"], "coverage-data-file=">, Alias; def coverage_notes_file : Separate<["-"], "coverage-notes-file">, - HelpText<"Emit coverage notes to this filename.">; + HelpText<"Emit coverage notes to this filename.">, + MarshallingInfoString<"CodeGenOpts.CoverageNotesFile">, + ShouldParseIf; def coverage_notes_file_EQ : Joined<["-"], "coverage-notes-file=">, Alias; def coverage_version_EQ : Joined<["-"], "coverage-version=">, 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 @@ -991,7 +991,6 @@ setPGOUseInstrumentor(Opts, Opts.ProfileInstrumentUsePath); Opts.CodeModel = TargetOpts.CodeModel; - Opts.Dwarf64 = Args.hasArg(OPT_gdwarf64); if (const Arg *A = Args.getLastArg(OPT_ftime_report, OPT_ftime_report_EQ)) { Opts.TimePasses = true; @@ -1051,14 +1050,6 @@ Opts.MemoryProfileOutput = MemProfileBasename; if (Opts.EmitGcovArcs || Opts.EmitGcovNotes) { - Opts.CoverageDataFile = - std::string(Args.getLastArgValue(OPT_coverage_data_file)); - Opts.CoverageNotesFile = - std::string(Args.getLastArgValue(OPT_coverage_notes_file)); - Opts.ProfileFilterFiles = - std::string(Args.getLastArgValue(OPT_fprofile_filter_files_EQ)); - Opts.ProfileExcludeFiles = - std::string(Args.getLastArgValue(OPT_fprofile_exclude_files_EQ)); if (Args.hasArg(OPT_coverage_version_EQ)) { StringRef CoverageVersion = Args.getLastArgValue(OPT_coverage_version_EQ); if (CoverageVersion.size() != 4) { @@ -1091,11 +1082,6 @@ } } - Opts.XRayTotalFunctionGroups = - getLastArgIntValue(Args, OPT_fxray_function_groups, 1, Diags); - Opts.XRaySelectedFunctionGroup = - getLastArgIntValue(Args, OPT_fxray_selected_function_group, 0, Diags); - auto XRayInstrBundles = Args.getAllArgValues(OPT_fxray_instrumentation_bundle); if (XRayInstrBundles.empty()) @@ -1120,15 +1106,6 @@ } } - if (const Arg *A = Args.getLastArg(OPT_compress_debug_sections_EQ)) { - auto DCT = llvm::StringSwitch(A->getValue()) - .Case("none", llvm::DebugCompressionType::None) - .Case("zlib", llvm::DebugCompressionType::Z) - .Case("zlib-gnu", llvm::DebugCompressionType::GNU) - .Default(llvm::DebugCompressionType::None); - Opts.setCompressDebugSections(DCT); - } - for (auto *A : Args.filtered(OPT_mlink_bitcode_file, OPT_mlink_builtin_bitcode)) { CodeGenOptions::BitcodeFileToLink F; @@ -1143,26 +1120,9 @@ Opts.LinkBitcodeFiles.push_back(F); } - Opts.StackProtectorGuard = - std::string(Args.getLastArgValue(OPT_mstack_protector_guard_EQ)); - - if (Arg *A = Args.getLastArg(OPT_mstack_protector_guard_offset_EQ)) { - StringRef Val = A->getValue(); - unsigned Offset = Opts.StackProtectorGuardOffset; - Val.getAsInteger(10, Offset); - Opts.StackProtectorGuardOffset = Offset; - } - - Opts.StackProtectorGuardReg = - std::string(Args.getLastArgValue(OPT_mstack_protector_guard_reg_EQ, - "none")); - - if (Args.getLastArg(OPT_femulated_tls) || Args.getLastArg(OPT_fno_emulated_tls)) { Opts.ExplicitEmulatedTLS = true; - Opts.EmulatedTLS = - Args.hasFlag(OPT_femulated_tls, OPT_fno_emulated_tls, false); } if (Arg *A = Args.getLastArg(OPT_fdenormal_fp_math_EQ)) {