@@ -2489,6 +2489,8 @@ are listed below.
2489
2489
2490
2490
$ clang -fuse-ld=lld -Oz -Wl,--icf=safe -fcodegen-data-use code.cc
2491
2491
2492
+ .. _strict_aliasing :
2493
+
2492
2494
Strict Aliasing
2493
2495
---------------
2494
2496
@@ -2513,8 +2515,7 @@ violates the strict aliasing rules. For example:
2513
2515
2514
2516
Strict aliasing can be explicitly enabled with ``-fstrict-aliasing `` and
2515
2517
disabled with ``-fno-strict-aliasing ``. ``clang-cl `` defaults to
2516
- ``-fno-strict-aliasing ``; see :ref: `Strict aliasing in clang-cl.
2517
- <clang_cl_strict_aliasing>`. Otherwise, Clang defaults to ``-fstrict-aliasing ``.
2518
+ ``-fno-strict-aliasing ``; see . Otherwise, Clang defaults to ``-fstrict-aliasing ``.
2518
2519
2519
2520
C and C++ specify slightly different rules for strict aliasing. To improve
2520
2521
language interoperability, Clang allows two types to alias if either language
@@ -2529,7 +2530,7 @@ standard aliasing rules in the following ways:
2529
2530
2530
2531
Code which violates strict aliasing has undefined behavior. A program that
2531
2532
works in one version of Clang may not work in another because of changes to the
2532
- optimizer. Clang provides a ` :ref: TypeSanitizer <TypeSanitizer> ` to help detect
2533
+ optimizer. Clang provides a :doc: ` TypeSanitizer ` to help detect
2533
2534
violations of the strict aliasing rules, but it is currently still experimental.
2534
2535
Code that is known to violate strict aliasing should generally be built with
2535
2536
``-fno-strict-aliasing `` if the violation cannot be fixed.
@@ -2561,7 +2562,7 @@ In Clang 20, Clang strengthened its implementation of strict aliasing for
2561
2562
accesses of pointer type. Previously, all accesses of pointer type were
2562
2563
permitted to alias each other, but Clang now distinguishes different pointers
2563
2564
by their pointee type, except as limited by the relaxations around qualifiers
2564
- and `void* ` described above. The previous behavior of treating all pointers as
2565
+ and `` void* ` ` described above. The previous behavior of treating all pointers as
2565
2566
aliasing can be restored using ``-fno-pointer-tbaa ``.
2566
2567
2567
2568
Profile Guided Optimization
@@ -5347,14 +5348,6 @@ The Visual C++ Toolset has a slightly more elaborate mechanism for detection.
5347
5348
Restrictions and Limitations compared to Clang
5348
5349
----------------------------------------------
5349
5350
5350
- .. _clang_cl_strict_aliasing :
5351
-
5352
- Strict Aliasing
5353
- ^^^^^^^^^^^^^^^
5354
-
5355
- Strict aliasing (TBAA) is always off by default in clang-cl. Whereas in clang,
5356
- strict aliasing is turned on by default for all optimization levels.
5357
-
5358
- To enable LLVM optimizations based on strict aliasing rules (e.g., optimizations
5359
- based on type of expressions in C/C++), user will need to explicitly pass
5360
- `-fstrict-aliasing ` to clang-cl.
5351
+ Strict aliasing (TBAA) is always off by default in clang-cl whereas in clang,
5352
+ strict aliasing is turned on by default for all optimization levels. For more
5353
+ details, see :ref: `Strict aliasing <strict_aliasing >`.
0 commit comments