Skip to content

Commit 6b8d659

Browse files
authored
[flang] remove -f[no-]alias-analysis (#74343)
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`
1 parent 432bb52 commit 6b8d659

File tree

6 files changed

+2
-45
lines changed

6 files changed

+2
-45
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6344,9 +6344,6 @@ defm stack_arrays : BoolOptionWithoutMarshalling<"f", "stack-arrays",
63446344
defm loop_versioning : BoolOptionWithoutMarshalling<"f", "version-loops-for-stride",
63456345
PosFlag<SetTrue, [], [ClangOption], "Create unit-strided versions of loops">,
63466346
NegFlag<SetFalse, [], [ClangOption], "Do not create unit-strided loops (default)">>;
6347-
defm alias_analysis : BoolOptionWithoutMarshalling<"f", "alias-analysis",
6348-
PosFlag<SetTrue, [], [], "Pass alias information on to LLVM (default when optimizing for speed)">,
6349-
NegFlag<SetFalse, [], [], "Do not pass alias information on to LLVM (default for unoptimized builds)">>;
63506347
} // let Visibility = [FC1Option, FlangOption]
63516348

63526349
def J : JoinedOrSeparate<["-"], "J">,

clang/lib/Driver/ToolChains/Flang.cpp

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -143,33 +143,11 @@ void Flang::addCodegenOptions(const ArgList &Args,
143143
if (shouldLoopVersion(Args))
144144
CmdArgs.push_back("-fversion-loops-for-stride");
145145

146-
Arg *aliasAnalysis = Args.getLastArg(options::OPT_falias_analysis,
147-
options::OPT_fno_alias_analysis);
148-
// only pass on the argument if it does not match that implied by the
149-
// optimization level: so if optimization is requested, only forward
150-
// -fno-alias-analysis. If optimization is not requested, only forward
151-
// -falias-analysis.
152-
Arg *optLevel =
153-
Args.getLastArg(options::OPT_Ofast, options::OPT_O, options::OPT_O4);
154-
if (aliasAnalysis) {
155-
bool faliasAnalysis =
156-
aliasAnalysis->getOption().matches(options::OPT_falias_analysis);
157-
if (optLevel && !faliasAnalysis) {
158-
CmdArgs.push_back("-fno-alias-analysis");
159-
} else {
160-
if (faliasAnalysis)
161-
// requested alias analysis but no optimization enabled
162-
CmdArgs.push_back("-falias-analysis");
163-
}
164-
}
165-
166146
Args.addAllArgs(CmdArgs, {options::OPT_flang_experimental_hlfir,
167147
options::OPT_flang_deprecated_no_hlfir,
168148
options::OPT_flang_experimental_polymorphism,
169149
options::OPT_fno_ppc_native_vec_elem_order,
170-
options::OPT_fppc_native_vec_elem_order,
171-
options::OPT_falias_analysis,
172-
options::OPT_fno_alias_analysis});
150+
options::OPT_fppc_native_vec_elem_order});
173151
}
174152

175153
void Flang::addPicOptions(const ArgList &Args, ArgStringList &CmdArgs) const {

flang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,6 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
243243
opts.LoopVersioning = 1;
244244

245245
opts.AliasAnalysis = opts.OptimizationLevel > 0;
246-
if (auto *arg =
247-
args.getLastArg(clang::driver::options::OPT_falias_analysis,
248-
clang::driver::options::OPT_fno_alias_analysis))
249-
opts.AliasAnalysis =
250-
arg->getOption().matches(clang::driver::options::OPT_falias_analysis);
251246

252247
for (auto *a : args.filtered(clang::driver::options::OPT_fpass_plugin_EQ))
253248
opts.LLVMPassPlugins.push_back(a->getValue());

flang/test/Driver/driver-help-hidden.f90

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
! CHECK-NEXT: -D <macro>=<value> Define <macro> to <value> (or 1 if <value> omitted)
2727
! CHECK-NEXT: -emit-llvm Use the LLVM representation for assembler and object files
2828
! CHECK-NEXT: -E Only run the preprocessor
29-
! CHECK-NEXT: -falias-analysis Pass alias information on to LLVM (default when optimizing for speed)
3029
! CHECK-NEXT: -falternative-parameter-statement
3130
! CHECK-NEXT: Enable the old style PARAMETER statement
3231
! CHECK-NEXT: -fapprox-func Allow certain math function calls to be replaced with an approximately equivalent calculation
@@ -63,7 +62,6 @@
6362
! CHECK-NEXT: -flto Enable LTO in 'full' mode
6463
! CHECK-NEXT: -fms-runtime-lib=<value>
6564
! CHECK-NEXT: Select Windows run-time library
66-
! CHECK-NEXT: -fno-alias-analysis Do not pass alias information on to LLVM (default for unoptimized builds)
6765
! CHECK-NEXT: -fno-automatic Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE
6866
! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics
6967
! CHECK-NEXT: -fno-integrated-as Disable the integrated assembler

flang/test/Driver/driver-help.f90

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
! HELP-NEXT: -D <macro>=<value> Define <macro> to <value> (or 1 if <value> omitted)
2323
! HELP-NEXT: -emit-llvm Use the LLVM representation for assembler and object files
2424
! HELP-NEXT: -E Only run the preprocessor
25-
! HELP-NEXT: -falias-analysis Pass alias information on to LLVM (default when optimizing for speed)
2625
! HELP-NEXT: -falternative-parameter-statement
2726
! HELP-NEXT: Enable the old style PARAMETER statement
2827
! HELP-NEXT: -fapprox-func Allow certain math function calls to be replaced with an approximately equivalent calculation
@@ -53,7 +52,6 @@
5352
! HELP-NEXT: -flto Enable LTO in 'full' mode
5453
! HELP-NEXT: -fms-runtime-lib=<value>
5554
! HELP-NEXT: Select Windows run-time library
56-
! HELP-NEXT: -fno-alias-analysis Do not pass alias information on to LLVM (default for unoptimized builds)
5755
! HELP-NEXT: -fno-automatic Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE
5856
! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
5957
! HELP-NEXT: -fno-integrated-as Disable the integrated assembler
@@ -152,7 +150,6 @@
152150
! HELP-FC1-NEXT: -emit-llvm Use the LLVM representation for assembler and object files
153151
! HELP-FC1-NEXT: -emit-obj Emit native object files
154152
! HELP-FC1-NEXT: -E Only run the preprocessor
155-
! HELP-FC1-NEXT: -falias-analysis Pass alias information on to LLVM (default when optimizing for speed)
156153
! HELP-FC1-NEXT: -falternative-parameter-statement
157154
! HELP-FC1-NEXT: Enable the old style PARAMETER statement
158155
! HELP-FC1-NEXT: -fapprox-func Allow certain math function calls to be replaced with an approximately equivalent calculation
@@ -199,7 +196,6 @@
199196
! HELP-FC1-NEXT: -flogical-abbreviations Enable logical abbreviations
200197
! HELP-FC1-NEXT: -flto=<value> Set LTO mode
201198
! HELP-FC1-NEXT: -flto Enable LTO in 'full' mode
202-
! HELP-FC1-NEXT: -fno-alias-analysis Do not pass alias information on to LLVM (default for unoptimized builds)
203199
! HELP-FC1-NEXT: -fno-analyzed-objects-for-unparse
204200
! HELP-FC1-NEXT: Do not use the analyzed objects when unparsing
205201
! HELP-FC1-NEXT: -fno-automatic Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE

flang/test/Driver/falias-analysis.f90

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
1-
! Check that -falias-analysis and -fno-alias-analysis work as expected
1+
! Check that tbaa tags are enabled and disabled with optimization flags as expected
22
! See flang/test/Fir/tbaa-codegen.fir for a test that the output is correct
33

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

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

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

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

2619
subroutine simple(a)
2720
integer, intent(inout) :: a(:)

0 commit comments

Comments
 (0)