annotate clang/test/CodeGen/object-size.cpp @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 // C++-specific tests for __builtin_object_size
anatofuz
parents:
diff changeset
4
anatofuz
parents:
diff changeset
5 int gi;
anatofuz
parents:
diff changeset
6
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
7 // CHECK-LABEL: define{{.*}} void @_Z5test1v()
150
anatofuz
parents:
diff changeset
8 void test1() {
anatofuz
parents:
diff changeset
9 // Guaranteeing that our cast removal logic doesn't break more interesting
anatofuz
parents:
diff changeset
10 // cases.
anatofuz
parents:
diff changeset
11 struct A { int a; };
anatofuz
parents:
diff changeset
12 struct B { int b; };
anatofuz
parents:
diff changeset
13 struct C: public A, public B {};
anatofuz
parents:
diff changeset
14
anatofuz
parents:
diff changeset
15 C c;
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 // CHECK: store i32 8
anatofuz
parents:
diff changeset
18 gi = __builtin_object_size(&c, 0);
anatofuz
parents:
diff changeset
19 // CHECK: store i32 8
anatofuz
parents:
diff changeset
20 gi = __builtin_object_size((A*)&c, 0);
anatofuz
parents:
diff changeset
21 // CHECK: store i32 4
anatofuz
parents:
diff changeset
22 gi = __builtin_object_size((B*)&c, 0);
anatofuz
parents:
diff changeset
23
anatofuz
parents:
diff changeset
24 // CHECK: store i32 8
anatofuz
parents:
diff changeset
25 gi = __builtin_object_size((char*)&c, 0);
anatofuz
parents:
diff changeset
26 // CHECK: store i32 8
anatofuz
parents:
diff changeset
27 gi = __builtin_object_size((char*)(A*)&c, 0);
anatofuz
parents:
diff changeset
28 // CHECK: store i32 4
anatofuz
parents:
diff changeset
29 gi = __builtin_object_size((char*)(B*)&c, 0);
anatofuz
parents:
diff changeset
30 }
anatofuz
parents:
diff changeset
31
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
32 // CHECK-LABEL: define{{.*}} void @_Z5test2v()
150
anatofuz
parents:
diff changeset
33 void test2() {
anatofuz
parents:
diff changeset
34 struct A { char buf[16]; };
anatofuz
parents:
diff changeset
35 struct B : A {};
anatofuz
parents:
diff changeset
36 struct C { int i; B bs[1]; } *c;
anatofuz
parents:
diff changeset
37
anatofuz
parents:
diff changeset
38 // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false, i1 true, i1 false)
anatofuz
parents:
diff changeset
39 gi = __builtin_object_size(&c->bs[0], 0);
anatofuz
parents:
diff changeset
40 // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false, i1 true, i1 false)
anatofuz
parents:
diff changeset
41 gi = __builtin_object_size(&c->bs[0], 1);
anatofuz
parents:
diff changeset
42 // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 true, i1 true, i1 false)
anatofuz
parents:
diff changeset
43 gi = __builtin_object_size(&c->bs[0], 2);
anatofuz
parents:
diff changeset
44 // CHECK: store i32 16
anatofuz
parents:
diff changeset
45 gi = __builtin_object_size(&c->bs[0], 3);
anatofuz
parents:
diff changeset
46
anatofuz
parents:
diff changeset
47 // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false, i1 true, i1 false)
anatofuz
parents:
diff changeset
48 gi = __builtin_object_size((A*)&c->bs[0], 0);
anatofuz
parents:
diff changeset
49 // CHECK: store i32 16
anatofuz
parents:
diff changeset
50 gi = __builtin_object_size((A*)&c->bs[0], 1);
anatofuz
parents:
diff changeset
51 // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 true, i1 true, i1 false)
anatofuz
parents:
diff changeset
52 gi = __builtin_object_size((A*)&c->bs[0], 2);
anatofuz
parents:
diff changeset
53 // CHECK: store i32 16
anatofuz
parents:
diff changeset
54 gi = __builtin_object_size((A*)&c->bs[0], 3);
anatofuz
parents:
diff changeset
55
anatofuz
parents:
diff changeset
56 // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false, i1 true, i1 false)
anatofuz
parents:
diff changeset
57 gi = __builtin_object_size(&c->bs[0].buf[0], 0);
anatofuz
parents:
diff changeset
58 // CHECK: store i32 16
anatofuz
parents:
diff changeset
59 gi = __builtin_object_size(&c->bs[0].buf[0], 1);
anatofuz
parents:
diff changeset
60 // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 true, i1 true, i1 false)
anatofuz
parents:
diff changeset
61 gi = __builtin_object_size(&c->bs[0].buf[0], 2);
anatofuz
parents:
diff changeset
62 // CHECK: store i32 16
anatofuz
parents:
diff changeset
63 gi = __builtin_object_size(&c->bs[0].buf[0], 3);
anatofuz
parents:
diff changeset
64 }