1; RUN: opt -lower-constant-intrinsics -S < %s | FileCheck %s 2 3; This is a reproducer for a heap-use-after-free bug that occured due to trying 4; to process a PHI node that was removed in a preceding worklist iteration. The 5; conditional branch in %cont2.i will be replaced with an unconditional branch 6; to %cont4.i. As a result of that, the PHI node in %handler.type_mismatch3.i 7; will be left with one predecessor and will thus be removed in that iteration. 8 9; CHECK-NOT: phi 10; CHECK: cont2.i: 11; CHECK-NEXT: br label %cont4.i 12; CHECK-NOT: phi 13 14%s = type { [2 x i16] } 15 16define fastcc void @foo(%s* %p) unnamed_addr { 17entry: 18 %0 = bitcast %s* %p to i8* 19 %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %0, i1 false, i1 false, i1 false) #2 20 %2 = icmp ne i32 %1, 0 21 %.not1.i = icmp eq i32 %1, 0 22 br label %for.cond 23 24for.cond: ; preds = %entry 25 br label %cont.i 26 27cont.i: ; preds = %for.cond 28 br i1 undef, label %cont2.i, label %cont2.thread.i 29 30cont2.thread.i: ; preds = %cont.i 31 br label %handler.type_mismatch3.i 32 33cont2.i: ; preds = %cont.i 34 br i1 %.not1.i, label %handler.type_mismatch3.i, label %cont4.i 35 36handler.type_mismatch3.i: ; preds = %cont2.i, %cont2.thread.i 37 %3 = phi i1 [ %2, %cont2.thread.i ], [ false, %cont2.i ] 38 unreachable 39 40cont4.i: ; preds = %cont2.i 41 unreachable 42} 43 44; Function Attrs: nofree nosync nounwind readnone speculatable willreturn 45declare i32 @llvm.objectsize.i32.p0i8(i8*, i1 immarg, i1 immarg, i1 immarg) #1 46 47attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } 48attributes #2 = { nounwind } 49