[flang-commits] [clang] [flang] [flang] Enable alias tags pass by default (PR #73111)

Andrzej WarzyƄski via flang-commits flang-commits at lists.llvm.org
Thu Nov 23 07:50:27 PST 2023


================
@@ -242,10 +242,24 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
                    clang::driver::options::OPT_fno_loop_versioning, false))
     opts.LoopVersioning = 1;
 
-  opts.AliasAnalysis =
-      args.hasFlag(clang::driver::options::OPT_falias_analysis,
-                   clang::driver::options::OPT_fno_alias_analysis,
-                   /*default=*/false);
+  bool aliasAnalysis = false;
+  bool noAliasAnalysis = false;
+  if (auto *arg =
+          args.getLastArg(clang::driver::options::OPT_falias_analysis,
+                          clang::driver::options::OPT_fno_alias_analysis)) {
+    if (arg->getOption().matches(clang::driver::options::OPT_falias_analysis))
+      aliasAnalysis = true;
+    else
+      noAliasAnalysis = true;
+  }
+  opts.AliasAnalysis = 0;
+  if (opts.OptimizationLevel > 0) {
+    if (!noAliasAnalysis)
+      opts.AliasAnalysis = 1;
+  } else {
+    if (aliasAnalysis)
+      opts.AliasAnalysis = 1;
+  }
----------------
banach-space wrote:

> I don't really understand how that differs from what I already have

1. It removes the need for `aliasAnalysis` and `noAliasAnalysis`. 
1.1 I also hinted elsewhere (https://github.com/llvm/llvm-project/pull/73111#discussion_r1402712333) that we should only need 1 bool to represent the same logic - an option is either enabled or disabled and one bool should be sufficient to represent that. 
1.2 Fewer variables leads to lower cognitive load, which is preferred.
2. No nested `if`s are required (i.e. `if (opts.OptimizationLevel > 0) { if (!noAliasAnalysis)) {}}`).
3. The logic for processing optimization options (e.g. `-O4`) and alias analysis options (e.g. `-falias-analysis`) is clearly separated.
4. From what I can tell, the number of source lines drops (though hard to tell for sure with GitHub's formatting).

I might be missing something though, so please correct me if I'm wrong and what I'm proposing wouldn't work.

https://github.com/llvm/llvm-project/pull/73111


More information about the flang-commits mailing list