brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · 3e1485f Raw
95 lines · plain
1; RUN: opt -passes=lcssa -S < %s | FileCheck %s2 3; This test is based on the following C++ code:4;5; void f()6; {7;   for (int i=0; i<12; i++) {8;     try {9;       if (i==3)10;         throw i;11;     } catch (int) {12;       continue;13;     } catch (...) { }14;     if (i==3) break;15;   }16; }17;18; The loop info analysis identifies the catch pad for the second catch as being19; outside the loop (because it returns to %for.end) but the associated20; catchswitch block is identified as being inside the loop.  Because of this21; analysis, the LCSSA pass wants to create a PHI node in the catchpad block22; for the catchswitch value, but this is a token, so it can't.23 24define void @f() personality ptr @__CxxFrameHandler3 {25entry:26  %tmp = alloca i32, align 427  %i7 = alloca i32, align 428  br label %for.cond29 30for.cond:                                         ; preds = %for.inc, %entry31  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]32  %cmp = icmp slt i32 %i.0, 1233  br i1 %cmp, label %for.body, label %for.end34 35for.body:                                         ; preds = %for.cond36  %cond = icmp eq i32 %i.0, 337  br i1 %cond, label %if.then, label %for.inc38 39if.then:                                          ; preds = %for.body40  store i32 %i.0, ptr %tmp, align 441  invoke void @_CxxThrowException(ptr %tmp, ptr nonnull @_TI1H) #142          to label %unreachable unwind label %catch.dispatch43 44catch.dispatch:                                   ; preds = %if.then45  %tmp2 = catchswitch within none [label %catch, label %catch2] unwind to caller46 47catch:                                            ; preds = %catch.dispatch48  %tmp3 = catchpad within %tmp2 [ptr @"\01??_R0H@8", i32 0, ptr %i7]49  catchret from %tmp3 to label %for.inc50 51catch2:                                           ; preds = %catch.dispatch52  %tmp4 = catchpad within %tmp2 [ptr null, i32 64, ptr null]53  catchret from %tmp4 to label %for.end54 55for.inc:                                          ; preds = %catch, %for.body56  %inc = add nsw i32 %i.0, 157  br label %for.cond58 59for.end:                                          ; preds = %catch2, %for.cond60  ret void61 62unreachable:                                      ; preds = %if.then63  unreachable64}65 66; CHECK-LABEL: define void @f()67; CHECK: catch2:68; CHECK-NOT: phi69; CHECK:   %tmp4 = catchpad within %tmp270; CHECK:   catchret from %tmp4 to label %for.end71 72%rtti.TypeDescriptor2 = type { ptr, ptr, [3 x i8] }73%eh.CatchableType = type { i32, i32, i32, i32, i32, i32, i32 }74%eh.CatchableTypeArray.1 = type { i32, [1 x i32] }75%eh.ThrowInfo = type { i32, i32, i32, i32 }76 77$"\01??_R0H@8" = comdat any78 79$"_CT??_R0H@84" = comdat any80 81$_CTA1H = comdat any82 83$_TI1H = comdat any84 85@"\01??_7type_info@@6B@" = external constant ptr86@"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { ptr @"\01??_7type_info@@6B@", ptr null, [3 x i8] c".H\00" }, comdat87@__ImageBase = external constant i888@"_CT??_R0H@84" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 1, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"\01??_R0H@8" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32), i32 0, i32 -1, i32 0, i32 4, i32 0 }, section ".xdata", comdat89@_CTA1H = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.1 { i32 1, [1 x i32] [i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"_CT??_R0H@84" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32)] }, section ".xdata", comdat90@_TI1H = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i32 0, i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @_CTA1H to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32) }, section ".xdata", comdat91 92declare void @_CxxThrowException(ptr, ptr)93 94declare i32 @__CxxFrameHandler3(...)95