[llvm-bugs] [Bug 51076] New: -Watomic-alignment not using available alignment info

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jul 13 07:37:11 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51076

            Bug ID: 51076
           Summary: -Watomic-alignment not using available alignment info
           Product: clang
           Version: 12.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rth at twiddle.net
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

For i686:

----------------------------------
#include <stdint.h>

uint64_t foo(uint64_t *p)
{
  p = __builtin_assume_aligned(p, 8);
  return __atomic_load_n(p, __ATOMIC_RELAXED);
}

uint64_t bar(uintptr_t p)
{
  if (p & 7) return 0;
  return __atomic_load_n((uint64_t *)p, __ATOMIC_RELAXED);
}
----------------------------------

$ clang-12 -Wall -O -c z.c
z.c:6:10: warning: misaligned atomic operation may incur significant
performance penalty; the expected alignment (8 bytes) exceeds the actual
alignment (4 bytes) [-Watomic-alignment]
  return __atomic_load_n(p, __ATOMIC_RELAXED);
         ^
z.c:12:10: warning: misaligned atomic operation may incur significant
performance penalty; the expected alignment (8 bytes) exceeds the actual
alignment (4 bytes) [-Watomic-alignment]
  return __atomic_load_n((uint64_t *)p, __ATOMIC_RELAXED);
         ^
2 warnings generated.

In both cases, additional alignment information is available
beyond that of the uint64_t type, and it is not being used.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210713/5d2433a7/attachment.html>


More information about the llvm-bugs mailing list