llvm-project
82 строки · 3.7 Кб
1; RUN: opt %loadNPMPolly '-passes=print<polly-simplify>,polly-optree' -disable-output < %s | FileCheck %s -match-full-lines
2
3; llvm.org/PR47098
4; Use-after-free by reference to Stmt remaining in InstStmtMap after removing it has been removed by Scop::simplifyScop.
5; Removal happened in -polly-simplify, Reference was using in -polly-optree.
6; Check that Simplify removes the definition of %0 as well of its use.
7
8target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
9target triple = "x86_64-pc-windows-msvc19.26.28806"
10
11@"?var_27@@3JA" = external dso_local local_unnamed_addr global i32, align 4
12@"?var_28@@3HA" = external dso_local local_unnamed_addr global i32, align 4
13
14; Function Attrs: nofree norecurse nounwind uwtable
15define dso_local void @"?test@@YAXHEQEAY3M@1BI@BJ@H@Z"(i32 %a, i8 %b, ptr nocapture readonly %c) local_unnamed_addr {
16entry:
17br label %entry.split
18
19entry.split: ; preds = %entry
20%sext = shl i32 %a, 16
21%conv4 = ashr exact i32 %sext, 16
22%sub = add nsw i32 %conv4, -25941
23%cmp535 = icmp sgt i32 %sext, 1700069376
24br i1 %cmp535, label %for.cond8.preheader.lr.ph, label %for.cond.cleanup.critedge
25
26for.cond8.preheader.lr.ph: ; preds = %entry.split
27%conv10 = zext i8 %b to i64
28%sub11 = add nsw i64 %conv10, -129
29%cmp1232.not = icmp eq i64 %sub11, 0
30br i1 %cmp1232.not, label %for.cond8.preheader, label %for.cond8.preheader.us
31
32for.cond8.preheader.us: ; preds = %for.cond8.preheader.lr.ph, %for.cond8.for.cond.cleanup13_crit_edge.us
33%e.036.us = phi i16 [ %add.us, %for.cond8.for.cond.cleanup13_crit_edge.us ], [ 0, %for.cond8.preheader.lr.ph ]
34%idxprom.us = sext i16 %e.036.us to i64
35br label %for.body14.us
36
37for.body14.us: ; preds = %for.cond8.preheader.us, %for.body14.us
38%indvars.iv = phi i64 [ 0, %for.cond8.preheader.us ], [ %indvars.iv.next, %for.body14.us ]
39%arrayidx19.us = getelementptr inbounds [12 x [2 x [24 x [25 x i32]]]], ptr %c, i64 6, i64 2, i64 1, i64 %idxprom.us, i64 %indvars.iv
40%0 = load i32, ptr %arrayidx19.us, align 4, !tbaa !3
41store i32 0, ptr @"?var_28@@3HA", align 4, !tbaa !3
42%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
43%exitcond.not = icmp eq i64 %indvars.iv.next, %sub11
44br i1 %exitcond.not, label %for.cond8.for.cond.cleanup13_crit_edge.us, label %for.body14.us
45
46for.cond8.for.cond.cleanup13_crit_edge.us: ; preds = %for.body14.us
47%add.us = add i16 %e.036.us, 4
48%conv2.us = sext i16 %add.us to i32
49%cmp5.us = icmp sgt i32 %sub, %conv2.us
50br i1 %cmp5.us, label %for.cond8.preheader.us, label %for.cond.cleanup.critedge.loopexit38
51
52for.cond.cleanup.critedge.loopexit38: ; preds = %for.cond8.for.cond.cleanup13_crit_edge.us
53store i32 %0, ptr @"?var_27@@3JA", align 4, !tbaa !7
54br label %for.cond.cleanup.critedge
55
56for.cond.cleanup.critedge: ; preds = %for.cond8.preheader, %for.cond.cleanup.critedge.loopexit38, %entry.split
57ret void
58
59for.cond8.preheader: ; preds = %for.cond8.preheader.lr.ph, %for.cond8.preheader
60%e.036 = phi i16 [ %add, %for.cond8.preheader ], [ 0, %for.cond8.preheader.lr.ph ]
61%add = add i16 %e.036, 4
62%conv2 = sext i16 %add to i32
63%cmp5 = icmp sgt i32 %sub, %conv2
64br i1 %cmp5, label %for.cond8.preheader, label %for.cond.cleanup.critedge
65}
66
67!3 = !{!4, !4, i64 0}
68!4 = !{!"int", !5, i64 0}
69!5 = !{!"omnipotent char", !6, i64 0}
70!6 = !{!"Simple C++ TBAA"}
71!7 = !{!8, !8, i64 0}
72!8 = !{!"long", !5, i64 0}
73
74
75; CHECK: Statistics {
76; CHECK: Empty domains removed: 2
77; CHECK: }
78
79; CHECK: After accesses {
80; CHECK-NOT: Stmt_for_body14_us_a
81; CHECK-NOT: Stmt_for_body14_us
82; CHECK: }
83