Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1034,7 +1034,7 @@ HelpText<"Don't use __cxa_atexit for calling destructors">; def fno_use_init_array : Flag<["-"], "fno-use-init-array">, Group, Flags<[CC1Option]>, HelpText<"Don't use .init_array instead of .ctors">; -def fno_unit_at_a_time : Flag<["-"], "fno-unit-at-a-time">, Group; +def fno_unit_at_a_time : Flag<["-"], "fno-unit-at-a-time">, Group, Flags<[CC1Option]>; def fno_unwind_tables : Flag<["-"], "fno-unwind-tables">, Group; def fno_verbose_asm : Flag<["-"], "fno-verbose-asm">, Group; def fno_working_directory : Flag<["-"], "fno-working-directory">, Group; @@ -1242,7 +1242,7 @@ def ftrapv_handler : Separate<["-"], "ftrapv-handler">, Group, Flags<[CC1Option]>; def ftrap_function_EQ : Joined<["-"], "ftrap-function=">, Group, Flags<[CC1Option]>, HelpText<"Issue call to specified function rather than a trap instruction">; -def funit_at_a_time : Flag<["-"], "funit-at-a-time">, Group; +def funit_at_a_time : Flag<["-"], "funit-at-a-time">, Group, Flags<[CC1Option]>; def funroll_loops : Flag<["-"], "funroll-loops">, Group, HelpText<"Turn on loop unroller">, Flags<[CC1Option]>; def fno_unroll_loops : Flag<["-"], "fno-unroll-loops">, Group, Index: include/clang/Frontend/CodeGenOptions.def =================================================================== --- include/clang/Frontend/CodeGenOptions.def +++ include/clang/Frontend/CodeGenOptions.def @@ -211,6 +211,8 @@ CODEGENOPT(WholeProgramVTables, 1, 0) ///< Whether to apply whole-program /// vtable optimization. +CODEGENOPT(UnitAtTime, 1, 1) ///< Whether to use IPO. + /// Whether to use public LTO visibility for entities in std and stdext /// namespaces. This is enabled by clang-cl's /MT and /MTd flags. CODEGENOPT(LTOVisibilityPublicStd, 1, 0) Index: lib/CodeGen/BackendUtil.cpp =================================================================== --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -332,6 +332,8 @@ PMBuilder.PrepareForLTO = CodeGenOpts.PrepareForLTO; PMBuilder.RerollLoops = CodeGenOpts.RerollLoops; + PMBuilder.DisableUnitAtATime = !CodeGenOpts.UnitAtTime; + // Add target-specific passes that need to run as early as possible. if (TM) PMBuilder.addExtension( Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -6193,13 +6193,8 @@ CmdArgs.push_back("-fno-dollars-in-identifiers"); } - // -funit-at-a-time is default, and we don't support -fno-unit-at-a-time for - // practical purposes. - if (Arg *A = Args.getLastArg(options::OPT_funit_at_a_time, - options::OPT_fno_unit_at_a_time)) { - if (A->getOption().matches(options::OPT_fno_unit_at_a_time)) - D.Diag(diag::warn_drv_clang_unsupported) << A->getAsString(Args); - } + Args.AddLastArg(CmdArgs, options::OPT_funit_at_a_time, + options::OPT_fno_unit_at_a_time); if (Args.hasFlag(options::OPT_fapple_pragma_pack, options::OPT_fno_apple_pragma_pack, false)) Index: lib/Frontend/CompilerInvocation.cpp =================================================================== --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -497,6 +497,8 @@ Opts.DebugColumnInfo = Args.hasArg(OPT_dwarf_column_info); Opts.EmitCodeView = Args.hasArg(OPT_gcodeview); Opts.WholeProgramVTables = Args.hasArg(OPT_fwhole_program_vtables); + Opts.UnitAtTime = Args.hasFlag(OPT_funit_at_a_time, + OPT_fno_unit_at_a_time, true); Opts.LTOVisibilityPublicStd = Args.hasArg(OPT_flto_visibility_public_std); Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file); Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining); Index: test/Driver/clang_f_opts.c =================================================================== --- test/Driver/clang_f_opts.c +++ test/Driver/clang_f_opts.c @@ -286,6 +286,8 @@ // RUN: -malign-functions=100 \ // RUN: -malign-loops=100 \ // RUN: -malign-jumps=100 \ +// RUN: -funit-at-a-time \ +// RUN: -fno-unit-at-a-time \ // RUN: %s 2>&1 | FileCheck --check-prefix=IGNORE %s // IGNORE-NOT: error: unknown argument