1 // Member pointer to virtual function.
3 // RUN: %clang_cc1 %s -triple=aarch64-unknown-fuchsia -O3 -S -o - -emit-llvm | FileCheck %s
5 // CHECK: define{{.*}} void @_Z4funcP1AMS_FvvE(ptr noundef %a, [2 x i64] %fn.coerce) local_unnamed_addr
7 // CHECK-NEXT: [[fn_ptr:%.+]] = extractvalue [2 x i64] %fn.coerce, 0
8 // CHECK-NEXT: [[adjust:%.+]] = extractvalue [2 x i64] %fn.coerce, 1
9 // CHECK-NEXT: [[this_adj:%.+]] = getelementptr inbounds i8, ptr %a, i64 [[adjust]]
10 // CHECK-NEXT: [[virtbit:%.+]] = and i64 [[fn_ptr]], 1
11 // CHECK-NEXT: [[isvirt:%.+]] = icmp eq i64 [[virtbit]], 0
12 // CHECK-NEXT: br i1 [[isvirt]], label %[[nonvirt:.+]], label %[[virt:.+]]
15 // The loading of the virtual function here should be replaced with a llvm.load.relative() call.
16 // CHECK-NEXT: [[vtable:%.+]] = load ptr, ptr [[this_adj]], align 8
17 // CHECK-NEXT: [[offset:%.+]] = add nsw i64 [[fn_ptr]], -1
18 // CHECK-NEXT: [[ptr:%.+]] = tail call ptr @llvm.load.relative.i64(ptr [[vtable]], i64 [[offset]])
19 // CHECK-NEXT: br label %[[memptr_end:.+]]
20 // CHECK: [[nonvirt]]:
21 // CHECK-NEXT: [[method2:%.+]] = inttoptr i64 [[fn_ptr]] to ptr
22 // CHECK-NEXT: br label %[[memptr_end]]
23 // CHECK: [[memptr_end]]:
24 // CHECK-NEXT: [[method3:%.+]] = phi ptr [ [[ptr]], %[[virt]] ], [ [[method2]], %[[nonvirt]] ]
25 // CHECK-NEXT: tail call void [[method3]](ptr {{[^,]*}} [[this_adj]])
26 // CHECK-NEXT: ret void
39 typedef void (A::*A_foo
)();
41 void func(A
*a
, A_foo fn
) {