1 ; RUN: opt -passes=lower-constant-intrinsics -S < %s | FileCheck %s
3 ; This is a reproducer for a heap-use-after-free bug that occurred 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.
11 ; CHECK-NEXT: br label %cont4.i
14 %s = type { [2 x i16] }
16 define fastcc void @foo(ptr %p) unnamed_addr {
18 %0 = tail call i32 @llvm.objectsize.i32.p0(ptr %p, i1 false, i1 false, i1 false) #2
19 %1 = icmp ne i32 %0, 0
20 %.not1.i = icmp eq i32 %0, 0
23 for.cond: ; preds = %entry
26 cont.i: ; preds = %for.cond
27 br i1 undef, label %cont2.i, label %cont2.thread.i
29 cont2.thread.i: ; preds = %cont.i
30 br label %handler.type_mismatch3.i
32 cont2.i: ; preds = %cont.i
33 br i1 %.not1.i, label %handler.type_mismatch3.i, label %cont4.i
35 handler.type_mismatch3.i: ; preds = %cont2.i, %cont2.thread.i
36 %2 = phi i1 [ %1, %cont2.thread.i ], [ false, %cont2.i ]
39 cont4.i: ; preds = %cont2.i
43 ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
44 declare i32 @llvm.objectsize.i32.p0(ptr, i1 immarg, i1 immarg, i1 immarg) #1
46 attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
47 attributes #2 = { nounwind }