diff options
author | Manman Ren <mren@apple.com> | 2013-04-22 19:50:07 +0000 |
---|---|---|
committer | Manman Ren <mren@apple.com> | 2013-04-22 19:50:07 +0000 |
commit | 09a3912b5c0d30128f626a88096ddb3ce9404023 (patch) | |
tree | 6c43b8aeee1e6750c493ce69082705836b7a02bd /clang/test/CodeGen/tbaa.cpp | |
parent | cb78f0d05e5fc85bf0fede0d35469bc8833c1262 (diff) | |
download | bcm5719-llvm-09a3912b5c0d30128f626a88096ddb3ce9404023.tar.gz bcm5719-llvm-09a3912b5c0d30128f626a88096ddb3ce9404023.zip |
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.
llvm-svn: 180038
Diffstat (limited to 'clang/test/CodeGen/tbaa.cpp')
-rw-r--r-- | clang/test/CodeGen/tbaa.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/clang/test/CodeGen/tbaa.cpp b/clang/test/CodeGen/tbaa.cpp index c256b4af809..439fd20086e 100644 --- a/clang/test/CodeGen/tbaa.cpp +++ b/clang/test/CodeGen/tbaa.cpp @@ -192,6 +192,36 @@ uint32_t g12(StructC *C, StructD *D, uint64_t count) { return b1->a.f32; } +// 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; +char g13(struct five *a, struct five *b) { + return a->b; +// CHECK: define signext i8 @{{.*}}( +// CHECK: load i8* %{{.*}}, align 1, !tbaa !1 +// PATH: define signext i8 @{{.*}}( +// PATH: load i8* %{{.*}}, align 1, !tbaa [[TAG_five_b:!.*]] +} + +struct six { + char a; + int :0; + char b; + char c; +}; +char g14(struct six *a, struct six *b) { +// CHECK: define signext i8 @{{.*}}( +// CHECK: load i8* %{{.*}}, align 1, !tbaa !1 +// PATH: define signext i8 @{{.*}}( +// PATH: load i8* %{{.*}}, align 1, !tbaa [[TAG_six_b:!.*]] + return a->b; +} + // CHECK: !1 = metadata !{metadata !"omnipotent char", metadata !2} // CHECK: !2 = metadata !{metadata !"Simple C/C++ TBAA"} // CHECK: !4 = metadata !{metadata !"int", metadata !1} @@ -219,3 +249,7 @@ uint32_t g12(StructC *C, StructD *D, uint64_t count) { // PATH: [[TYPE_C]] = metadata !{metadata !"_ZTS7StructC", i64 0, metadata [[TYPE_SHORT]], i64 4, metadata [[TYPE_B]], i64 28, metadata [[TYPE_INT]]} // PATH: [[TAG_D_b_a_f32]] = metadata !{metadata [[TYPE_D:!.*]], metadata [[TYPE_INT]], i64 12} // PATH: [[TYPE_D]] = metadata !{metadata !"_ZTS7StructD", i64 0, metadata [[TYPE_SHORT]], i64 4, metadata [[TYPE_B]], i64 28, metadata [[TYPE_INT]], i64 32, metadata [[TYPE_CHAR]]} +// PATH: [[TAG_five_b]] = metadata !{metadata [[TYPE_five:!.*]], metadata [[TYPE_CHAR]], i64 1} +// PATH: [[TYPE_five]] = metadata !{metadata !"_ZTS4five", i64 0, metadata [[TYPE_CHAR]], i64 1, metadata [[TYPE_CHAR]], i64 2, metadata [[TYPE_CHAR]]} +// PATH: [[TAG_six_b]] = metadata !{metadata [[TYPE_six:!.*]], metadata [[TYPE_CHAR]], i64 4} +// PATH: [[TYPE_six]] = metadata !{metadata !"_ZTS3six", i64 0, metadata [[TYPE_CHAR]], i64 4, metadata [[TYPE_INT]], i64 4, metadata [[TYPE_CHAR]], i64 5, metadata [[TYPE_CHAR]]} |