171568a9eSLeonard Chan // Check that the pointer adjustment from the virtual base offset is loaded as a
271568a9eSLeonard Chan // 32-bit int.
371568a9eSLeonard Chan 
4*532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers %s -triple=aarch64-unknown-fuchsia -S -o - -emit-llvm | FileCheck %s
571568a9eSLeonard Chan 
671568a9eSLeonard Chan // CHECK-LABEL: @_ZTv0_n12_N7Derived1fEi(
771568a9eSLeonard Chan // CHECK-NEXT:  entry:
871568a9eSLeonard Chan // CHECK:        [[this:%.+]] = bitcast %class.Derived* %this1 to i8*
971568a9eSLeonard Chan // CHECK-NEXT:   [[this2:%.+]] = bitcast i8* [[this]] to i8**
1071568a9eSLeonard Chan // CHECK-NEXT:   [[vtable:%.+]] = load i8*, i8** [[this2]], align 8
1171568a9eSLeonard Chan // CHECK-NEXT:   [[vbase_offset_ptr:%.+]] = getelementptr inbounds i8, i8* [[vtable]], i64 -12
1271568a9eSLeonard Chan // CHECK-NEXT:   [[vbase_offset_ptr2:%.+]] = bitcast i8* [[vbase_offset_ptr]] to i32*
1371568a9eSLeonard Chan // CHECK-NEXT:   [[vbase_offset:%.+]] = load i32, i32* [[vbase_offset_ptr2]], align 4
1471568a9eSLeonard Chan // CHECK-NEXT:   [[adj_this:%.+]] = getelementptr inbounds i8, i8* [[this]], i32 [[vbase_offset]]
1571568a9eSLeonard Chan // CHECK-NEXT:   [[adj_this2:%.+]] = bitcast i8* [[adj_this]] to %class.Derived*
161b1c8d83Shyeongyu kim // CHECK:        [[call:%.+]] = tail call noundef i32 @_ZN7Derived1fEi(%class.Derived* noundef{{[^,]*}} [[adj_this2]], i32 noundef {{.*}})
1771568a9eSLeonard Chan // CHECK:        ret i32 [[call]]
1871568a9eSLeonard Chan 
1971568a9eSLeonard Chan class Base {
2071568a9eSLeonard Chan public:
2171568a9eSLeonard Chan   virtual int f(int x);
2271568a9eSLeonard Chan 
2371568a9eSLeonard Chan private:
2471568a9eSLeonard Chan   long x;
2571568a9eSLeonard Chan };
2671568a9eSLeonard Chan 
2771568a9eSLeonard Chan class Derived : public virtual Base {
2871568a9eSLeonard Chan public:
2971568a9eSLeonard Chan   virtual int f(int x);
3071568a9eSLeonard Chan 
3171568a9eSLeonard Chan private:
3271568a9eSLeonard Chan   long y;
3371568a9eSLeonard Chan };
3471568a9eSLeonard Chan 
f(int x)3571568a9eSLeonard Chan int Base::f(int x) { return x + 1; }
f(int x)3671568a9eSLeonard Chan int Derived::f(int x) { return x + 2; }
37