brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.9 KiB · 67fcabc Raw
200 lines · plain
1; RUN: opt < %s -passes=jump-threading -S | FileCheck %s2; Test whether two consecutive switches with identical structures assign the3; proper value to the proper variable.  This is really testing4; Instruction::isIdenticalToWhenDefined, as previously that function was5; returning true if the value part of the operands of two phis were identical,6; even if the incoming blocks were not.7; NB: this function should be pruned down more.8 9%struct._GList = type { ptr, ptr, ptr }10%struct.filter_def = type { ptr, ptr }11 12@capture_filters = external hidden global ptr, align 813@display_filters = external hidden global ptr, align 814@.str2 = external hidden unnamed_addr constant [10 x i8], align 115@__PRETTY_FUNCTION__.copy_filter_list = external hidden unnamed_addr constant [62 x i8], align 116@.str12 = external hidden unnamed_addr constant [22 x i8], align 117@.str13 = external hidden unnamed_addr constant [31 x i8], align 118@capture_edited_filters = external hidden global ptr, align 819@display_edited_filters = external hidden global ptr, align 820@__PRETTY_FUNCTION__.get_filter_list = external hidden unnamed_addr constant [44 x i8], align 121 22declare void @g_assertion_message(ptr, ptr, i32, ptr, ptr) noreturn23 24declare void @g_free(ptr)25 26declare ptr @g_list_first(ptr)27 28declare noalias ptr @g_malloc(i64)29 30define void @copy_filter_list(i32 %dest_type, i32 %src_type) nounwind uwtable ssp {31entry:32  br label %do.body33 34do.body:                                          ; preds = %entry35  %cmp = icmp ne i32 %dest_type, %src_type36  br i1 %cmp, label %if.then, label %if.else37 38if.then:                                          ; preds = %do.body39  br label %if.end40 41if.else:                                          ; preds = %do.body42  call void @g_assertion_message_expr(ptr null, ptr @.str2, i32 581, ptr @__PRETTY_FUNCTION__.copy_filter_list, ptr @.str12) noreturn43  unreachable44 45if.end:                                           ; preds = %if.then46  br label %do.end47 48do.end:                                           ; preds = %if.end49  switch i32 %dest_type, label %sw.default.i [50    i32 0, label %sw.bb.i51    i32 1, label %sw.bb1.i52    i32 2, label %sw.bb2.i53    i32 3, label %sw.bb3.i54  ]55 56sw.bb.i:                                          ; preds = %do.end57  br label %get_filter_list.exit58 59sw.bb1.i:                                         ; preds = %do.end60  br label %get_filter_list.exit61 62sw.bb2.i:                                         ; preds = %do.end63  br label %get_filter_list.exit64 65sw.bb3.i:                                         ; preds = %do.end66  br label %get_filter_list.exit67 68sw.default.i:                                     ; preds = %do.end69  call void @g_assertion_message(ptr null, ptr @.str2, i32 408, ptr @__PRETTY_FUNCTION__.get_filter_list, ptr null) noreturn nounwind70  unreachable71 72get_filter_list.exit:                             ; preds = %sw.bb3.i, %sw.bb2.i, %sw.bb1.i, %sw.bb.i73  %0 = phi ptr [ @display_edited_filters, %sw.bb3.i ], [ @capture_edited_filters, %sw.bb2.i ], [ @display_filters, %sw.bb1.i ], [ @capture_filters, %sw.bb.i ]74  switch i32 %src_type, label %sw.default.i5 [75    i32 0, label %sw.bb.i176    i32 1, label %sw.bb1.i277    i32 2, label %sw.bb2.i378    i32 3, label %sw.bb3.i479  ]80 81sw.bb.i1:                                         ; preds = %get_filter_list.exit82  br label %get_filter_list.exit683 84sw.bb1.i2:                                        ; preds = %get_filter_list.exit85  br label %get_filter_list.exit686 87sw.bb2.i3:                                        ; preds = %get_filter_list.exit88  br label %get_filter_list.exit689 90sw.bb3.i4:                                        ; preds = %get_filter_list.exit91  br label %get_filter_list.exit692 93sw.default.i5:                                    ; preds = %get_filter_list.exit94  call void @g_assertion_message(ptr null, ptr @.str2, i32 408, ptr @__PRETTY_FUNCTION__.get_filter_list, ptr null) noreturn nounwind95  unreachable96 97; CHECK: get_filter_list.exit98get_filter_list.exit6:                            ; preds = %sw.bb3.i4, %sw.bb2.i3, %sw.bb1.i2, %sw.bb.i199  %1 = phi ptr [ @display_edited_filters, %sw.bb3.i4 ], [ @capture_edited_filters, %sw.bb2.i3 ], [ @display_filters, %sw.bb1.i2 ], [ @capture_filters, %sw.bb.i1 ]100; CHECK: %2 = load101  %2 = load ptr, ptr %1, align 8102; We should have jump-threading insert an additional load here for the value103; coming out of the first switch, which is picked up by a subsequent phi104; CHECK: %.pr = load ptr, ptr %0105; CHECK-NEXT:  br label %while.cond106  br label %while.cond107 108; CHECK: while.cond109while.cond:                                       ; preds = %while.body, %get_filter_list.exit6110; CHECK: {{= phi .*%.pr}}111  %3 = load ptr, ptr %0, align 8112; CHECK: tobool113  %tobool = icmp ne ptr %3, null114  br i1 %tobool, label %while.body, label %while.end115 116while.body:                                       ; preds = %while.cond117  %4 = load ptr, ptr %0, align 8118  %5 = load ptr, ptr %0, align 8119  %call2 = call ptr @g_list_first(ptr %5)120  %6 = load ptr, ptr %call2, align 8121  %7 = load ptr, ptr %6, align 8122  call void @g_free(ptr %7) nounwind123  %strval.i = getelementptr inbounds %struct.filter_def, ptr %6, i32 0, i32 1124  %8 = load ptr, ptr %strval.i, align 8125  call void @g_free(ptr %8) nounwind126  call void @g_free(ptr %6) nounwind127  %call.i = call ptr @g_list_remove_link(ptr %4, ptr %call2) nounwind128  store ptr %call.i, ptr %0, align 8129  br label %while.cond130 131while.end:                                        ; preds = %while.cond132  br label %do.body4133 134do.body4:                                         ; preds = %while.end135  %9 = load ptr, ptr %0, align 8136  %call5 = call i32 @g_list_length(ptr %9)137  %cmp6 = icmp eq i32 %call5, 0138  br i1 %cmp6, label %if.then7, label %if.else8139 140if.then7:                                         ; preds = %do.body4141  br label %if.end9142 143if.else8:                                         ; preds = %do.body4144  call void @g_assertion_message_expr(ptr null, ptr @.str2, i32 600, ptr @__PRETTY_FUNCTION__.copy_filter_list, ptr @.str13) noreturn145  unreachable146 147if.end9:                                          ; preds = %if.then7148  br label %do.end10149 150do.end10:                                         ; preds = %if.end9151  br label %while.cond11152 153while.cond11:                                     ; preds = %cond.end, %do.end10154  %cond10 = phi ptr [ %cond, %cond.end ], [ %2, %do.end10 ]155  %tobool12 = icmp ne ptr %cond10, null156  br i1 %tobool12, label %while.body13, label %while.end16157 158while.body13:                                     ; preds = %while.cond11159  %10 = load ptr, ptr %cond10, align 8160  %11 = load ptr, ptr %0, align 8161  %12 = load ptr, ptr %10, align 8162  %strval = getelementptr inbounds %struct.filter_def, ptr %10, i32 0, i32 1163  %13 = load ptr, ptr %strval, align 8164  %call.i7 = call noalias ptr @g_malloc(i64 16) nounwind165  %call1.i = call noalias ptr @g_strdup(ptr %12) nounwind166  store ptr %call1.i, ptr %call.i7, align 8167  %call2.i = call noalias ptr @g_strdup(ptr %13) nounwind168  %strval.i9 = getelementptr inbounds %struct.filter_def, ptr %call.i7, i32 0, i32 1169  store ptr %call2.i, ptr %strval.i9, align 8170  %call3.i = call ptr @g_list_append(ptr %11, ptr %call.i7) nounwind171  store ptr %call3.i, ptr %0, align 8172  %tobool15 = icmp ne ptr %cond10, null173  br i1 %tobool15, label %cond.true, label %cond.false174 175cond.true:                                        ; preds = %while.body13176  %next = getelementptr inbounds %struct._GList, ptr %cond10, i32 0, i32 1177  %14 = load ptr, ptr %next, align 8178  br label %cond.end179 180cond.false:                                       ; preds = %while.body13181  br label %cond.end182 183cond.end:                                         ; preds = %cond.false, %cond.true184  %cond = phi ptr [ %14, %cond.true ], [ null, %cond.false ]185  br label %while.cond11186 187while.end16:                                      ; preds = %while.cond11188  ret void189}190 191declare void @g_assertion_message_expr(ptr, ptr, i32, ptr, ptr) noreturn192 193declare i32 @g_list_length(ptr)194 195declare noalias ptr @g_strdup(ptr)196 197declare ptr @g_list_append(ptr, ptr)198 199declare ptr @g_list_remove_link(ptr, ptr)200