[all-commits] [llvm/llvm-project] 7501e5: [Clang] Give warning for an underaligned 128-bit _...

Jonas Paulsson via All-commits all-commits at lists.llvm.org
Wed Mar 15 04:46:40 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7501e53b8d6d7563b047a34d0141630d5afc86c5
      https://github.com/llvm/llvm-project/commit/7501e53b8d6d7563b047a34d0141630d5afc86c5
  Author: Jonas Paulsson <paulsson at linux.vnet.ibm.com>
  Date:   2023-03-15 (Wed, 15 Mar 2023)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticFrontendKinds.td
    M clang/include/clang/Basic/DiagnosticGroups.td
    M clang/lib/CodeGen/CGBuiltin.cpp
    A clang/test/CodeGen/SystemZ/sync-builtins-i128-16Al.c
    A clang/test/CodeGen/SystemZ/sync-builtins-i128-8Al.c

  Log Message:
  -----------
  [Clang] Give warning for an underaligned 128-bit __sync library call.

On SystemZ, int128 values are generally aligned to only 8 bytes per the ABI
while 128 bit atomic ISA instructions exist with a full 16 byte alignment
requirement.

__sync builtins are emitted as atomicrmw instructions which always require
the natural alignment (16 bytes in this case), and they always get it
regardless of the alignment of the value being addressed.

This patch improves this situation by giving a warning if the alignment is
not known to be sufficient. This check is done in CodeGen instead of in Sema
as this is currently the only place where the alignment can be computed. This
could/should be moved into Sema in case the alignment computation could be
made there eventually.

Reviewed By: efriedma, jyknight, uweigand

Differential Revision: https://reviews.llvm.org/D143813




More information about the All-commits mailing list