// RUN: cir-translate %s -cir-to-llvmir --target x86_64-unknown-linux-gnu -o %t.ll // RUN: FileCheck %s --input-file=%t.ll // Test the lowering of the two forms of vtt.address_point op, as they will // appear in constructors. !u8i = !cir.int !void = !cir.void !rec_A = !cir.struct<"A" {!u8i}> !rec_B = !cir.struct<"B" {!cir.vptr}> !rec_C = !cir.struct<"C" {!rec_B}> !rec_anon_struct = !cir.struct<{!cir.array x 3>}> module { cir.func private @_ZN1AC2Ev(!cir.ptr) cir.func private @_ZN1BC2Ev(!cir.ptr, !cir.ptr>) cir.func dso_local @_ZN1CC2Ev(%arg0: !cir.ptr, %arg1: !cir.ptr>) { %0 = cir.alloca !cir.ptr, !cir.ptr>, ["this", init] {alignment = 8 : i64} %1 = cir.alloca !cir.ptr>, !cir.ptr>>, ["vtt", init] {alignment = 8 : i64} cir.store %arg0, %0 : !cir.ptr, !cir.ptr> cir.store %arg1, %1 : !cir.ptr>, !cir.ptr>> %2 = cir.load %0 : !cir.ptr>, !cir.ptr %3 = cir.load align(8) %1 : !cir.ptr>>, !cir.ptr> %4 = cir.base_class_addr %2 : !cir.ptr nonnull [0] -> !cir.ptr %5 = cir.vtt.address_point %3 : !cir.ptr>, offset = 1 -> !cir.ptr> cir.call @_ZN1BC2Ev(%4, %5) : (!cir.ptr, !cir.ptr>) -> () %6 = cir.vtt.address_point %3 : !cir.ptr>, offset = 0 -> !cir.ptr> %7 = cir.cast bitcast %6 : !cir.ptr> -> !cir.ptr %8 = cir.load align(8) %7 : !cir.ptr, !cir.vptr %9 = cir.vtable.get_vptr %2 : !cir.ptr -> !cir.ptr cir.store align(8) %8, %9 : !cir.vptr, !cir.ptr cir.return } // CHECK: define{{.*}} void @_ZN1CC2Ev // CHECK: %[[VTT:.*]] = getelementptr inbounds ptr, ptr %{{.*}}, i32 1 // CHECK: call void @_ZN1BC2Ev(ptr %{{.*}}, ptr %[[VTT]]) cir.global linkonce_odr dso_local @_ZTV1C = #cir.vtable<{#cir.const_array<[#cir.ptr : !cir.ptr, #cir.ptr : !cir.ptr, #cir.ptr : !cir.ptr]> : !cir.array x 3>}> : !rec_anon_struct {alignment = 8 : i64} cir.global linkonce_odr @_ZTT1C = #cir.const_array<[#cir.global_view<@_ZTV1C, [0 : i32, 3 : i32]> : !cir.ptr, #cir.global_view<@_ZTC1C0_1B, [0 : i32, 3 : i32]> : !cir.ptr]> : !cir.array x 2> {alignment = 8 : i64} cir.func dso_local @_ZN1CC1Ev(%arg0: !cir.ptr) { %0 = cir.alloca !cir.ptr, !cir.ptr>, ["this", init] {alignment = 8 : i64} cir.store %arg0, %0 : !cir.ptr, !cir.ptr> %1 = cir.load %0 : !cir.ptr>, !cir.ptr %2 = cir.base_class_addr %1 : !cir.ptr nonnull [0] -> !cir.ptr cir.call @_ZN1AC2Ev(%2) : (!cir.ptr) -> () %3 = cir.base_class_addr %1 : !cir.ptr nonnull [0] -> !cir.ptr %4 = cir.vtt.address_point @_ZTT1C, offset = 1 -> !cir.ptr> cir.call @_ZN1BC2Ev(%3, %4) : (!cir.ptr, !cir.ptr>) -> () %5 = cir.vtable.address_point(@_ZTV1C, address_point = ) : !cir.vptr %6 = cir.vtable.get_vptr %1 : !cir.ptr -> !cir.ptr cir.store align(8) %5, %6 : !cir.vptr, !cir.ptr cir.return } // CHECK: define{{.*}} void @_ZN1CC1Ev // CHECK: store ptr getelementptr inbounds nuw (i8, ptr @_ZTV1C, i64 24), ptr %{{.*}} cir.global linkonce_odr dso_local @_ZTC1C0_1B = #cir.const_record<{#cir.const_array<[#cir.ptr : !cir.ptr, #cir.ptr : !cir.ptr, #cir.ptr : !cir.ptr]> : !cir.array x 3>}> : !rec_anon_struct {alignment = 8 : i64} }