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

Florian Hahn via All-commits all-commits at lists.llvm.org
Fri Jan 31 03:38:37 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 77d3f8a92564b533a3c60a8c8e0657c38fd88ba1
      https://github.com/llvm/llvm-project/commit/77d3f8a92564b533a3c60a8c8e0657c38fd88ba1
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2025-01-31 (Fri, 31 Jan 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



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