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 @@ -1351,9 +1351,13 @@ HelpText<"Enables the global instruction selector">; def fexperimental_isel : Flag<["-"], "fexperimental-isel">, Group, Alias; -defm experimental_new_pass_manager : BooleanMarshalledFFlag<"experimental-new-pass-manager", "CodeGenOpts.ExperimentalNewPassManager", - "static_cast(LLVM_ENABLE_NEW_PASS_MANAGER)", "Enables an experimental new pass manager in LLVM.", - "Disables an experimental new pass manager in LLVM.">, Group, Flags<[CC1Option]>; +defm new_pass_manager : BooleanMarshalledFFlag<"new-pass-manager", "CodeGenOpts.ExperimentalNewPassManager", + "static_cast(LLVM_ENABLE_NEW_PASS_MANAGER)", "Use the new pass manager in LLVM", + "Use the legacy pass manager in LLVM">, Group, Flags<[CC1Option]>; +def fexperimental_new_pass_manager : Flag<["-"], "fexperimental-new-pass-manager">, + Group, Flags<[CC1Option]>, Alias; +def fno_experimental_new_pass_manager : Flag<["-"], "fno-experimental-new-pass-manager">, + Group, Flags<[CC1Option]>, Alias; def fexperimental_strict_floating_point : Flag<["-"], "fexperimental-strict-floating-point">, Group, Flags<[CC1Option]>, HelpText<"Enables experimental strict floating point in LLVM.">, diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5835,8 +5835,8 @@ false)) CmdArgs.push_back("-fmodules-debuginfo"); - Args.AddLastArg(CmdArgs, options::OPT_fexperimental_new_pass_manager, - options::OPT_fno_experimental_new_pass_manager); + Args.AddLastArg(CmdArgs, options::OPT_fnew_pass_manager, + options::OPT_fno_new_pass_manager); ObjCRuntime Runtime = AddObjCRuntimeArgs(Args, Inputs, CmdArgs, rewriteKind); RenderObjCOptions(TC, D, RawTriple, Args, Runtime, rewriteKind != RK_None, diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -596,8 +596,8 @@ } // Need this flag to turn on new pass manager via Gold plugin. - if (Args.hasFlag(options::OPT_fexperimental_new_pass_manager, - options::OPT_fno_experimental_new_pass_manager, + if (Args.hasFlag(options::OPT_fnew_pass_manager, + options::OPT_fno_new_pass_manager, /* Default */ LLVM_ENABLE_NEW_PASS_MANAGER)) { CmdArgs.push_back("-plugin-opt=new-pass-manager"); } diff --git a/clang/test/Driver/clang_f_opts.c b/clang/test/Driver/clang_f_opts.c --- a/clang/test/Driver/clang_f_opts.c +++ b/clang/test/Driver/clang_f_opts.c @@ -469,10 +469,10 @@ // RUN: %clang -### -fno-experimental-new-pass-manager -fexperimental-new-pass-manager %s 2>&1 | FileCheck --check-prefix=CHECK-PM --check-prefix=CHECK-NEW-PM %s // RUN: %clang -### -fexperimental-new-pass-manager -fno-experimental-new-pass-manager %s 2>&1 | FileCheck --check-prefix=CHECK-PM --check-prefix=CHECK-NO-NEW-PM %s // CHECK-PM-NOT: argument unused -// CHECK-NEW-PM: -fexperimental-new-pass-manager -// CHECK-NEW-PM-NOT: -fno-experimental-new-pass-manager -// CHECK-NO-NEW-PM: -fno-experimental-new-pass-manager -// CHECK-NO-NEW-PM-NOT: -fexperimental-new-pass-manager +// CHECK-NEW-PM: -fnew-pass-manager +// CHECK-NEW-PM-NOT: -fno-new-pass-manager +// CHECK-NO-NEW-PM: -fno-new-pass-manager +// CHECK-NO-NEW-PM-NOT: -fnew-pass-manager // RUN: %clang -### -S -fstrict-return %s 2>&1 | FileCheck -check-prefix=CHECK-STRICT-RETURN %s // RUN: %clang -### -S -fno-strict-return %s 2>&1 | FileCheck -check-prefix=CHECK-NO-STRICT-RETURN %s diff --git a/clang/test/Driver/fnew-pass-manager.c b/clang/test/Driver/fnew-pass-manager.c new file mode 100644 --- /dev/null +++ b/clang/test/Driver/fnew-pass-manager.c @@ -0,0 +1,25 @@ +// RUN: %clang -### -c -fno-new-pass-manager -fnew-pass-manager %s 2>&1 | FileCheck --check-prefixes=NOWARN,NEW %s +// RUN: %clang -### -c -fnew-pass-manager -fno-new-pass-manager %s 2>&1 | FileCheck --check-prefixes=NOWARN,LEGACY %s + +/// -f[no-]experimental-new-pass-manager are legacy aliases when the new PM was still experimental. +// RUN: %clang -### -c -fno-experimental-new-pass-manager -fexperimental-new-pass-manager %s 2>&1 | FileCheck --check-prefixes=NOWARN,NEW %s +// RUN: %clang -### -c -fexperimental-new-pass-manager -fno-experimental-new-pass-manager %s 2>&1 | FileCheck --check-prefixes=NOWARN,LEGACY %s + +// NOWARN-NOT: warning: argument unused + +// NEW: -fnew-pass-manager +// NEW-NOT: -fno-new-pass-manager + +// LEGACY: -fno-new-pass-manager +// LEGACY-NOT: -fnew-pass-manager + +/// For full/Thin LTO, -fnew-pass-manager passes -plugin-opt=new-pass-manager to the linker (which may not be LLD). +// RUN: %clang -### -target x86_64-linux -flto -fnew-pass-manager %s 2>&1 | FileCheck --check-prefixes=NEW_LINK %s +// RUN: %clang -### -target x86_64-linux -flto=thin -fexperimental-new-pass-manager %s 2>&1 | FileCheck --check-prefixes=NEW_LINK %s + +// NEW_LINK: "-plugin-opt=new-pass-manager" + +/// TODO Add the negative option and pass it to the linker. +// RUN: %clang -### -target x86_64 -flto -fno-new-pass-manager %s 2>&1 | FileCheck --check-prefixes=LEGACY_LINK %s + +// LEGACY_LINK-NOT: "-plugin-opt=new-pass-manager" diff --git a/clang/test/Driver/gold-lto-new-pass-man.c b/clang/test/Driver/gold-lto-new-pass-man.c deleted file mode 100644 --- a/clang/test/Driver/gold-lto-new-pass-man.c +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: touch %t.o -// -// RUN: %clang -target ppc64le-unknown-linux -### %t.o -flto 2>&1 \ -// RUN: -Wl,-plugin-opt=foo -O3 \ -// RUN: -fexperimental-new-pass-manager \ -// RUN: | FileCheck %s -// CHECK: "-plugin-opt=new-pass-manager"