[sanitizer] Improve FreeBSD ASLR detection
[llvm-project.git] / llvm / test / Transforms / LowerConstantIntrinsics / stale-worklist-phi.ll
blob304e86584862bb29c8d812aba52c89d5f4e51f0f
1 ; RUN: opt -lower-constant-intrinsics -S < %s | FileCheck %s
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.
9 ; CHECK-NOT: phi
10 ; CHECK: cont2.i:
11 ; CHECK-NEXT: br label %cont4.i
12 ; CHECK-NOT: phi
14 %s = type { [2 x i16] }
16 define fastcc void @foo(%s* %p) unnamed_addr {
17 entry:
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
24 for.cond:                                         ; preds = %entry
25   br label %cont.i
27 cont.i:                                           ; preds = %for.cond
28   br i1 undef, label %cont2.i, label %cont2.thread.i
30 cont2.thread.i:                                   ; preds = %cont.i
31   br label %handler.type_mismatch3.i
33 cont2.i:                                          ; preds = %cont.i
34   br i1 %.not1.i, label %handler.type_mismatch3.i, label %cont4.i
36 handler.type_mismatch3.i:                         ; preds = %cont2.i, %cont2.thread.i
37   %3 = phi i1 [ %2, %cont2.thread.i ], [ false, %cont2.i ]
38   unreachable
40 cont4.i:                                          ; preds = %cont2.i
41   unreachable
44 ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
45 declare i32 @llvm.objectsize.i32.p0i8(i8*, i1 immarg, i1 immarg, i1 immarg) #1
47 attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
48 attributes #2 = { nounwind }