Skip to content

Commit 86ecdec

Browse files
Florian Hahnfhahn
authored andcommitted
Revert "[Clang] Enable -fpointer-tbaa by default. (llvm#117244)"
This reverts commit 7954a05.
1 parent 70d7c84 commit 86ecdec

File tree

12 files changed

+500
-477
lines changed

12 files changed

+500
-477
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ code bases.
5252
`migrate to Vulkan <https://developer.android.com/guide/topics/renderscript/migrate>`_
5353
or other options.
5454

55-
- Clang now emits distinct type-based alias analysis tags for incompatible
56-
pointers by default, enabling more powerful alias analysis when accessing
57-
pointer types. This change may silently change code behavior for code
58-
containing strict-aliasing violations. The new default behavior can be
59-
disabled using ``-fno-pointer-tbaa``.
60-
6155
- Clang will now more aggressively use undefined behavior on pointer addition
6256
overflow for optimization purposes. For example, a check like
6357
``ptr + unsigned_offset < ptr`` will now optimize to ``false``, because

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ ENUM_CODEGENOPT(StructReturnConvention, StructReturnConventionKind, 2, SRCK_Defa
242242

243243
CODEGENOPT(RelaxAll , 1, 0) ///< Relax all machine code instructions.
244244
CODEGENOPT(RelaxedAliasing , 1, 0) ///< Set when -fno-strict-aliasing is enabled.
245-
CODEGENOPT(PointerTBAA , 1, 1) ///< Whether or not to use distinct TBAA tags for pointers.
245+
CODEGENOPT(PointerTBAA, 1, 0) ///< Whether or not to use distinct TBAA tags for pointers.
246246
CODEGENOPT(StructPathTBAA , 1, 0) ///< Whether or not to use struct-path TBAA.
247247
CODEGENOPT(NewStructPathTBAA , 1, 0) ///< Whether or not to use enhanced struct-path TBAA.
248248
CODEGENOPT(SaveTempLabels , 1, 0) ///< Save temporary labels.

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7447,12 +7447,9 @@ def fuse_register_sized_bitfield_access: Flag<["-"], "fuse-register-sized-bitfie
74477447
def relaxed_aliasing : Flag<["-"], "relaxed-aliasing">,
74487448
HelpText<"Turn off Type Based Alias Analysis">,
74497449
MarshallingInfoFlag<CodeGenOpts<"RelaxedAliasing">>;
7450-
defm pointer_tbaa: BoolOption<"", "pointer-tbaa", CodeGenOpts<"PointerTBAA">,
7451-
DefaultTrue,
7452-
PosFlag<SetTrue, [], [ClangOption], "Enable">,
7453-
NegFlag<SetFalse, [], [ClangOption], "Disable">,
7454-
BothFlags<[], [ClangOption], " that single precision floating-point divide and sqrt used in ">>
7455-
;
7450+
def pointer_tbaa: Flag<["-"], "pointer-tbaa">,
7451+
HelpText<"Turn on Type Based Alias Analysis for pointer accesses">,
7452+
MarshallingInfoFlag<CodeGenOpts<"PointerTBAA">>;
74567453
def no_struct_path_tbaa : Flag<["-"], "no-struct-path-tbaa">,
74577454
HelpText<"Turn off struct-path aware Type Based Alias Analysis">,
74587455
MarshallingInfoNegativeFlag<CodeGenOpts<"StructPathTBAA">>;

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5988,9 +5988,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
59885988
if (!Args.hasFlag(options::OPT_fstrict_aliasing, StrictAliasingAliasOption,
59895989
options::OPT_fno_strict_aliasing, !IsWindowsMSVC))
59905990
CmdArgs.push_back("-relaxed-aliasing");
5991-
if (Args.hasFlag(options::OPT_fno_pointer_tbaa, options::OPT_fpointer_tbaa,
5991+
if (Args.hasFlag(options::OPT_fpointer_tbaa, options::OPT_fno_pointer_tbaa,
59925992
false))
5993-
CmdArgs.push_back("-no-pointer-tbaa");
5993+
CmdArgs.push_back("-pointer-tbaa");
59945994
if (!Args.hasFlag(options::OPT_fstruct_path_tbaa,
59955995
options::OPT_fno_struct_path_tbaa, true))
59965996
CmdArgs.push_back("-no-struct-path-tbaa");

clang/test/CodeGen/attr-counted-by.c

Lines changed: 28 additions & 37 deletions
Large diffs are not rendered by default.

clang/test/CodeGen/tbaa-pointers.c

Lines changed: 123 additions & 93 deletions
Large diffs are not rendered by default.

clang/test/CodeGen/tbaa-reference.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes -no-pointer-tbaa %s -emit-llvm -o - | FileCheck %s -check-prefixes=CHECK,OLD-PATH
2-
// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s -check-prefixes=CHECK,OLD-PATH-POINTER
3-
// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s -no-pointer-tbaa -emit-llvm -new-struct-path-tbaa -o - | FileCheck %s -check-prefixes=CHECK,NEW-PATH
4-
// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s -emit-llvm -new-struct-path-tbaa -o - | FileCheck %s -check-prefixes=CHECK,NEW-PATH-POINTER
1+
// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s -check-prefixes=CHECK,OLD-PATH
2+
// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes -pointer-tbaa %s -emit-llvm -o - | FileCheck %s -check-prefixes=CHECK,OLD-PATH-POINTER
3+
// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s -emit-llvm -new-struct-path-tbaa -o - | FileCheck %s -check-prefixes=CHECK,NEW-PATH
4+
// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s -pointer-tbaa -emit-llvm -new-struct-path-tbaa -o - | FileCheck %s -check-prefixes=CHECK,NEW-PATH-POINTER
55
//
66
// Check that we generate correct TBAA information for reference accesses.
77

clang/test/CodeGenCXX/template-instantiation.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
// CHECK2-NOT: _ZTVN5test31SIiEE
1919
// CHECK2-NOT: _ZTSN5test31SIiEE
20-
// CHECK2: !{!"p1 _ZTSN5test31SIiEE",
2120

2221
// CHECK-LABEL: define linkonce_odr void @_ZN5test21CIiEC1Ev(ptr {{[^,]*}} %this) unnamed_addr
2322
// CHECK-LABEL: define linkonce_odr void @_ZN5test21CIiE6foobarIdEEvT_(

0 commit comments

Comments
 (0)