xref: /llvm-project/llvm/test/CodeGen/AArch64/stack-tagging-loop.ll (revision 9320a32bb91bb97d9eafacacc6a4aea602da52ff)
1; We set a low dom-tree-reachability-max-bbs-to-explore to check whether the
2; loop analysis is working. Without skipping over the loop, we would need more
3; than 4 BB to reach end from entry.
4
5; RUN: opt -S -dom-tree-reachability-max-bbs-to-explore=4 -aarch64-stack-tagging %s -o - | FileCheck %s
6
7target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
8target triple = "aarch64"
9
10define dso_local void @foo(i1 %x, i32 %n) sanitize_memtag {
11entry:
12  %c = alloca [1024 x i8], align 1
13  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %c)
14  %cmp2.not = icmp eq i32 %n, 0
15  br i1 %x, label %entry2, label %noloop
16
17entry2:
18  br i1 %cmp2.not, label %for.cond.cleanup, label %for.body
19
20for.cond.cleanup:                                 ; preds = %for.body, %entry
21; CHECK-LABEL: for.cond.cleanup:
22; CHECK: call{{.*}}settag
23; CHECK: call{{.*}}lifetime.end
24  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %c)
25  call void @bar(ptr noundef nonnull inttoptr (i64 120 to ptr))
26  br label %end
27
28for.body:                                         ; preds = %entry, %for.body
29  %i.03 = phi i32 [ %inc, %for.body2 ], [ 0, %entry2 ]
30  call void @bar(ptr noundef nonnull %c) #3
31  br label %for.body2
32
33for.body2:
34  %inc = add nuw nsw i32 %i.03, 1
35  %cmp = icmp ult i32 %inc, %n
36  br i1 %cmp, label %for.body, label %for.cond.cleanup, !llvm.loop !13
37
38noloop:
39; CHECK-LABEL: noloop:
40; CHECK: call{{.*}}settag
41; CHECK: call{{.*}}lifetime.end
42  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %c)
43  br label %end
44
45end:
46; CHECK-LABEL: end:
47; CHECK-NOT: call{{.*}}settag
48  ret void
49}
50
51; Function Attrs: argmemonly mustprogress nocallback nofree nosync nounwind willreturn
52declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0
53declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0
54
55declare dso_local void @bar(ptr noundef)
56
57attributes #0 = { argmemonly mustprogress nocallback nofree nosync nounwind willreturn }
58
59!13 = distinct !{!13, !14}
60!14 = !{!"llvm.loop.mustprogress"}
61