1 // RUN: %clang_cc1 -emit-llvm %s -o - -triple i686-pc-linux-gnu | FileCheck %s
2 // RUN: %clang_cc1 -emit-llvm %s -o - -triple i686-pc-win32 | FileCheck -check-prefix MSVC %s
4 struct A
{ int a
; virtual int aa(); };
5 struct B
{ int b
; virtual int bb(); };
6 struct C
: virtual A
, virtual B
{ int c
; virtual int aa(); virtual int bb(); };
7 struct AA
{ int a
; virtual int aa(); };
8 struct BB
{ int b
; virtual int bb(); };
9 struct CC
: AA
, BB
{ virtual int aa(); virtual int bb(); virtual int cc(); };
10 struct D
: virtual C
, virtual CC
{ int e
; };
15 // CHECK: @_Z1av() [[NUW:#[0-9]+]]
16 // CHECK: [[VBASEOFFSETPTRA:%[a-zA-Z0-9\.]+]] = getelementptr i8, ptr {{.*}}, i64 -16
17 // CHECK: load i32, ptr [[VBASEOFFSETPTRA]]
20 // MSVC: @"?a@@YAPAUA@@XZ"() [[NUW:#[0-9]+]] {
21 // MSVC: %[[vbptr_off:.*]] = getelementptr inbounds i8, ptr {{.*}}, i32 0
22 // MSVC: %[[vbtable:.*]] = load ptr, ptr %[[vbptr_off]]
23 // MSVC: %[[entry:.*]] = getelementptr inbounds i32, ptr {{.*}}, i32 1
24 // MSVC: %[[offset:.*]] = load i32, ptr %[[entry]]
25 // MSVC: add nsw i32 0, %[[offset]]
29 // CHECK: @_Z1bv() [[NUW]]
30 // CHECK: [[VBASEOFFSETPTRA:%[a-zA-Z0-9\.]+]] = getelementptr i8, ptr {{.*}}, i64 -20
31 // CHECK: load i32, ptr [[VBASEOFFSETPTRA]]
34 // Same as 'a' except we use a different vbtable offset.
35 // MSVC: @"?b@@YAPAUB@@XZ"() [[NUW:#[0-9]+]] {
36 // MSVC: %[[vbptr_off:.*]] = getelementptr inbounds i8, ptr {{.*}}, i32 0
37 // MSVC: %[[vbtable:.*]] = load ptr, ptr %[[vbptr_off]]
38 // MSVC: %[[entry:.*]] = getelementptr inbounds i32, ptr {{.*}}, i32 2
39 // MSVC: %[[offset:.*]] = load i32, ptr %[[entry]]
40 // MSVC: add nsw i32 0, %[[offset]]
45 // CHECK: @_Z1cv() [[NUW]]
46 // CHECK: [[VBASEOFFSETPTRC:%[a-zA-Z0-9\.]+]] = getelementptr i8, ptr {{.*}}, i64 -24
47 // CHECK: [[VBASEOFFSETC:%[a-zA-Z0-9\.]+]] = load i32, ptr [[VBASEOFFSETPTRC]]
48 // CHECK: add i32 [[VBASEOFFSETC]], 8
51 // Same as 'a' except we use a different vbtable offset.
52 // MSVC: @"?c@@YAPAUBB@@XZ"() [[NUW:#[0-9]+]] {
53 // MSVC: %[[vbptr_off:.*]] = getelementptr inbounds i8, ptr {{.*}}, i32 0
54 // MSVC: %[[vbtable:.*]] = load ptr, ptr %[[vbptr_off]]
55 // MSVC: %[[entry:.*]] = getelementptr inbounds i32, ptr {{.*}}, i32 4
56 // MSVC: %[[offset:.*]] = load i32, ptr %[[entry]]
57 // MSVC: add nsw i32 0, %[[offset]]
60 // Put the vbptr at a non-zero offset inside a non-virtual base.
62 struct F
: E
, D
{ int f
; };
68 // Same as 'c' except the vbptr offset is 4, changing the initial GEP and the
70 // MSVC: @"?d@@YAPAUBB@@XZ"() [[NUW:#[0-9]+]] {
71 // MSVC: %[[vbptr_off:.*]] = getelementptr inbounds i8, ptr {{.*}}, i32 4
72 // MSVC: %[[vbtable:.*]] = load ptr, ptr %[[vbptr_off]]
73 // MSVC: %[[entry:.*]] = getelementptr inbounds i32, ptr {{.*}}, i32 4
74 // MSVC: %[[offset:.*]] = load i32, ptr %[[entry]]
75 // MSVC: add nsw i32 4, %[[offset]]
78 // CHECK: attributes [[NUW]] = { mustprogress noinline nounwind{{.*}} }