• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Check that the pointer adjustment from the virtual base offset is loaded as a
2 // 32-bit int.
3 
4 // RUN: %clang_cc1 %s -triple=aarch64-unknown-fuchsia -S -o - -emit-llvm -fexperimental-relative-c++-abi-vtables | FileCheck %s
5 
6 // CHECK-LABEL: @_ZTv0_n12_N7Derived1fEi(
7 // CHECK-NEXT:  entry:
8 // CHECK:        [[this:%.+]] = bitcast %class.Derived* %this1 to i8*
9 // CHECK-NEXT:   [[this2:%.+]] = bitcast i8* [[this]] to i8**
10 // CHECK-NEXT:   [[vtable:%.+]] = load i8*, i8** [[this2]], align 8
11 // CHECK-NEXT:   [[vbase_offset_ptr:%.+]] = getelementptr inbounds i8, i8* [[vtable]], i64 -12
12 // CHECK-NEXT:   [[vbase_offset_ptr2:%.+]] = bitcast i8* [[vbase_offset_ptr]] to i32*
13 // CHECK-NEXT:   [[vbase_offset:%.+]] = load i32, i32* [[vbase_offset_ptr2]], align 4
14 // CHECK-NEXT:   [[adj_this:%.+]] = getelementptr inbounds i8, i8* [[this]], i32 [[vbase_offset]]
15 // CHECK-NEXT:   [[adj_this2:%.+]] = bitcast i8* [[adj_this]] to %class.Derived*
16 // CHECK:        [[call:%.+]] = tail call i32 @_ZN7Derived1fEi(%class.Derived* {{[^,]*}} [[adj_this2]], i32 {{.*}})
17 // CHECK:        ret i32 [[call]]
18 
19 class Base {
20 public:
21   virtual int f(int x);
22 
23 private:
24   long x;
25 };
26 
27 class Derived : public virtual Base {
28 public:
29   virtual int f(int x);
30 
31 private:
32   long y;
33 };
34 
f(int x)35 int Base::f(int x) { return x + 1; }
f(int x)36 int Derived::f(int x) { return x + 2; }
37