Skip to content

Commit

Permalink
[flang] remove -f[no-]alias-analysis (#74343)
Browse files Browse the repository at this point in the history
Now that tbaa tags pass is enabled by default, I would like to remove
these flags. `-fno-alias-analysis` was originally intended to be useful
for debugging, but as it also disables tbaa tag generation in codegen,
it turned out to be too noisy.

@banach-space expressed that these flags felt too non-standard.

The tbaa tags pass can be toggled using `-mllvm
-disable-fir-alias-tags=0`
  • Loading branch information
tblah committed Dec 5, 2023
1 parent 432bb52 commit 6b8d659
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 45 deletions.
3 changes: 0 additions & 3 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -6344,9 +6344,6 @@ defm stack_arrays : BoolOptionWithoutMarshalling<"f", "stack-arrays",
defm loop_versioning : BoolOptionWithoutMarshalling<"f", "version-loops-for-stride",
PosFlag<SetTrue, [], [ClangOption], "Create unit-strided versions of loops">,
NegFlag<SetFalse, [], [ClangOption], "Do not create unit-strided loops (default)">>;
defm alias_analysis : BoolOptionWithoutMarshalling<"f", "alias-analysis",
PosFlag<SetTrue, [], [], "Pass alias information on to LLVM (default when optimizing for speed)">,
NegFlag<SetFalse, [], [], "Do not pass alias information on to LLVM (default for unoptimized builds)">>;
} // let Visibility = [FC1Option, FlangOption]

def J : JoinedOrSeparate<["-"], "J">,
Expand Down
24 changes: 1 addition & 23 deletions clang/lib/Driver/ToolChains/Flang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,33 +143,11 @@ 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);
// only pass on the argument if it does not match that implied by the
// optimization level: so if optimization is requested, only forward
// -fno-alias-analysis. If optimization is not requested, only forward
// -falias-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);
if (optLevel && !faliasAnalysis) {
CmdArgs.push_back("-fno-alias-analysis");
} else {
if (faliasAnalysis)
// requested alias analysis but no optimization enabled
CmdArgs.push_back("-falias-analysis");
}
}

Args.addAllArgs(CmdArgs, {options::OPT_flang_experimental_hlfir,
options::OPT_flang_deprecated_no_hlfir,
options::OPT_flang_experimental_polymorphism,
options::OPT_fno_ppc_native_vec_elem_order,
options::OPT_fppc_native_vec_elem_order,
options::OPT_falias_analysis,
options::OPT_fno_alias_analysis});
options::OPT_fppc_native_vec_elem_order});
}

void Flang::addPicOptions(const ArgList &Args, ArgStringList &CmdArgs) const {
Expand Down
5 changes: 0 additions & 5 deletions flang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,6 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
opts.LoopVersioning = 1;

opts.AliasAnalysis = opts.OptimizationLevel > 0;
if (auto *arg =
args.getLastArg(clang::driver::options::OPT_falias_analysis,
clang::driver::options::OPT_fno_alias_analysis))
opts.AliasAnalysis =
arg->getOption().matches(clang::driver::options::OPT_falias_analysis);

for (auto *a : args.filtered(clang::driver::options::OPT_fpass_plugin_EQ))
opts.LLVMPassPlugins.push_back(a->getValue());
Expand Down
2 changes: 0 additions & 2 deletions flang/test/Driver/driver-help-hidden.f90
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
! CHECK-NEXT: -D <macro>=<value> Define <macro> to <value> (or 1 if <value> omitted)
! CHECK-NEXT: -emit-llvm Use the LLVM representation for assembler and object files
! CHECK-NEXT: -E Only run the preprocessor
! CHECK-NEXT: -falias-analysis Pass alias information on to LLVM (default when optimizing for speed)
! CHECK-NEXT: -falternative-parameter-statement
! CHECK-NEXT: Enable the old style PARAMETER statement
! CHECK-NEXT: -fapprox-func Allow certain math function calls to be replaced with an approximately equivalent calculation
Expand Down Expand Up @@ -63,7 +62,6 @@
! CHECK-NEXT: -flto Enable LTO in 'full' mode
! CHECK-NEXT: -fms-runtime-lib=<value>
! CHECK-NEXT: Select Windows run-time library
! CHECK-NEXT: -fno-alias-analysis Do not pass alias information on to LLVM (default for unoptimized builds)
! CHECK-NEXT: -fno-automatic Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE
! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics
! CHECK-NEXT: -fno-integrated-as Disable the integrated assembler
Expand Down
4 changes: 0 additions & 4 deletions flang/test/Driver/driver-help.f90
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
! HELP-NEXT: -D <macro>=<value> Define <macro> to <value> (or 1 if <value> omitted)
! HELP-NEXT: -emit-llvm Use the LLVM representation for assembler and object files
! HELP-NEXT: -E Only run the preprocessor
! HELP-NEXT: -falias-analysis Pass alias information on to LLVM (default when optimizing for speed)
! HELP-NEXT: -falternative-parameter-statement
! HELP-NEXT: Enable the old style PARAMETER statement
! HELP-NEXT: -fapprox-func Allow certain math function calls to be replaced with an approximately equivalent calculation
Expand Down Expand Up @@ -53,7 +52,6 @@
! HELP-NEXT: -flto Enable LTO in 'full' mode
! HELP-NEXT: -fms-runtime-lib=<value>
! HELP-NEXT: Select Windows run-time library
! HELP-NEXT: -fno-alias-analysis Do not pass alias information on to LLVM (default for unoptimized builds)
! HELP-NEXT: -fno-automatic Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE
! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
! HELP-NEXT: -fno-integrated-as Disable the integrated assembler
Expand Down Expand Up @@ -152,7 +150,6 @@
! HELP-FC1-NEXT: -emit-llvm Use the LLVM representation for assembler and object files
! HELP-FC1-NEXT: -emit-obj Emit native object files
! HELP-FC1-NEXT: -E Only run the preprocessor
! HELP-FC1-NEXT: -falias-analysis Pass alias information on to LLVM (default when optimizing for speed)
! HELP-FC1-NEXT: -falternative-parameter-statement
! HELP-FC1-NEXT: Enable the old style PARAMETER statement
! HELP-FC1-NEXT: -fapprox-func Allow certain math function calls to be replaced with an approximately equivalent calculation
Expand Down Expand Up @@ -199,7 +196,6 @@
! HELP-FC1-NEXT: -flogical-abbreviations Enable logical abbreviations
! HELP-FC1-NEXT: -flto=<value> Set LTO mode
! HELP-FC1-NEXT: -flto Enable LTO in 'full' mode
! HELP-FC1-NEXT: -fno-alias-analysis Do not pass alias information on to LLVM (default for unoptimized builds)
! HELP-FC1-NEXT: -fno-analyzed-objects-for-unparse
! HELP-FC1-NEXT: Do not use the analyzed objects when unparsing
! HELP-FC1-NEXT: -fno-automatic Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE
Expand Down
9 changes: 1 addition & 8 deletions flang/test/Driver/falias-analysis.f90
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
! Check that -falias-analysis and -fno-alias-analysis work as expected
! Check that tbaa tags are enabled and disabled with optimization flags as expected
! See flang/test/Fir/tbaa-codegen.fir for a test that the output is correct

! RUN: %flang -c -emit-llvm -falias-analysis %s -o - | llvm-dis | FileCheck %s --check-prefix=CHECK-AA --check-prefix=CHECK-ALL
! RUN: %flang -c -emit-llvm -Ofast %s -o - | llvm-dis | FileCheck %s --check-prefix=CHECK-AA --check-prefix=CHECK-ALL
! RUN: %flang -c -emit-llvm -O3 %s -o - | llvm-dis | FileCheck %s --check-prefix=CHECK-AA --check-prefix=CHECK-ALL
! RUN: %flang -c -emit-llvm -O2 %s -o - | llvm-dis | FileCheck %s --check-prefix=CHECK-AA --check-prefix=CHECK-ALL
! RUN: %flang -c -emit-llvm -O1 %s -o - | llvm-dis | FileCheck %s --check-prefix=CHECK-AA --check-prefix=CHECK-ALL

! RUN: %flang -c -emit-llvm -O0 %s -o - | llvm-dis | FileCheck %s --check-prefix=CHECK-NOAA --check-prefix=CHECK-ALL
! RUN: %flang -c -emit-llvm -Ofast -fno-alias-analysis %s -o - | llvm-dis | FileCheck %s --check-prefix=CHECK-NOAA --check-prefix=CHECK-ALL
! RUN: %flang -c -emit-llvm -fno-alias-analysis -Ofast %s -o - | llvm-dis | FileCheck %s --check-prefix=CHECK-NOAA --check-prefix=CHECK-ALL
! RUN: %flang -c -emit-llvm %s -o - | llvm-dis | FileCheck %s --check-prefix=CHECK-NOAA --check-prefix=CHECK-ALL
! RUN: %flang -c -emit-llvm -falias-analysis -fno-alias-analysis %s -o - | llvm-dis | FileCheck %s --check-prefix=CHECK-NOAA --check-prefix=CHECK-ALL

! RUN: %flang -fc1 -emit-llvm -falias-analysis %s -o - | FileCheck %s --check-prefix=CHECK-AA --check-prefix=CHECK-ALL
! RUN: %flang -fc1 -emit-llvm -O3 %s -o - | FileCheck %s --check-prefix=CHECK-AA --check-prefix=CHECK-ALL
! RUN: %flang -fc1 -emit-llvm -O2 %s -o - | FileCheck %s --check-prefix=CHECK-AA --check-prefix=CHECK-ALL
! RUN: %flang -fc1 -emit-llvm -O1 %s -o - | FileCheck %s --check-prefix=CHECK-AA --check-prefix=CHECK-ALL

! RUN: %flang -fc1 -emit-llvm -O0 %s -o - | FileCheck %s --check-prefix=CHECK-NOAA --check-prefix=CHECK-ALL
! RUN: %flang -fc1 -emit-llvm -falias-analysis -fno-alias-analysis %s -o - | FileCheck %s --check-prefix=CHECK-NOAA --check-prefix=CHECK-ALL
! RUN: %flang -fc1 -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-NOAA --check-prefix=CHECK-ALL
! RUN: %flang -fc1 -emit-llvm -O3 -fno-alias-analysis %s -o - | FileCheck %s --check-prefix=CHECK-NOAA --check-prefix=CHECK-ALL

subroutine simple(a)
integer, intent(inout) :: a(:)
Expand Down

0 comments on commit 6b8d659

Please sign in to comment.