126 lines · cpp
1// RUN: %clang_cc1 -std=c++20 -triple x86_64-linux-gnu %s -emit-llvm -o - | FileCheck %s2 3// CHECK-DAG: @[[STR_0:.*]] = {{.*}} [3 x i8] c"%s\00",4// CHECK-DAG: @[[STR_1:.*]] = {{.*}} [2 x i8] c"C\00",5// CHECK-DAG: @[[STR_2:.*]] = {{.*}} [4 x i8] c" {\0A\00",6// CHECK-DAG: @[[STR_3:.*]] = {{.*}} [5 x i8] c"%s%s\00",7// CHECK-DAG: @[[STR_4:.*]] = {{.*}} [3 x i8] c" \00",8// CHECK-DAG: @[[STR_5:.*]] = {{.*}} [2 x i8] c"A\00",9// CHECK-DAG: @[[STR_6:.*]] = {{.*}} [14 x i8] c"%s%s %s = %d\0A\00",10// CHECK-DAG: @[[STR_7:.*]] = {{.*}} [5 x i8] c" \00",11// CHECK-DAG: @[[STR_8:.*]] = {{.*}} [4 x i8] c"int\00",12// CHECK-DAG: @[[STR_9:.*]] = {{.*}} [2 x i8] c"n\00",13// CHECK-DAG: @[[STR_10:.*]] = {{.*}} [5 x i8] c"%s}\0A\00",14// CHECK-DAG: @[[STR_11:.*]] = {{.*}} [2 x i8] c"B\00",15// CHECK-DAG: @[[STR_12:.*]] = {{.*}} [10 x i8] c"%s%s %s =\00",16// CHECK-DAG: @[[STR_13:.*]] = {{.*}} [2 x i8] c"a\00",17// CHECK-DAG: @[[STR_14:.*]] = {{.*}} [15 x i8] c"%s%s %s = *%p\0A\00",18// CHECK-DAG: @[[STR_15:.*]] = {{.*}} [2 x i8] c"X\00",19// CHECK-DAG: @[[STR_16:.*]] = {{.*}} [2 x i8] c"x\00",20// CHECK-DAG: @[[STR_17:.*]] = {{.*}} [2 x i8] c"f\00",21// CHECK-DAG: @[[STR_18:.*]] = {{.*}} [2 x i8] c"g\00",22// CHECK-DAG: @[[STR_19:.*]] = {{.*}} [3 x i8] c"}\0A\00",23 24struct A { int n; };25struct B { int n; };26class X { private: int n; };27struct C : A, B { A a; X x; int f, g; };28 29template<typename ...T> int format(int a, const char *str, T ...);30 31int f();32 33// CHECK-LABEL: define {{.*}} @_Z1gR1C(34void g(C &c) {35 // CHECK: call {{.*}} @_Z1fv()36 // CHECK: call {{.*}} @_Z6formatIJPKcEEiiS1_DpT_(i32 {{.*}}, ptr noundef @[[STR_0]], ptr noundef @[[STR_1]])37 38 // CHECK: call {{.*}} @_Z1fv()39 // CHECK: call {{.*}} @_Z6formatIJEEiiPKcDpT_(i32 {{.*}}, ptr noundef @[[STR_2]])40 41 // CHECK: call {{.*}} @_Z1fv()42 // CHECK: call {{.*}} @_Z6formatIJPKcS1_EEiiS1_DpT_(i32 {{.*}}, ptr noundef @[[STR_3]], ptr noundef @[[STR_4]], ptr noundef @[[STR_5]])43 44 // CHECK: call {{.*}} @_Z1fv()45 // CHECK: call {{.*}} @_Z6formatIJEEiiPKcDpT_(i32 {{.*}}, ptr noundef @[[STR_2]])46 47 // CHECK: call {{.*}} @_Z1fv()48 // CHECK: %[[VAL_n:.*]] = getelementptr inbounds nuw %[[VAL_struct_A:.*]], ptr %[[VAL_0:.*]], i32 0, i32 049 // CHECK: %[[VAL_1:.*]] = load i32, ptr %[[VAL_n]],50 // CHECK: call {{.*}} @_Z6formatIJPKcS1_S1_iEEiiS1_DpT_(i32 {{.*}}, ptr noundef @[[STR_6]], ptr noundef @[[STR_7]], ptr noundef @[[STR_8]], ptr noundef @[[STR_9]], i32 noundef %[[VAL_1]])51 52 // CHECK: call {{.*}} @_Z1fv()53 // CHECK: call {{.*}} @_Z6formatIJPKcEEiiS1_DpT_(i32 {{.*}}, ptr noundef @[[STR_10]], ptr noundef @[[STR_4]])54 55 // CHECK: call {{.*}} @_Z1fv()56 // CHECK: call {{.*}} @_Z6formatIJPKcS1_EEiiS1_DpT_(i32 {{.*}}, ptr noundef @[[STR_3]], ptr noundef @[[STR_4]], ptr noundef @[[STR_11]])57 58 // CHECK: %[[VAL_2:.*]] = icmp eq ptr %[[VAL_0]], null59 // CHECK: br i1 %[[VAL_2]],60 61 // CHECK: %[[VAL_add_ptr:.*]] = getelementptr inbounds i8, ptr %[[VAL_0]], i64 462 // CHECK: br label63 64 // CHECK: %[[VAL_cast_result:.*]] = phi65 // CHECK: call {{.*}} @_Z1fv()66 // CHECK: call {{.*}} @_Z6formatIJEEiiPKcDpT_(i32 {{.*}}, ptr noundef @[[STR_2]])67 68 // CHECK: call {{.*}} @_Z1fv()69 // CHECK: %[[VAL_n17:.*]] = getelementptr inbounds nuw %[[VAL_struct_B:.*]], ptr %[[VAL_cast_result]], i32 0, i32 070 // CHECK: %[[VAL_3:.*]] = load i32, ptr %[[VAL_n17]],71 // CHECK: call {{.*}} @_Z6formatIJPKcS1_S1_iEEiiS1_DpT_(i32 {{.*}}, ptr noundef @[[STR_6]], ptr noundef @[[STR_7]], ptr noundef @[[STR_8]], ptr noundef @[[STR_9]], i32 noundef %[[VAL_3]])72 73 // CHECK: call {{.*}} @_Z1fv()74 // CHECK: call {{.*}} @_Z6formatIJPKcEEiiS1_DpT_(i32 {{.*}}, ptr noundef @[[STR_10]], ptr noundef @[[STR_4]])75 76 // CHECK: call {{.*}} @_Z1fv()77 // CHECK: call {{.*}} @_Z6formatIJPKcS1_S1_EEiiS1_DpT_(i32 {{.*}}, ptr noundef @[[STR_12]], ptr noundef @[[STR_4]], ptr noundef @[[STR_5]], ptr noundef @[[STR_13]])78 79 // CHECK: %[[VAL_a:.*]] = getelementptr inbounds nuw %[[VAL_struct_C:.*]], ptr %[[VAL_0]], i32 0, i32 280 // CHECK: call {{.*}} @_Z1fv()81 // CHECK: call {{.*}} @_Z6formatIJEEiiPKcDpT_(i32 {{.*}}, ptr noundef @[[STR_2]])82 83 // CHECK: call {{.*}} @_Z1fv()84 // CHECK: %[[VAL_n26:.*]] = getelementptr inbounds nuw %[[VAL_struct_A]], ptr %[[VAL_a]], i32 0, i32 085 // CHECK: %[[VAL_4:.*]] = load i32, ptr %[[VAL_n26]],86 // CHECK: call {{.*}} @_Z6formatIJPKcS1_S1_iEEiiS1_DpT_(i32 {{.*}}, ptr noundef @[[STR_6]], ptr noundef @[[STR_7]], ptr noundef @[[STR_8]], ptr noundef @[[STR_9]], i32 noundef %[[VAL_4]])87 88 // CHECK: call {{.*}} @_Z1fv()89 // CHECK: call {{.*}} @_Z6formatIJPKcEEiiS1_DpT_(i32 {{.*}}, ptr noundef @[[STR_10]], ptr noundef @[[STR_4]])90 91 // CHECK: call {{.*}} @_Z1fv()92 // CHECK: %[[VAL_x:.*]] = getelementptr inbounds nuw %[[VAL_struct_C]], ptr %[[VAL_0]], i32 0, i32 393 // CHECK: call {{.*}} @_Z6formatIJPKcS1_S1_P1XEEiiS1_DpT_(i32 {{.*}}, ptr noundef @[[STR_14]], ptr noundef @[[STR_4]], ptr noundef @[[STR_15]], ptr noundef @[[STR_16]], ptr noundef %[[VAL_x]])94 95 // CHECK: call {{.*}} @_Z1fv()96 // CHECK: %[[VAL_f:.*]] = getelementptr inbounds nuw %[[VAL_struct_C]], ptr %[[VAL_0]], i32 0, i32 497 // CHECK: %[[VAL_5:.*]] = load i32, ptr %[[VAL_f]],98 // CHECK: call {{.*}} @_Z6formatIJPKcS1_S1_iEEiiS1_DpT_(i32 {{.*}}, ptr noundef @[[STR_6]], ptr noundef @[[STR_4]], ptr noundef @[[STR_8]], ptr noundef @[[STR_17]], i32 noundef %[[VAL_5]])99 100 // CHECK: call {{.*}} @_Z1fv()101 // CHECK: %[[VAL_g:.*]] = getelementptr inbounds nuw %[[VAL_struct_C]], ptr %[[VAL_0]], i32 0, i32 5102 // CHECK: %[[VAL_6:.*]] = load i32, ptr %[[VAL_g]],103 // CHECK: call {{.*}} @_Z6formatIJPKcS1_S1_iEEiiS1_DpT_(i32 {{.*}}, ptr noundef @[[STR_6]], ptr noundef @[[STR_4]], ptr noundef @[[STR_8]], ptr noundef @[[STR_18]], i32 noundef %[[VAL_6]])104 105 // CHECK: call {{.*}} @_Z1fv()106 // CHECK: call {{.*}} @_Z6formatIJEEiiPKcDpT_(i32 {{.*}}, ptr noundef @[[STR_19]])107 __builtin_dump_struct(&c, format, f());108}109 110// CHECK-LABEL: define {{.*}} @_Z1hR1X(111void h(X &x) {112 // CHECK: %[[VAL_x_addr:.*]] = alloca ptr,113 // CHECK: store ptr %[[VAL_x]], ptr %[[VAL_x_addr]],114 // CHECK: call {{.*}} @_Z6formatIJPKcEEiiS1_DpT_(i32 noundef 0, ptr noundef @[[STR_0]], ptr noundef @[[STR_15]])115 116 // CHECK: %[[VAL_0:.*]] = load ptr, ptr %[[VAL_x_addr]],117 // CHECK: call {{.*}} @_Z6formatIJEEiiPKcDpT_(i32 noundef 0, ptr noundef @[[STR_2]])118 119 // CHECK: %[[VAL_n:.*]] = getelementptr inbounds nuw %[[VAL_class_X:.*]], ptr %[[VAL_0]], i32 0, i32 0120 // CHECK: %[[VAL_1:.*]] = load i32, ptr %[[VAL_n]],121 // CHECK: call {{.*}} @_Z6formatIJPKcS1_S1_iEEiiS1_DpT_(i32 noundef 0, ptr noundef @[[STR_6]], ptr noundef @[[STR_4]], ptr noundef @[[STR_8]], ptr noundef @[[STR_9]], i32 noundef %[[VAL_1]])122 123 // CHECK: call {{.*}} @_Z6formatIJEEiiPKcDpT_(i32 noundef 0, ptr noundef @[[STR_19]])124 __builtin_dump_struct(&x, format, 0);125}126