1 /// Check that the offset to top calculation is adjusted to account for the
2 /// omitted RTTI entry.
4 // RUN: %clang_cc1 %s -triple=aarch64-unknown-linux-gnu -fexperimental-omit-vtable-rtti -fno-rtti -S -o - -emit-llvm | FileCheck -check-prefixes=POINTER %s
5 // RUN: %clang_cc1 %s -triple=aarch64-unknown-linux-gnu -fexperimental-relative-c++-abi-vtables -fexperimental-omit-vtable-rtti -fno-rtti -S -o - -emit-llvm | FileCheck -check-prefixes=RELATIVE %s
7 /// Some important things to check:
8 /// - The n16 here represents the virtual thunk size. Normally this would be 24
9 /// to represent 3 components (offset to top, RTTI component, vcall offset),
10 /// but since one 8-byte component is removed, this is now 16.
11 // POINTER-LABEL: @_ZTv0_n16_N7Derived1fEi(
12 // POINTER-NEXT: entry:
13 // POINTER: [[vtable:%.+]] = load ptr, ptr %this1, align 8
15 /// Same here - When getting the vbase offset, we subtract 2 pointer sizes
17 // POINTER-NEXT: [[vbase_offset_ptr:%.+]] = getelementptr inbounds i8, ptr [[vtable]], i64 -16
18 // POINTER-NEXT: [[vbase_offset:%.+]] = load i64, ptr [[vbase_offset_ptr]], align 8
19 // POINTER-NEXT: [[adj_this:%.+]] = getelementptr inbounds i8, ptr %this1, i64 [[vbase_offset]]
20 // POINTER: [[call:%.+]] = tail call noundef i32 @_ZN7Derived1fEi(ptr noundef{{[^,]*}} [[adj_this]], i32 noundef {{.*}})
21 // POINTER: ret i32 [[call]]
23 /// For relative vtables, it's almost the same except the offset sizes are
25 // RELATIVE-LABEL: @_ZTv0_n8_N7Derived1fEi(
26 // RELATIVE-NEXT: entry:
27 // RELATIVE: [[vtable:%.+]] = load ptr, ptr %this1, align 8
28 // RELATIVE-NEXT: [[vbase_offset_ptr:%.+]] = getelementptr inbounds i8, ptr [[vtable]], i64 -8
29 // RELATIVE-NEXT: [[vbase_offset:%.+]] = load i32, ptr [[vbase_offset_ptr]], align 4
30 // RELATIVE-NEXT: [[adj_this:%.+]] = getelementptr inbounds i8, ptr %this1, i32 [[vbase_offset]]
31 // RELATIVE: [[call:%.+]] = tail call noundef i32 @_ZN7Derived1fEi(ptr noundef{{[^,]*}} [[adj_this]], i32 noundef {{.*}})
32 // RELATIVE: ret i32 [[call]]
42 class Derived
: public virtual Base
{
50 int Base::f(int x
) { return x
+ 1; }
51 int Derived::f(int x
) { return x
+ 2; }