[all-commits] [llvm/llvm-project] e18c6e: [clang] improve diagnostics for misaligned and lar...
tschuett via All-commits
all-commits at lists.llvm.org
Tue Aug 4 11:10:55 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: e18c6ef6b41a59af73bf5c3d7d52a8c53a471e5d
https://github.com/llvm/llvm-project/commit/e18c6ef6b41a59af73bf5c3d7d52a8c53a471e5d
Author: Thorsten Schuett <schuett at gmail.com>
Date: 2020-08-04 (Tue, 04 Aug 2020)
Changed paths:
M clang/include/clang/Basic/DiagnosticFrontendKinds.td
M clang/include/clang/Basic/DiagnosticGroups.td
M clang/lib/CodeGen/CGAtomic.cpp
M clang/test/CodeGen/atomics-sema-alignment.c
Log Message:
-----------
[clang] improve diagnostics for misaligned and large atomics
"Listing the alignment and access size (== expected alignment) in the warning
seems like a good idea."
solves PR 46947
struct Foo {
struct Bar {
void * a;
void * b;
};
Bar bar;
};
struct ThirtyTwo {
struct Large {
void * a;
void * b;
void * c;
void * d;
};
Large bar;
};
void braz(Foo *foo, ThirtyTwo *braz) {
Foo::Bar bar;
__atomic_load(&foo->bar, &bar, __ATOMIC_RELAXED);
ThirtyTwo::Large foobar;
__atomic_load(&braz->bar, &foobar, __ATOMIC_RELAXED);
}
repro.cpp:21:3: warning: misaligned atomic operation may incur significant performance penalty; the expected (16 bytes) exceeds the actual alignment (8 bytes) [-Watomic-alignment]
__atomic_load(&foo->bar, &bar, __ATOMIC_RELAXED);
^
repro.cpp:24:3: warning: misaligned atomic operation may incur significant performance penalty; the expected (32 bytes) exceeds the actual alignment (8 bytes) [-Watomic-alignment]
__atomic_load(&braz->bar, &foobar, __ATOMIC_RELAXED);
^
repro.cpp:24:3: warning: large atomic operation may incur significant performance penalty; the access size (32 bytes) exceeds the max lock-free size (16 bytes) [-Watomic-alignment]
3 warnings generated.
Differential Revision: https://reviews.llvm.org/D85102
More information about the All-commits
mailing list