summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/tail-padding.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2019-06-20 20:44:45 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2019-06-20 20:44:45 +0000
commit78b239ea67cf248a5c04031050c32f707f127a9d (patch)
tree23150096a3e3d50ec9a6285ddf6d170b6a61ac20 /clang/test/CodeGenCXX/tail-padding.cpp
parent60ca31a7ddabb46c9ea3762949629433c5eb4c8c (diff)
downloadbcm5719-llvm-78b239ea67cf248a5c04031050c32f707f127a9d.tar.gz
bcm5719-llvm-78b239ea67cf248a5c04031050c32f707f127a9d.zip
P0840R2: support for [[no_unique_address]] attribute
Summary: Add support for the C++2a [[no_unique_address]] attribute for targets using the Itanium C++ ABI. This depends on D63371. Reviewers: rjmccall, aaron.ballman Subscribers: dschuff, aheejin, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63451 llvm-svn: 363976
Diffstat (limited to 'clang/test/CodeGenCXX/tail-padding.cpp')
-rw-r--r--clang/test/CodeGenCXX/tail-padding.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/tail-padding.cpp b/clang/test/CodeGenCXX/tail-padding.cpp
index b8b9e4ccf9a..afb97a00da7 100644
--- a/clang/test/CodeGenCXX/tail-padding.cpp
+++ b/clang/test/CodeGenCXX/tail-padding.cpp
@@ -32,3 +32,47 @@ namespace InitWithinNVSize {
// CHECK: store i32 {{.*}} @_ZTVN16InitWithinNVSize1CE
// CHECK: store i8
}
+
+namespace NoUniqueAddr {
+ struct A { char c; A(const A&); };
+ struct B { int n; char c[3]; ~B(); };
+ struct C : virtual A { B b; };
+ struct D : virtual A { [[no_unique_address]] B b; };
+ struct E : virtual A { [[no_unique_address]] B b; char x; };
+ static_assert(sizeof(C) == sizeof(void*) + 8 + alignof(void*));
+ static_assert(sizeof(D) == sizeof(void*) + 8);
+ static_assert(sizeof(E) == sizeof(void*) + 8 + alignof(void*));
+
+ // CHECK: define {{.*}} @_ZN12NoUniqueAddr1CC1EOS0_
+ // CHECK: call void @_ZN12NoUniqueAddr1AC2ERKS0_(
+ // CHECK: store i32 {{.*}} @_ZTVN12NoUniqueAddr1CE
+ // Copy the full size of B.
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 8, i1 false)
+ C f(C c) { return c; }
+
+ // CHECK: define {{.*}} @_ZN12NoUniqueAddr1DC1EOS0_
+ // CHECK: call void @_ZN12NoUniqueAddr1AC2ERKS0_(
+ // CHECK: store i32 {{.*}} @_ZTVN12NoUniqueAddr1DE
+ // Copy just the data size of B, to avoid overwriting the A base class.
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 7, i1 false)
+ D f(D d) { return d; }
+
+ // CHECK: define {{.*}} @_ZN12NoUniqueAddr1EC1EOS0_
+ // CHECK: call void @_ZN12NoUniqueAddr1AC2ERKS0_(
+ // CHECK: store i32 {{.*}} @_ZTVN12NoUniqueAddr1EE
+ // We can copy the full size of B here. (As it happens, we fold the copy of 'x' into
+ // this memcpy, so we're copying 8 bytes either way.)
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 8, i1 false)
+ E f(E e) { return e; }
+
+ struct F : virtual A {
+ F(const F &o) : A(o), b(o.b) {}
+ [[no_unique_address]] B b;
+ };
+
+ // CHECK: define {{.*}} @_ZN12NoUniqueAddr1FC1ERKS0_
+ // CHECK: call void @_ZN12NoUniqueAddr1AC2ERKS0_(
+ // CHECK: store i32 {{.*}} @_ZTVN12NoUniqueAddr1FE
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 7, i1 false)
+ F f(F x) { return x; }
+}
OpenPOWER on IntegriCloud