16 Commits

Author SHA1 Message Date
Florian Hahn
346fad5c2c
[TBAA] Simplify checks for unnamed struct case, where anyptr is used. 2025-01-08 14:08:28 +00:00
Florian Hahn
9fc152d25e
[TBAA] Add Clang pointer TBAA test with void *. 2025-01-08 11:54:02 +00:00
Florian Hahn
7954a0514b
[Clang] Enable -fpointer-tbaa by default. (#117244)
Support for more precise TBAA metadata has been added a while ago
(behind the -fpointer-tbaa flag). The more precise TBAA metadata allows
treating accesses of different pointer types as no-alias.

This helps to remove more redundant loads and stores in a number of
workloads.

Some highlights on the impact across llvm-test-suite's MultiSource,
SPEC2006 & SPEC2017 include:
 * +2% more NoAlias results for memory accesses
 * +3% more stores removed by DSE,
 * +4% more loops vectorized.

This closes a relatively big gap to GCC, which has been supporting
disambiguating based on pointer types for a long time.
(https://clang.godbolt.org/z/K7Wbhrz4q)

Pointer-TBAA support for pointers to builtin types has been added in
https://github.com/llvm/llvm-project/pull/76612.

Support for user-defined types has been added in
https://github.com/llvm/llvm-project/pull/110569.

There are 2 recent PRs with bug fixes for special cases uncovered during
testing:
 * https://github.com/llvm/llvm-project/pull/116991
 * https://github.com/llvm/llvm-project/pull/116596

PR: https://github.com/llvm/llvm-project/pull/117244
2024-12-04 20:55:18 +00:00
Florian Hahn
41a0c66f43
[TBAA] Don't emit pointer tbaa for unnamed structs or unions. (#116596)
For unnamed structs or unions, C's compatible types rule applies. Two
compatible types in different compilation units can have different
mangled names, meaning the metadata emitted below would incorrectly mark
them as no-alias. Use AnyPtr for such types in both C and C++, as C and
C++ types may be visible when doing LTO.

PR: https://github.com/llvm/llvm-project/pull/116596
2024-11-21 22:20:27 +00:00
NAKAMURA Takumi
5ff52436fd Relax clang/test/CodeGen/tbaa-pointers.c for -Asserts.
Fixes c4eeef32d5dc (llvmorg-20-init-12475-gc4eeef32d5dc)
2024-11-18 15:27:49 +09:00
Florian Hahn
c4eeef32d5
[TBAA] Add test for generating pointer-tbaa for unnamed structs.
Currently we generate incorrect metadata not considering compatible
types in C.
2024-11-17 20:04:36 +00:00
Florian Hahn
4334f317e7
[TBAA] Extend pointer TBAA to pointers of non-builtin types. (#110569)
Extend the logic added in 123c036bd361d
(https://github.com/llvm/llvm-project/pull/76612) to support pointers to
non-builtin types by using the mangled name of the canonical type.

PR: https://github.com/llvm/llvm-project/pull/110569
2024-10-22 16:23:34 -07:00
Florian Hahn
df3f291d2a
[TBAA] Add tests with pointers to structs to tbaa-pointers.c.
Precommit tests for follow-up improvements to Clang's TBAA emission.

Also add variants with -pointer-tbaa to tbaa-reference.cpp.
2024-09-30 19:54:05 +01:00
Florian Hahn
f9f6f5a9c7
[TBAA] Remove remaining entry BB in check lines for tbaa-pointers.c (2)
Missed out of 47c08fb8d79ec.
2024-07-19 15:48:50 +01:00
Florian Hahn
47c08fb8d7
[TBAA] Remove references to entry BB in check lines for tbaa-pointers.c
Follow-up to 123c036bd361d to remove references to entry BB name from
checks, to fix tests for builds that do not generate block names.
2024-07-19 14:51:27 +01:00
Florian Hahn
123c036bd3
Recommit "[TBAA] Emit distinct TBAA tags for pointers with different depths,types. (#76612)"
This reverts the revert commit bee240367cc48bbc93fe5eb57d537968dfe4419f.

This version includes updates to the tests to use patterns when matching
the pointer argument.

Original commit message:

    This patch extends Clang's TBAA generation code to emit distinct tags
    for incompatible pointer types.

    Pointers with different element types are incompatible if the pointee
    types are also incompatible (modulo sugar/modifiers).

    Express this in TBAA by generating different tags for pointers based on
    the pointer depth and pointee type. To get the TBAA tag for the pointee
    type it uses getTypeInfoHelper on the pointee type.

    (Moved from https://reviews.llvm.org/D122573)

    PR: https://github.com/llvm/llvm-project/pull/76612
2024-07-19 13:03:22 +01:00
Florian Hahn
bee240367c
Revert "[TBAA] Emit distinct TBAA tags for pointers with different depths,types. (#76612)"
This reverts commit 038c48c1f41119d667fa55e17e040281378071f3.

This is causing test failures in some configurations, reverted while I
investigate.

Failures include

 http://lab.llvm.org/buildbot/#/builders/11/builds/1623
 http://lab.llvm.org/buildbot/#/builders/108/builds/1172
2024-07-12 21:32:00 +01:00
Florian Hahn
038c48c1f4
[TBAA] Emit distinct TBAA tags for pointers with different depths,types. (#76612)
This patch extends Clang's TBAA generation code to emit distinct tags
for incompatible pointer types.

Pointers with different element types are incompatible if the pointee
types are also incompatible (modulo sugar/modifiers).

Express this in TBAA by generating different tags for pointers based on
the pointer depth and pointee type. To get the TBAA tag for the pointee
type it uses getTypeInfoHelper on the pointee type.

(Moved from https://reviews.llvm.org/D122573)

PR: https://github.com/llvm/llvm-project/pull/76612
2024-07-12 20:56:10 +01:00
Nikita Popov
39db5e1ed8 [CodeGen] Convert tests to opaque pointers (NFC)
Conversion performed using the script at:
https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34

These are only tests where no manual fixup was required.
2022-10-07 14:22:00 +02:00
Nikita Popov
532dc62b90 [OpaquePtrs][Clang] Add -no-opaque-pointers to tests (NFC)
This adds -no-opaque-pointers to clang tests whose output will
change when opaque pointers are enabled by default. This is
intended to be part of the migration approach described in
https://discourse.llvm.org/t/enabling-opaque-pointers-by-default/61322/9.

The patch has been produced by replacing %clang_cc1 with
%clang_cc1 -no-opaque-pointers for tests that fail with opaque
pointers enabled. Worth noting that this doesn't cover all tests,
there's a remaining ~40 tests not using %clang_cc1 that will need
a followup change.

Differential Revision: https://reviews.llvm.org/D123115
2022-04-07 12:09:47 +02:00
Florian Hahn
8b245ab41d
[Clang,TBAA] Add test cases for nested pointers and TBAA data. 2022-03-27 19:59:37 +01:00