summaryrefslogtreecommitdiffstats
path: root/test/CodeGen/tbaa-struct.cpp
diff options
context:
space:
mode:
authorManman Ren <mren@apple.com>2013-04-22 19:50:07 +0000
committerManman Ren <mren@apple.com>2013-04-22 19:50:07 +0000
commitc7f2bfb4a2dcda757619356a28cb633711a6548c (patch)
tree84f2b96f3c8e2fce4d3214bf06942a3291b0ed4d /test/CodeGen/tbaa-struct.cpp
parent1e7ca6211c77208c8a339c2a26e612be81c70ec5 (diff)
TBAA: make sure zero-length bitfield works for tbaa.struct and path-aware tbaa
For ms structs, zero-length bitfields following non-bitfield members are completely ignored, we should not increase the field index. Before the fix, we will have an assertion failure. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180038 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/tbaa-struct.cpp')
-rw-r--r--test/CodeGen/tbaa-struct.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/CodeGen/tbaa-struct.cpp b/test/CodeGen/tbaa-struct.cpp
index 12a6f4de82..3a93d75156 100644
--- a/test/CodeGen/tbaa-struct.cpp
+++ b/test/CodeGen/tbaa-struct.cpp
@@ -39,8 +39,36 @@ void copy3 (T1 *a, T1 *b) {
// CHECK: call void @llvm.memcpy.p0i8.p0i8.i[[P]](i8* %{{.*}}, i8* %{{.*}}, i[[P]] 12, i32 4, i1 false), !tbaa.struct [[TS3:!.*]]
+// Make sure that zero-length bitfield works.
+#define ATTR __attribute__ ((ms_struct))
+struct five {
+ char a;
+ int :0; /* ignored; prior field is not a bitfield. */
+ char b;
+ char c;
+} ATTR;
+void copy4(struct five *a, struct five *b) {
+ *a = *b;
+}
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i[[P]](i8* %{{.*}}, i8* %{{.*}}, i[[P]] 3, i32 1, i1 false), !tbaa.struct [[TS4:!.*]]
+
+struct six {
+ char a;
+ int :0;
+ char b;
+ char c;
+};
+void copy5(struct six *a, struct six *b) {
+ *a = *b;
+}
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i[[P]](i8* %{{.*}}, i8* %{{.*}}, i[[P]] 6, i32 1, i1 false), !tbaa.struct [[TS5:!.*]]
+
// CHECK: [[TS]] = metadata !{i64 0, i64 2, metadata !{{.*}}, i64 4, i64 4, metadata !{{.*}}, i64 8, i64 1, metadata !{{.*}}, i64 12, i64 4, metadata !{{.*}}}
+// CHECK: [[CHAR:!.*]] = metadata !{metadata !"omnipotent char", metadata !{{.*}}}
+// CHECK: [[INT:!.*]] = metadata !{metadata !"int", metadata [[CHAR]]}
// (offset, size) = (0,1) char; (4,2) short; (8,4) int; (12,1) char; (16,4) int; (20,4) int
// CHECK: [[TS2]] = metadata !{i64 0, i64 1, metadata !{{.*}}, i64 4, i64 2, metadata !{{.*}}, i64 8, i64 4, metadata !{{.*}}, i64 12, i64 1, metadata !{{.*}}, i64 16, i64 4, metadata {{.*}}, i64 20, i64 4, metadata {{.*}}}
// (offset, size) = (0,8) char; (0,2) char; (4,8) char
// CHECK: [[TS3]] = metadata !{i64 0, i64 8, metadata !{{.*}}, i64 0, i64 2, metadata !{{.*}}, i64 4, i64 8, metadata !{{.*}}}
+// CHECK: [[TS4]] = metadata !{i64 0, i64 1, metadata [[CHAR]], i64 1, i64 1, metadata [[CHAR]], i64 2, i64 1, metadata [[CHAR]]}
+// CHECK: [[TS5]] = metadata !{i64 0, i64 1, metadata [[CHAR]], i64 4, i64 4, metadata [[INT]], i64 4, i64 1, metadata [[CHAR]], i64 5, i64 1, metadata [[CHAR]]}