Skip to content

Commit dcab42a

Browse files
authored
[TBAA] Test for tbaa.struct metadata with bitfields in big endian layout (#87617)
This test exposes what I think is invalid tbaa.struct metadata currently generated for bitfields when using big endian layout. The regions given by `!{i64 2, i64 4, [[META3:![0-9]+]], i64 4, i64 4 ...` are overlapping. This issue was originally observed in #86709.
1 parent be8fd86 commit dcab42a

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// RUN: %clang_cc1 -triple aarch64_be-apple-darwin -emit-llvm -o - -O1 %s | \
2+
// RUN: FileCheck -check-prefixes=CHECK,CHECK-BE %s
3+
// RUN: %clang_cc1 -triple aarch64-apple-darwin -emit-llvm -o - -O1 %s | \
4+
// RUN: FileCheck -check-prefixes=CHECK,CHECK-LE %s
5+
//
6+
// Check that TBAA metadata for structs containing bitfields is
7+
// consistent between big and little endian layouts.
8+
//
9+
// FIXME: The metadata below is invalid for the big endian layout: the
10+
// start offset of 2 is incorrect.
11+
12+
struct NamedBitfields {
13+
int f1 : 8;
14+
int f2 : 8;
15+
unsigned f3 : 1;
16+
unsigned f4 : 15;
17+
int f5;
18+
double f6;
19+
};
20+
21+
// CHECK-LABEL: _Z4copyP14NamedBitfieldsS0_
22+
// CHECK-SAME: ptr nocapture noundef writeonly [[A1:%.*]], ptr nocapture noundef readonly [[A2:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
23+
// CHECK-NEXT: entry:
24+
// CHECK-NEXT: tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) [[A1]], ptr noundef nonnull align 8 dereferenceable(16) [[A2]], i64 16, i1 false), !tbaa.struct [[TBAA_STRUCT2:![0-9]+]]
25+
// CHECK-NEXT: ret void
26+
//
27+
void copy(NamedBitfields *a1, NamedBitfields *a2) {
28+
*a1 = *a2;
29+
}
30+
31+
// CHECK-BE: [[TBAA_STRUCT2]] = !{i64 2, i64 4, [[META3:![0-9]+]], i64 4, i64 4, [[META6:![0-9]+]], i64 8, i64 8, [[META8:![0-9]+]]}
32+
// CHECK-LE: [[TBAA_STRUCT2]] = !{i64 0, i64 4, [[META3:![0-9]+]], i64 4, i64 4, [[META6:![0-9]+]], i64 8, i64 8, [[META8:![0-9]+]]}
33+
// CHECK: [[META3]] = !{[[META4:![0-9]+]], [[META4]], i64 0}
34+
// CHECK: [[META4]] = !{!"omnipotent char", [[META5:![0-9]+]], i64 0}
35+
// CHECK: [[META5]] = !{!"Simple C++ TBAA"}
36+
// CHECK: [[META6]] = !{[[META7:![0-9]+]], [[META7]], i64 0}
37+
// CHECK: [[META7]] = !{!"int", [[META4]], i64 0}
38+
// CHECK: [[META8]] = !{[[META9:![0-9]+]], [[META9]], i64 0}
39+
// CHECK: [[META9]] = !{!"double", [[META4]], i64 0}

0 commit comments

Comments
 (0)