================
@@ -3564,9 +3564,10 @@ void tools::handleVectorizeSLPArgs(const ArgList &Args,
 
 void tools::handleInterchangeLoopsArgs(const ArgList &Args,
                                        ArgStringList &CmdArgs) {
-  if (Args.hasFlag(options::OPT_floop_interchange,
-                   options::OPT_fno_loop_interchange, false))
-    CmdArgs.push_back("-floop-interchange");
+  // Forward the user's explicit choice; the frontend applies the -O3
+  // default when neither flag is present.
+  Args.AddLastArg(CmdArgs, options::OPT_floop_interchange,
+                  options::OPT_fno_loop_interchange);
----------------
madhur13490 wrote:

Yes, it's necessary for the Flang path. This helper is only called by the Flang 
driver (Flang.cpp), and with this PR the -O3 default is now applied in the 
frontend (-fc1). For the frontend to honor an explicit -fno-loop-interchange at 
-O3, the driver has to forward the negative flag as well.

The previous code used `hasFlag(..., /*Default=*/false)` and only pushed 
`-floop-interchange`, so `-fno-loop-interchange` was never forwarded to -fc1. 
That would make -O3 -fno-loop-interchange silently keep interchange enabled. 
Switching to `AddLastArg` forwards whichever of the two flags the user actually 
passed, and it mirrors what the Clang driver already does for the same options 
in Clang.cpp.

https://github.com/llvm/llvm-project/pull/216920
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to