diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 0ed17a0f388cd5..e7fded8d54192c 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6842,6 +6842,10 @@ def fno_automatic : Flag<["-"], "fno-automatic">, Group, defm stack_arrays : BoolOptionWithoutMarshalling<"f", "stack-arrays", PosFlag, NegFlag>; + +def fno_add_alias_tags : Flag<["-"], "fno-add-alias-tags">, Group, + HelpText<"Disable adding alias tags">; + defm loop_versioning : BoolOptionWithoutMarshalling<"f", "version-loops-for-stride", PosFlag, NegFlag>; diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index 1675c3fae75b07..2a1b72fc24d035 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -148,6 +148,9 @@ void Flang::addCodegenOptions(const ArgList &Args, if (shouldLoopVersion(Args)) CmdArgs.push_back("-fversion-loops-for-stride"); + if (Args.getLastArg(options::OPT_fno_add_alias_tags)) + CmdArgs.push_back("-fno-add-alias-tags"); + Args.addAllArgs(CmdArgs, {options::OPT_flang_experimental_hlfir, options::OPT_flang_deprecated_no_hlfir, options::OPT_flang_experimental_integer_overflow, diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index d14ac210444f5d..ee53788f53219d 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -271,8 +271,10 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts, if (args.hasFlag(clang::driver::options::OPT_floop_versioning, clang::driver::options::OPT_fno_loop_versioning, false)) opts.LoopVersioning = 1; - - opts.AliasAnalysis = opts.OptimizationLevel > 0; + if (args.getLastArg(clang::driver::options::OPT_fno_add_alias_tags)) + opts.AliasAnalysis = false; + else + opts.AliasAnalysis = opts.OptimizationLevel > 0; // -mframe-pointer=none/non-leaf/all option. if (const llvm::opt::Arg *a =