blob: c05f3f02442f258c8db3e599a218d616d58a8a85 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -I%S -triple x86_64-apple-darwin -std=c++0x -emit-llvm %s -o %t.ll
Mike Stump39f36e32009-11-16 23:36:30 +00002// RUN: FileCheck -check-prefix LL --input-file=%t.ll %s
3
4#include <typeinfo>
5
6class test1_A { virtual void f() { } };
7class test1_B { virtual void g() { } };
8class test1_D : public virtual test1_A, private test1_B {};
9class test1_E : public test1_D, public test1_B {};
10class test1_F : public test1_E, public test1_D {};
11
12extern test1_D test1_d;
13extern test1_F test1_f;
14
15extern "C" int printf(const char *str...);
16
17#define S(V, N) if (V) printf("PASS: %d\n", N); else printf("FAIL: %d\n", N)
18
19void test1() {
20 test1_B* bp = (test1_B*)&test1_d;
21 test1_A* ap = &test1_d;
22 // This throws
23 // test1_D& dr = dynamic_cast<D&>(*bp);
24 test1_D* dp = dynamic_cast<test1_D*>(bp);
25 S(dp == 0, 1);
26 ap = dynamic_cast<test1_A*>(bp);
27 S(ap == 0, 2);
28 bp = dynamic_cast<test1_B*>(ap);
29 S(bp == 0, 3);
30 ap = dynamic_cast<test1_A*>(&test1_d);
31 S(ap != 0, 4);
Mike Stumpc888f482009-11-17 00:30:31 +000032 // FIXME: Doesn't work yet, gcc fails this at compile time. We'd need access
33 // control for this to work.
Mike Stump39f36e32009-11-16 23:36:30 +000034 // bp = dynamic_cast<test1_B*>(&test1_d);
35 // S(bp == 0, 5);
36 {
37 test1_A* ap = &test1_f;
38 S(ap != 0, 6);
39 test1_D* dp = dynamic_cast<test1_D*>(ap);
40 S(dp == 0, 7);
41 // cast from virtual base
42 test1_E* ep1 = dynamic_cast<test1_E*>(ap);
43 S(ep1 != 0, 8);
44 }
45 dp = dynamic_cast<test1_D*>(&test1_d);
46 S(dp == &test1_d, 9);
47 const test1_D *cdp = dynamic_cast<const test1_D*>(&test1_d);
48 S(cdp == &test1_d, 10);
49 dp = dynamic_cast<test1_D*>((test1_A*)0);
50 S(dp == 0, 11);
51 ap = dynamic_cast<test1_A*>(&test1_d);
52 S(ap == (test1_A*)&test1_d, 12);
53 test1_E* ep = dynamic_cast<test1_E*>(&test1_f);
54 S(ep == (test1_E*)&test1_f, 13);
55 void *vp = dynamic_cast<void*>(ap);
56 S(vp == &test1_d, 14);
57 const void *cvp = dynamic_cast<const void*>(ap);
58 S(cvp == &test1_d, 15);
59}
60
61// CHECK-LL: define void @_Z5test1v() nounwind {
Mike Stump69456f12010-01-15 00:50:35 +000062// CHECK-LL: [[bp:%.*]] = alloca %class.test1_A*, align 8
63// CHECK-LL-NEXT: [[ap:%.*]] = alloca %class.test1_A*, align 8
64// CHECK-LL-NEXT: [[dp:%.*]] = alloca %class.test1_D*, align 8
65// CHECK-LL-NEXT: [[ap37:%.*]] = alloca %class.test1_A*, align 8
66// CHECK-LL-NEXT: [[dp53:%.*]] = alloca %class.test1_D*, align 8
67// CHECK-LL-NEXT: [[ep1:%.*]] = alloca %class.test1_E*, align 8
68// CHECK-LL-NEXT: [[cdp:%.*]] = alloca %class.test1_D*, align 8
69// CHECK-LL-NEXT: [[ep:%.*]] = alloca %class.test1_E*, align 8
70// CHECK-LL-NEXT: [[vp:%.*]] = alloca i8*, align 8
71// CHECK-LL-NEXT: [[cvp:%.*]] = alloca i8*, align 8
Anders Carlsson905a1002010-01-31 02:39:02 +000072// CHECK-LL-NEXT: store %class.test1_A* bitcast (%class.test1_D* @test1_d to %class.test1_A*), %class.test1_A** [[bp]]
Mike Stump69456f12010-01-15 00:50:35 +000073// CHECK-LL-NEXT: br i1 false, label %[[castnull2:.*]], label %[[castnotnull1:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +000074// CHECK-LL: [[castnotnull1]]
Mike Stump69456f12010-01-15 00:50:35 +000075// CHECK-LL-NEXT: [[vtable:%.*]] = load i8** bitcast (%class.test1_D* @test1_d to i8**)
76// CHECK-LL-NEXT: [[vbaseoffsetptr:%.*]] = getelementptr i8* [[vtable]], i64 -24
77// CHECK-LL-NEXT: [[v1:%.*]] = bitcast i8* [[vbaseoffsetptr]] to i64*
78// CHECK-LL-NEXT: [[vbaseoffset:%.*]] = load i64* [[v1]]
79// CHECK-LL-NEXT: [[addptr:%.*]] = getelementptr i8* getelementptr inbounds (%class.test1_D* @test1_d, i32 0, i32 0, i32 0), i64 [[vbaseoffset:.*]]
80// CHECK-LL-NEXT: [[v2:%.*]] = bitcast i8* [[addptr]] to %class.test1_A*
81// CHECK-LL-NEXT: br label %[[castend3:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +000082// CHECK-LL: [[castnull2]]
Mike Stump69456f12010-01-15 00:50:35 +000083// CHECK-LL-NEXT: br label %[[castend3]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +000084// CHECK-LL: [[castend3]]
Mike Stump69456f12010-01-15 00:50:35 +000085// CHECK-LL-NEXT: [[v3:%.*]] = phi %class.test1_A* [ [[v2]], %[[castnotnull1]] ], [ null, %[[castnull2]] ]
86// CHECK-LL-NEXT: store %class.test1_A* [[v3]], %class.test1_A** [[ap]]
87// CHECK-LL-NEXT: [[tmp:%.*]] = load %class.test1_A** [[bp]]
88// CHECK-LL-NEXT: [[v4:%.*]] = icmp ne %class.test1_A* [[tmp]], null
89// CHECK-LL-NEXT: br i1 [[v4]], label %[[v5:.*]], label %[[v9:.*]]
90// CHECK-LL: ; <label>:[[v5]]
91// CHECK-LL-NEXT: [[v6:%.*]] = bitcast %class.test1_A* [[tmp]] to i8*
92// CHECK-LL-NEXT: [[v7:%.*]] = call i8* @__dynamic_cast(i8* [[v6]], i8* bitcast (%0* @_ZTI7test1_B to i8*), i8* bitcast (%1* @_ZTI7test1_D to i8*), i64 -1) ; <i8*> [#uses=1]
93// CHECK-LL-NEXT: [[v8:%.*]] = bitcast i8* [[v7]] to %class.test1_D*
94// CHECK-LL-NEXT: br label %[[v10:.*]]
95// CHECK-LL: ; <label>:[[v9]]
96// CHECK-LL-NEXT: br label %[[v10]]
97// CHECK-LL: ; <label>:[[v10]]
98// CHECK-LL-NEXT: [[v11:%.*]] = phi %class.test1_D* [ [[v8]], %[[v5]] ], [ null, %[[v9]] ]
99// CHECK-LL-NEXT: store %class.test1_D* [[v11]], %class.test1_D** [[dp]]
100// CHECK-LL-NEXT: [[tmp4:%.*]] = load %class.test1_D** [[dp]]
101// CHECK-LL-NEXT: [[cmp:%.*]] = icmp eq %class.test1_D* [[tmp4]], null
102// CHECK-LL-NEXT: br i1 [[cmp]], label %[[ifthen:.*]], label %[[ifelse:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000103// CHECK-LL: [[ifthen]]
Mike Stump69456f12010-01-15 00:50:35 +0000104// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 1)
105// CHECK-LL-NEXT: br label %[[ifend:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000106// CHECK-LL: [[ifelse]]
Mike Stump69456f12010-01-15 00:50:35 +0000107// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 1)
108// CHECK-LL-NEXT: br label %[[ifend]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000109// CHECK-LL: [[ifend]]
Mike Stump69456f12010-01-15 00:50:35 +0000110// CHECK-LL-NEXT: [[tmp6:%.*]] = load %class.test1_A** [[bp]]
111// CHECK-LL-NEXT: [[v12:%.*]] = icmp ne %class.test1_A* [[tmp6]], null
112// CHECK-LL-NEXT: br i1 [[v12]], label %[[v13:.*]], label %[[v17:.*]]
113// CHECK-LL: ; <label>:[[v13]]
114// CHECK-LL-NEXT: [[v14:%.*]] = bitcast %class.test1_A* [[tmp6]] to i8*
115// CHECK-LL-NEXT: [[v15:%.*]] = call i8* @__dynamic_cast(i8* [[v14]], i8* bitcast ({{.*}} @_ZTI7test1_B to i8*), i8* bitcast ({{.*}} @_ZTI7test1_A to i8*), i64 -1)
116// CHECK-LL-NEXT: [[v16:%.*]] = bitcast i8* [[v15]] to %class.test1_A*
117// CHECK-LL-NEXT: br label %[[v18:.*]]
118// CHECK-LL: ; <label>:[[v17]]
119// CHECK-LL-NEXT: br label %[[v18]]
120// CHECK-LL: ; <label>:[[v18]]
121// CHECK-LL-NEXT: [[v19:%.*]] = phi %class.test1_A* [ [[v16]], %[[v13]] ], [ null, %[[v17]] ]
122// CHECK-LL-NEXT: store %class.test1_A* [[v19]], %class.test1_A** [[ap]]
123// CHECK-LL-NEXT: [[tmp7:%.*]] = load %class.test1_A** [[ap]]
124// CHECK-LL-NEXT: [[cmp8:%.*]] = icmp eq %class.test1_A* [[tmp7]], null
125// CHECK-LL-NEXT: br i1 [[cmp8]], label %[[ifthen9:.*]], label %[[ifelse11:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000126// CHECK-LL: [[ifthen9]]
Mike Stump69456f12010-01-15 00:50:35 +0000127// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 2)
128// CHECK-LL-NEXT: br label %[[ifend13:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000129// CHECK-LL: [[ifelse11]]
Mike Stump69456f12010-01-15 00:50:35 +0000130// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 2)
131// CHECK-LL-NEXT: br label %[[ifend13]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000132// CHECK-LL: [[ifend13]]
Mike Stump69456f12010-01-15 00:50:35 +0000133// CHECK-LL-NEXT: [[tmp14:%.*]] = load %class.test1_A** [[ap]]
134// CHECK-LL-NEXT: [[v20:%.*]] = icmp ne %class.test1_A* [[tmp14]], null
135// CHECK-LL-NEXT: br i1 [[v20]], label %[[v21:.*]], label %[[v25:.*]]
136// CHECK-LL: ; <label>:[[v21]]
137// CHECK-LL-NEXT: [[v22:%.*]] = bitcast %class.test1_A* [[tmp14]] to i8*
138// CHECK-LL-NEXT: [[v23:%.*]] = call i8* @__dynamic_cast({{.*}} [[v22]], i8* bitcast ({{.*}} @_ZTI7test1_A to i8*), i8* bitcast ({{.*}} @_ZTI7test1_B to i8*), i64 -1)
139// CHECK-LL-NEXT: [[v24:%.*]] = bitcast i8* [[v23]] to %class.test1_A*
140// CHECK-LL-NEXT: br label %[[v26:.*]]
141// CHECK-LL: ; <label>:[[v25]]
142// CHECK-LL-NEXT: br label %[[v26]]
143// CHECK-LL: ; <label>:[[v26]]
144// CHECK-LL-NEXT: [[v27:%.*]] = phi %class.test1_A* [ [[v24]], %[[v21]] ], [ null, %[[v25]] ]
145// CHECK-LL-NEXT: store %class.test1_A* [[v27]], %class.test1_A** [[bp]]
146// CHECK-LL-NEXT: [[tmp15:%.*]] = load %class.test1_A** [[bp]]
147// CHECK-LL-NEXT: [[cmp16:%.*]] = icmp eq %class.test1_A* [[tmp15]], null
148// CHECK-LL-NEXT: br i1 [[cmp16]], label %[[ifthen17:.*]], label %[[ifelse19:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000149// CHECK-LL: [[ifthen17]]
Mike Stump69456f12010-01-15 00:50:35 +0000150// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 3)
151// CHECK-LL-NEXT: br label %[[ifend21:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000152// CHECK-LL: [[ifelse19]]
Mike Stump69456f12010-01-15 00:50:35 +0000153// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 3)
154// CHECK-LL-NEXT: br label %[[ifend21]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000155// CHECK-LL: [[ifend21]]
Mike Stump69456f12010-01-15 00:50:35 +0000156// CHECK-LL-NEXT: br i1 false, label %[[castnull27:.*]], label %[[castnotnull22:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000157// CHECK-LL: [[castnotnull22]]
Mike Stump69456f12010-01-15 00:50:35 +0000158// CHECK-LL-NEXT: [[vtable23:%.*]] = load i8** bitcast (%class.test1_D* @test1_d to i8**)
159// CHECK-LL-NEXT: [[vbaseoffsetptr24:%.*]] = getelementptr i8* [[vtable23]], i64 -24
160// CHECK-LL-NEXT: [[v28:%.*]] = bitcast i8* [[vbaseoffsetptr24]] to i64*
161// CHECK-LL-NEXT: [[vbaseoffset25:%.*]] = load i64* [[v28]]
162// CHECK-LL-NEXT: [[addptr26:%.*]] = getelementptr i8* getelementptr inbounds (%class.test1_D* @test1_d, i32 0, i32 0, i32 0), i64 [[vbaseoffset25]]
163// CHECK-LL-NEXT: [[v29:%.*]] = bitcast i8* [[addptr26]] to %class.test1_A*
164// CHECK-LL-NEXT: br label %[[castend28:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000165// CHECK-LL: [[castnull27]]
Mike Stump69456f12010-01-15 00:50:35 +0000166// CHECK-LL-NEXT: br label %[[castend28]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000167// CHECK-LL: [[castend28]]
Mike Stump69456f12010-01-15 00:50:35 +0000168// CHECK-LL-NEXT: [[v30:%.*]] = phi %class.test1_A* [ [[v29]], %[[castnotnull22]] ], [ null, %[[castnull27]] ]
169// CHECK-LL-NEXT: store %class.test1_A* [[v30]], %class.test1_A** [[ap]]
170// CHECK-LL-NEXT: [[tmp29:%.*]] = load %class.test1_A** [[ap]]
171// CHECK-LL-NEXT: [[cmp30:%.*]] = icmp ne %class.test1_A* [[tmp29]], null
172// CHECK-LL-NEXT: br i1 [[cmp30]], label %[[ifthen31:.*]], label %[[ifelse33:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000173// CHECK-LL: [[ifthen31]]
Mike Stump69456f12010-01-15 00:50:35 +0000174// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 4)
175// CHECK-LL-NEXT: br label %[[ifend35:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000176// CHECK-LL: [[ifelse33]]
Mike Stump69456f12010-01-15 00:50:35 +0000177// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 4)
178// CHECK-LL-NEXT: br label %[[ifend35]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000179// CHECK-LL: [[ifend35]]
Mike Stump69456f12010-01-15 00:50:35 +0000180// CHECK-LL-NEXT: br i1 false, label %[[castnull43:.*]], label %[[castnotnull38:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000181// CHECK-LL: [[castnotnull38]]
Mike Stump69456f12010-01-15 00:50:35 +0000182// CHECK-LL-NEXT: [[vtable39:%.*]] = load i8** bitcast (%class.test1_F* @test1_f to i8**)
183// CHECK-LL-NEXT: [[vbaseoffsetptr40:%.*]] = getelementptr i8* [[vtable39]], i64 -24
184// CHECK-LL-NEXT: [[v31:%.*]] = bitcast i8* [[vbaseoffsetptr40]] to i64*
185// CHECK-LL-NEXT: [[vbaseoffset41:%.*]] = load i64* [[v31]]
186// CHECK-LL-NEXT: [[addptr42:%.*]] = getelementptr i8* getelementptr inbounds (%class.test1_F* @test1_f, i32 0, i32 0, i32 0), i64 [[vbaseoffset41]]
187// CHECK-LL-NEXT: [[v32:%.*]] = bitcast i8* [[addptr42]] to %class.test1_A*
188// CHECK-LL-NEXT: br label %[[castend44:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000189// CHECK-LL: [[castnull43]]
Mike Stump69456f12010-01-15 00:50:35 +0000190// CHECK-LL-NEXT: br label %[[castend44]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000191// CHECK-LL: [[castend44]]
Mike Stump69456f12010-01-15 00:50:35 +0000192// CHECK-LL-NEXT: [[v33:%.*]] = phi %class.test1_A* [ [[v32]], %[[castnotnull38]] ], [ null, %[[castnull43]] ]
193// CHECK-LL-NEXT: store %class.test1_A* [[v33]], %class.test1_A** [[ap37]]
194// CHECK-LL-NEXT: [[tmp45:%.*]] = load %class.test1_A** [[ap37]]
195// CHECK-LL-NEXT: [[cmp46:%.*]] = icmp ne %class.test1_A* [[tmp45]], null
196// CHECK-LL-NEXT: br i1 [[cmp46]], label %[[ifthen47:.*]], label %[[ifelse49:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000197// CHECK-LL: [[ifthen47]]
Mike Stump69456f12010-01-15 00:50:35 +0000198// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 6)
199// CHECK-LL-NEXT: br label %[[ifend51:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000200// CHECK-LL: [[ifelse49]]
Mike Stump69456f12010-01-15 00:50:35 +0000201// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 6)
202// CHECK-LL-NEXT: br label %[[ifend51]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000203// CHECK-LL: [[ifend51]]
Mike Stump69456f12010-01-15 00:50:35 +0000204// CHECK-LL-NEXT: [[tmp54:%.*]] = load %class.test1_A** [[ap37]]
205// CHECK-LL-NEXT: [[v34:%.*]] = icmp ne %class.test1_A* [[tmp54]], null
206// CHECK-LL-NEXT: br i1 [[v34]], label %[[v35:.*]], label %[[v39:.*]]
207// CHECK-LL: ; <label>:[[v35]]
208// CHECK-LL-NEXT: [[v36:%.*]] = bitcast %class.test1_A* [[tmp54]] to i8*
209// CHECK-LL-NEXT: [[v37:%.*]] = call i8* @__dynamic_cast(i8* [[v36]], i8* bitcast ({{.*}} @_ZTI7test1_A to i8*), i8* bitcast ({{.*}} @_ZTI7test1_D to i8*), i64 -1)
210// CHECK-LL-NEXT: [[v38:%.*]] = bitcast i8* [[v37]] to %class.test1_D*
211// CHECK-LL-NEXT: br label %[[v40:.*]]
212// CHECK-LL: ; <label>:[[v39]]
213// CHECK-LL-NEXT: br label %[[v40]]
214// CHECK-LL: ; <label>:[[v40]]
215// CHECK-LL-NEXT: [[v41:%.*]] = phi %class.test1_D* [ [[v38]], %[[v35]] ], [ null, %[[v39]] ]
216// CHECK-LL-NEXT: store %class.test1_D* [[v41]], %class.test1_D** [[dp53]]
217// CHECK-LL-NEXT: [[tmp55:%.*]] = load %class.test1_D** [[dp53]]
218// CHECK-LL-NEXT: [[cmp56:%.*]] = icmp eq %class.test1_D* [[tmp55]], null
219// CHECK-LL-NEXT: br i1 [[cmp56]], label %[[ifthen57:.*]], label %[[ifelse59:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000220// CHECK-LL: [[ifthen57]]
Mike Stump69456f12010-01-15 00:50:35 +0000221// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 7)
222// CHECK-LL-NEXT: br label %[[ifend61:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000223// CHECK-LL: [[ifelse59]]
Mike Stump69456f12010-01-15 00:50:35 +0000224// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 7)
225// CHECK-LL-NEXT: br label %[[ifend61]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000226// CHECK-LL: [[ifend61]]
Mike Stump69456f12010-01-15 00:50:35 +0000227// CHECK-LL-NEXT: [[tmp63:%.*]] = load %class.test1_A** [[ap37]]
228// CHECK-LL-NEXT: [[v42:%.*]] = icmp ne %class.test1_A* [[tmp63]], null
229// CHECK-LL-NEXT: br i1 [[v42]], label %[[v43:.*]], label %[[v47:.*]]
230// CHECK-LL: ; <label>:[[v43]]
231// CHECK-LL-NEXT: [[v44:%.*]] = bitcast %class.test1_A* [[tmp63]] to i8*
232// CHECK-LL-NEXT: [[v45:%.*]] = call i8* @__dynamic_cast(i8* [[v44]], i8* bitcast ({{.*}} @_ZTI7test1_A to i8*), i8* bitcast ({{.*}} @_ZTI7test1_E to i8*), i64 -1)
233// CHECK-LL-NEXT: [[v46:%.*]] = bitcast i8* [[v45]] to %class.test1_E*
234// CHECK-LL-NEXT: br label %[[v48:.*]]
235// CHECK-LL: ; <label>:[[v47]]
236// CHECK-LL-NEXT: br label %[[v48]]
237// CHECK-LL: ; <label>:[[v48]]
238// CHECK-LL-NEXT: [[v49:%.*]] = phi %class.test1_E* [ [[v46]], %[[v43]] ], [ null, %[[v47]] ]
239// CHECK-LL-NEXT: store %class.test1_E* [[v49]], %class.test1_E** [[ep1]]
240// CHECK-LL-NEXT: [[tmp64:%.*]] = load %class.test1_E** [[ep1]]
241// CHECK-LL-NEXT: [[cmp65:%.*]] = icmp ne %class.test1_E* [[tmp64]], null
242// CHECK-LL-NEXT: br i1 [[cmp65]], label %[[ifthen66:.*]], label %[[ifelse68:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000243// CHECK-LL: [[ifthen66]]
Mike Stump69456f12010-01-15 00:50:35 +0000244// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 8)
245// CHECK-LL-NEXT: br label %[[ifend70:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000246// CHECK-LL: [[ifelse68]]
Mike Stump69456f12010-01-15 00:50:35 +0000247// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 8)
248// CHECK-LL-NEXT: br label %[[ifend70]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000249// CHECK-LL: [[ifend70]]
Mike Stump69456f12010-01-15 00:50:35 +0000250// CHECK-LL-NEXT: store %class.test1_D* @test1_d, %class.test1_D** [[dp]]
251// CHECK-LL-NEXT: [[tmp71:%.*]] = load %class.test1_D** [[dp]]
252// CHECK-LL-NEXT: [[cmp72:%.*]] = icmp eq %class.test1_D* [[tmp71]], @test1_d
253// CHECK-LL-NEXT: br i1 [[cmp72]], label %[[ifthen73:.*]], label %[[ifelse75:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000254// CHECK-LL: [[ifthen73]]
Mike Stump69456f12010-01-15 00:50:35 +0000255// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 9)
256// CHECK-LL-NEXT: br label %[[ifend77:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000257// CHECK-LL: [[ifelse75]]
Mike Stump69456f12010-01-15 00:50:35 +0000258// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 9)
259// CHECK-LL-NEXT: br label %[[ifend77]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000260// CHECK-LL: [[ifend77]]
Mike Stump69456f12010-01-15 00:50:35 +0000261// CHECK-LL-NEXT: store %class.test1_D* @test1_d, %class.test1_D** [[cdp]]
262// CHECK-LL-NEXT: [[tmp79:%.*]] = load %class.test1_D** [[cdp]]
263// CHECK-LL-NEXT: [[cmp80:%.*]] = icmp eq %class.test1_D* [[tmp79]], @test1_d
264// CHECK-LL-NEXT: br i1 [[cmp80]], label %[[ifthen81:.*]], label %[[ifelse83:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000265// CHECK-LL: [[ifthen81]]
Mike Stump69456f12010-01-15 00:50:35 +0000266// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 10)
267// CHECK-LL-NEXT: br label %[[ifend85:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000268// CHECK-LL: [[ifelse83]]
Mike Stump69456f12010-01-15 00:50:35 +0000269// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 10)
270// CHECK-LL-NEXT: br label %[[ifend85]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000271// CHECK-LL: [[ifend85]]
Mike Stump69456f12010-01-15 00:50:35 +0000272// CHECK-LL-NEXT: br i1 false, label %[[v50:.*]], label %[[v53:.*]]
273// CHECK-LL: ; <label>:[[v50]]
274// CHECK-LL-NEXT: [[v51:%.*]] = call i8* @__dynamic_cast(i8* null, i8* bitcast ({{.*}}* @_ZTI7test1_A to i8*), i8* bitcast ({{.*}} @_ZTI7test1_D to i8*), i64 -1)
275// CHECK-LL-NEXT: [[v52:%.*]] = bitcast i8* [[v51]] to %class.test1_D*
276// CHECK-LL-NEXT: br label %[[v54:.*]]
277// CHECK-LL: ; <label>:[[v53]]
278// CHECK-LL-NEXT: br label %[[v54]]
279// CHECK-LL: ; <label>:[[v54]]
280// CHECK-LL-NEXT: [[v55:%.*]] = phi %class.test1_D* [ [[v52]], %[[v50]] ], [ null, %[[v53]] ]
281// CHECK-LL-NEXT: store %class.test1_D* [[v55]], %class.test1_D** [[dp]]
282// CHECK-LL-NEXT: [[tmp86:%.*]] = load %class.test1_D** [[dp]]
283// CHECK-LL-NEXT: [[cmp87:%.*]] = icmp eq %class.test1_D* [[tmp86]], null
284// CHECK-LL-NEXT: br i1 [[cmp87]], label %[[ifthen88:.*]], label %[[ifelse90:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000285// CHECK-LL: [[ifthen88]]
Mike Stump69456f12010-01-15 00:50:35 +0000286// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 11)
287// CHECK-LL-NEXT: br label %[[ifend92:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000288// CHECK-LL: [[ifelse90]]
Mike Stump69456f12010-01-15 00:50:35 +0000289// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 11)
290// CHECK-LL-NEXT: br label %[[ifend92]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000291// CHECK-LL: [[ifend92]]
Mike Stump69456f12010-01-15 00:50:35 +0000292// CHECK-LL-NEXT: br i1 false, label %[[castnull98:.*]], label %[[castnotnull93:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000293// CHECK-LL: [[castnotnull93]]
Mike Stump69456f12010-01-15 00:50:35 +0000294// CHECK-LL-NEXT: [[vtable94:%.*]] = load i8** bitcast (%class.test1_D* @test1_d to i8**)
295// CHECK-LL-NEXT: [[vbaseoffsetptr95:%.*]] = getelementptr i8* [[vtable94]], i64 -24
296// CHECK-LL-NEXT: [[v56:%.*]] = bitcast i8* [[vbaseoffsetptr95]] to i64*
297// CHECK-LL-NEXT: [[vbaseoffset96:%.*]] = load i64* [[v56]]
298// CHECK-LL-NEXT: [[addptr97:%.*]] = getelementptr i8* getelementptr inbounds (%class.test1_D* @test1_d, i32 0, i32 0, i32 0), i64 [[vbaseoffset96]]
299// CHECK-LL-NEXT: [[v57:%.*]] = bitcast i8* [[addptr97]] to %class.test1_A*
300// CHECK-LL-NEXT: br label %[[castend99:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000301// CHECK-LL: [[castnull98]]
Mike Stump69456f12010-01-15 00:50:35 +0000302// CHECK-LL-NEXT: br label %[[castend99]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000303// CHECK-LL: [[castend99]]
Mike Stump69456f12010-01-15 00:50:35 +0000304// CHECK-LL-NEXT: [[v58:%.*]] = phi %class.test1_A* [ [[v57]], %[[castnotnull93]] ], [ null, %[[castnull98]] ]
305// CHECK-LL-NEXT: store %class.test1_A* [[v58]], %class.test1_A** [[ap]]
306// CHECK-LL-NEXT: [[tmp100:%.*]] = load %class.test1_A** [[ap]]
307// CHECK-LL-NEXT: br i1 false, label %[[castnull106:.*]], label %[[castnotnull101:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000308// CHECK-LL: [[castnotnull101]]
Mike Stump69456f12010-01-15 00:50:35 +0000309// CHECK-LL-NEXT: [[vtable102:%.*]] = load i8** bitcast (%class.test1_D* @test1_d to i8**)
310// CHECK-LL-NEXT: [[vbaseoffsetptr103:%.*]] = getelementptr i8* [[vtable102]], i64 -24
311// CHECK-LL-NEXT: [[v59:%.*]] = bitcast i8* [[vbaseoffsetptr103]] to i64*
312// CHECK-LL-NEXT: [[vbaseoffset104:%.*]] = load i64* [[v59]]
313// CHECK-LL-NEXT: [[addptr105:%.*]] = getelementptr i8* getelementptr inbounds (%class.test1_D* @test1_d, i32 0, i32 0, i32 0), i64 [[vbaseoffset104]]
314// CHECK-LL-NEXT: [[v60:%.*]] = bitcast i8* [[addptr105]] to %class.test1_A*
315// CHECK-LL-NEXT: br label %[[castend107:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000316// CHECK-LL: [[castnull106]]
Mike Stump69456f12010-01-15 00:50:35 +0000317// CHECK-LL-NEXT: br label %[[castend107]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000318// CHECK-LL: [[castend107]]
Mike Stump69456f12010-01-15 00:50:35 +0000319// CHECK-LL-NEXT: [[v61:%.*]] = phi %class.test1_A* [ [[v60]], %[[castnotnull101]] ], [ null, %[[castnull106]] ]
320// CHECK-LL-NEXT: [[cmp108:%.*]] = icmp eq %class.test1_A* [[tmp100]], [[v61]]
321// CHECK-LL-NEXT: br i1 [[cmp108]], label %[[ifthen109:.*]], label %[[ifelse111:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000322// CHECK-LL: [[ifthen109]]
Mike Stump69456f12010-01-15 00:50:35 +0000323// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 12)
324// CHECK-LL-NEXT: br label %[[ifend113:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000325// CHECK-LL: [[ifelse111]]
Mike Stump69456f12010-01-15 00:50:35 +0000326// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 12)
327// CHECK-LL-NEXT: br label %[[ifend113]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000328// CHECK-LL: [[ifend113]]
Anders Carlsson905a1002010-01-31 02:39:02 +0000329// CHECK-LL-NEXT: store %class.test1_E* bitcast (%class.test1_F* @test1_f to %class.test1_E*), %class.test1_E** [[ep]]
Mike Stump69456f12010-01-15 00:50:35 +0000330// CHECK-LL-NEXT: [[tmp118:%.*]] = load %class.test1_E** [[ep]]
Anders Carlsson905a1002010-01-31 02:39:02 +0000331// CHECK-LL-NEXT: [[cmp122:%.*]] = icmp eq %class.test1_E* [[tmp118]], bitcast (%class.test1_F* @test1_f to %class.test1_E*) ; <i1> [#uses=1]
332
Mike Stump69456f12010-01-15 00:50:35 +0000333// CHECK-LL-NEXT: br i1 [[cmp122]], label %[[ifthen123:.*]], label %[[ifelse125:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000334// CHECK-LL: [[ifthen123]]
Mike Stump69456f12010-01-15 00:50:35 +0000335// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 13)
336// CHECK-LL-NEXT: br label %[[ifend127:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000337// CHECK-LL: [[ifelse125]]
Mike Stump69456f12010-01-15 00:50:35 +0000338// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 13)
339// CHECK-LL-NEXT: br label %[[ifend127]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000340// CHECK-LL: [[ifend127]]
Mike Stump69456f12010-01-15 00:50:35 +0000341// CHECK-LL-NEXT: [[tmp129:%.*]] = load %class.test1_A** [[ap]]
342// CHECK-LL-NEXT: [[v64:%.*]] = icmp ne %class.test1_A* [[tmp129]], null
343// CHECK-LL-NEXT: br i1 [[v64]], label %[[v65:.*]], label %[[v70:.*]]
344// CHECK-LL: ; <label>:[[v65]]
345// CHECK-LL-NEXT: [[v66:%.*]] = bitcast %class.test1_A* [[tmp129]] to i64**
346// CHECK-LL-NEXT: [[vtable130:%.*]] = load i64** [[v66]]
347// CHECK-LL-NEXT: [[v67:%.*]] = getelementptr inbounds i64* [[vtable130]], i64 -2
348// CHECK-LL-NEXT: [[offsettotop:%.*]] = load i64* [[v67]]
349// CHECK-LL-NEXT: [[v68:%.*]] = bitcast %class.test1_A* [[tmp129]] to i8*
350// CHECK-LL-NEXT: [[v69:%.*]] = getelementptr inbounds i8* [[v68]], i64 [[offsettotop]]
351// CHECK-LL-NEXT: br label %[[v71:.*]]
352// CHECK-LL: ; <label>:[[v70]]
353// CHECK-LL-NEXT: br label %[[v71]]
354// CHECK-LL: ; <label>:[[v71]]
355// CHECK-LL-NEXT: [[v72:%.*]] = phi i8* [ [[v69]], %[[v65]] ], [ null, %[[v70]] ]
356// CHECK-LL-NEXT: store i8* [[v72]], i8** [[vp]]
357// CHECK-LL-NEXT: [[tmp131:%.*]] = load i8** [[vp]]
358// CHECK-LL-NEXT: [[cmp132:%.*]] = icmp eq i8* [[tmp131]], getelementptr inbounds (%class.test1_D* @test1_d, i32 0, i32 0, i32 0)
359// CHECK-LL-NEXT: br i1 [[cmp132]], label %[[ifthen133:.*]], label %[[ifelse135:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000360// CHECK-LL: [[ifthen133]]
Mike Stump69456f12010-01-15 00:50:35 +0000361// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 14)
362// CHECK-LL-NEXT: br label %[[ifend137:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000363// CHECK-LL: [[ifelse135]]
Mike Stump69456f12010-01-15 00:50:35 +0000364// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 14)
365// CHECK-LL-NEXT: br label %[[ifend137]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000366// CHECK-LL: [[ifend137]]
Mike Stump69456f12010-01-15 00:50:35 +0000367// CHECK-LL-NEXT: [[tmp139:%.*]] = load %class.test1_A** [[ap]]
368// CHECK-LL-NEXT: [[v73:%.*]] = icmp ne %class.test1_A* [[tmp139]], null
369// CHECK-LL-NEXT: br i1 [[v73]], label %[[v74:.*]], label %[[v79:.*]]
370// CHECK-LL: ; <label>:[[v74]]
371// CHECK-LL-NEXT: [[v75:%.*]] = bitcast %class.test1_A* [[tmp139]] to i64**
372// CHECK-LL-NEXT: [[vtable140:%.*]] = load i64** [[v75]]
373// CHECK-LL-NEXT: [[v76:%.*]] = getelementptr inbounds i64* [[vtable140]], i64 -2
374// CHECK-LL-NEXT: [[offsettotop141:%.*]] = load i64* [[v76]]
375// CHECK-LL-NEXT: [[v77:%.*]] = bitcast %class.test1_A* [[tmp139]] to i8*
376// CHECK-LL-NEXT: [[v78:%.*]] = getelementptr inbounds i8* [[v77]], i64 [[offsettotop141]]
377// CHECK-LL-NEXT: br label %[[v80:.*]]
378// CHECK-LL: ; <label>:[[v79]]
379// CHECK-LL-NEXT: br label %[[v80]]
380// CHECK-LL: ; <label>:[[v80]]
381// CHECK-LL-NEXT: [[v81:%.*]] = phi i8* [ [[v78]], %[[v74]] ], [ null, %[[v79]] ]
382// CHECK-LL-NEXT: store i8* [[v81]], i8** [[cvp]]
383// CHECK-LL-NEXT: [[tmp142:%.*]] = load i8** [[cvp]]
384// CHECK-LL-NEXT: [[cmp143:%.*]] = icmp eq i8* [[tmp142]], getelementptr inbounds (%class.test1_D* @test1_d, i32 0, i32 0, i32 0)
385// CHECK-LL-NEXT: br i1 [[cmp143]], label %[[ifthen144:.*]], label %[[ifelse146:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000386// CHECK-LL: [[ifthen144]]
Mike Stump69456f12010-01-15 00:50:35 +0000387// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 15)
388// CHECK-LL-NEXT: br label %[[ifend148:.*]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000389// CHECK-LL: [[ifelse146]]
Mike Stump69456f12010-01-15 00:50:35 +0000390// CHECK-LL-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 15)
391// CHECK-LL-NEXT: br label %[[ifend148]]
Benjamin Kramer5bb4d982010-01-21 18:14:21 +0000392// CHECK-LL: [[ifend148]]
Mike Stump39f36e32009-11-16 23:36:30 +0000393// CHECK-LL-NEXT: ret void