================ @@ -142,6 +142,24 @@ void Flang::addCodegenOptions(const ArgList &Args, if (shouldLoopVersion(Args)) CmdArgs.push_back("-fversion-loops-for-stride"); + Arg *aliasAnalysis = Args.getLastArg(options::OPT_falias_analysis, + options::OPT_fno_alias_analysis); + Arg *optLevel = + Args.getLastArg(options::OPT_Ofast, options::OPT_O, options::OPT_O4); + if (aliasAnalysis) { + bool faliasAnalysis = + aliasAnalysis->getOption().matches(options::OPT_falias_analysis); + // only pass on the argument if it does not match that implied by the + // optimization level + if (optLevel && !faliasAnalysis) { + CmdArgs.push_back("-fno-alias-analysis"); + } else { + if (faliasAnalysis) + // requested alias analysis but no optimization enabled + CmdArgs.push_back("-falias-analysis"); + } + } ---------------- banach-space wrote:
[nit] It would be worth adding a comment here explaining the intent (e.g. "Only forward `-f{no}-alias-analysis if that makes sense considering other optimisation flags"). Alternatively, you could rename `optLevel` as `optLevelForSpeed` to communicate that. Or both. Just to make things clear for our future selves ;-) https://github.com/llvm/llvm-project/pull/73111 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits