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 @@ -967,8 +967,10 @@ MetaVarName<"">; def c : Flag<["-"], "c">, Flags<[NoXarchOption, FlangOption]>, Group, HelpText<"Only run preprocess, compile, and assemble steps">; -def fconvergent_functions : Flag<["-"], "fconvergent-functions">, Group, Flags<[CC1Option]>, - HelpText<"Assume functions may be convergent">; +defm convergent_functions : BoolFOption<"convergent-functions", + LangOpts<"ConvergentFunctions">, DefaultFalse, + NegFlag, + PosFlag>; def gpu_use_aux_triple_only : Flag<["--"], "gpu-use-aux-triple-only">, InternalDriverOpt, HelpText<"Prepare '-aux-triple' only without populating " 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 @@ -5700,6 +5700,8 @@ options::OPT_fno_unique_internal_linkage_names); Args.addOptInFlag(CmdArgs, options::OPT_funique_basic_block_section_names, options::OPT_fno_unique_basic_block_section_names); + Args.addOptInFlag(CmdArgs, options::OPT_fconvergent_functions, + options::OPT_fno_convergent_functions); if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions, options::OPT_fno_split_machine_functions)) { 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 @@ -3731,9 +3731,9 @@ Opts.Blocks = Args.hasArg(OPT_fblocks) || (Opts.OpenCL && Opts.OpenCLVersion == 200); - Opts.ConvergentFunctions = Opts.OpenCL || (Opts.CUDA && Opts.CUDAIsDevice) || - Opts.SYCLIsDevice || - Args.hasArg(OPT_fconvergent_functions); + Opts.ConvergentFunctions = Args.hasArg(OPT_fconvergent_functions) || + Opts.OpenCL || (Opts.CUDA && Opts.CUDAIsDevice) || + Opts.SYCLIsDevice; Opts.NoBuiltin = Args.hasArg(OPT_fno_builtin) || Opts.Freestanding; if (!Opts.NoBuiltin) diff --git a/clang/test/Driver/amdgpu-toolchain.c b/clang/test/Driver/amdgpu-toolchain.c --- a/clang/test/Driver/amdgpu-toolchain.c +++ b/clang/test/Driver/amdgpu-toolchain.c @@ -11,6 +11,6 @@ // DWARF_VER: "-dwarf-version=5" // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \ -// RUN: -flto %s 2>&1 | FileCheck -check-prefix=LTO %s -// LTO: clang{{.*}} "-flto=full" +// RUN: -flto -fconvergent-functions %s 2>&1 | FileCheck -check-prefix=LTO %s +// LTO: clang{{.*}} "-flto=full"{{.*}}"-fconvergent-functions" // LTO: ld.lld{{.*}}-plugin-opt=mcpu=gfx906