[all-commits] [llvm/llvm-project] 7643bd: [TBAA] Don't emit pointer-tbaa for void pointers. ...

Florian Hahn via All-commits all-commits at lists.llvm.org
Tue Feb 18 15:05:45 PST 2025


  Branch: refs/heads/release/20.x
  Home:   https://github.com/llvm/llvm-project
  Commit: 7643bd660236cd72345c0f3cbbdc75e2726ff32b
      https://github.com/llvm/llvm-project/commit/7643bd660236cd72345c0f3cbbdc75e2726ff32b
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2025-02-18 (Tue, 18 Feb 2025)

  Changed paths:
    M clang/docs/UsersManual.rst
    M clang/lib/CodeGen/CodeGenTBAA.cpp
    M clang/test/CodeGen/tbaa-pointers.c
    M clang/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
    M clang/unittests/CodeGen/TBAAMetadataTest.cpp

  Log Message:
  -----------
  [TBAA] Don't emit pointer-tbaa for void pointers. (#122116)

While there are no special rules in the standards regarding void
pointers and strict aliasing, emitting distinct tags for void pointers
break some common idioms and there is no good alternative to re-write
the code without strict-aliasing violations. An example is to count the
entries in an array of pointers:

    int count_elements(void * values) {
      void **seq = values;
      int count;
      for (count = 0; seq && seq[count]; count++);
      return count;
    }

https://clang.godbolt.org/z/8dTv51v8W

An example in the wild is from
https://github.com/llvm/llvm-project/issues/119099

This patch avoids emitting distinct tags for void pointers, to avoid
those idioms causing mis-compiles for now.

Fixes https://github.com/llvm/llvm-project/issues/119099.
Fixes https://github.com/llvm/llvm-project/issues/122537.

PR: https://github.com/llvm/llvm-project/pull/122116
(cherry picked from commit 77d3f8a92564b533a3c60a8c8e0657c38fd88ba1)



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list