1; This test checks that the code doesn't aggressively apply TBAA
2; metadata to temporaries that are passed by pointer to kernels.
3
4; RUN: opt -load libbcc.so -kernelexp -inline -tbaa -aa-eval -print-may-aliases -evaluate-aa-metadata < %s -S -o - 2>&1 | FileCheck %s
5
6; ModuleID = 'kernel.bc'
7target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
8target triple = "aarch64-none-linux-gnueabi"
9
10; Declarations expected by the expansion pass.
11declare void @_Z14rsGetElementAt13rs_allocationj()
12declare void @_Z14rsGetElementAt13rs_allocationjj()
13declare void @_Z14rsGetElementAt13rs_allocationjjj()
14declare void @_Z14rsSetElementAt13rs_allocationPvj()
15declare void @_Z14rsSetElementAt13rs_allocationPvjj()
16declare void @_Z14rsSetElementAt13rs_allocationPvjjj()
17declare void @_Z25rsGetElementAtYuv_uchar_Y13rs_allocationjj()
18declare void @_Z25rsGetElementAtYuv_uchar_U13rs_allocationjj()
19declare void @_Z25rsGetElementAtYuv_uchar_V13rs_allocationjj()
20
21%struct.int5.0 = type { [5 x i32] }
22
23; Function Attrs: nounwind
24define void @add1_int5(%struct.int5.0* noalias nocapture sret %agg.result, %struct.int5.0* nocapture %in) #0 {
25  br label %1
26
27; <label>:1                                       ; preds = %1, %0
28  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %1 ]
29  %2 = getelementptr inbounds %struct.int5.0, %struct.int5.0* %in, i64 0, i32 0, i64 %indvars.iv
30; CHECK: MayAlias: %load_from_input{{.*}} <-> store %struct.int5.0 %input, %struct.int5.0* %input_struct_slot
31  %load_from_input = load i32, i32* %2, align 4, !tbaa !9
32  %3 = add nsw i32 %load_from_input, 1
33  store i32 %3, i32* %2, align 4, !tbaa !9
34  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
35  %exitcond = icmp eq i64 %indvars.iv.next, 5
36  br i1 %exitcond, label %4, label %1
37
38; <label>:4                                       ; preds = %1
39  %5 = bitcast %struct.int5.0* %agg.result to i8*
40  %6 = bitcast %struct.int5.0* %in to i8*
41  tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %5, i8* %6, i64 20, i32 4, i1 false), !tbaa.struct !13
42  ret void
43}
44
45; Function Attrs: nounwind
46declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) #0
47
48attributes #0 = { nounwind }
49
50!llvm.ident = !{!0}
51!\23pragma = !{!1, !2}
52!\23rs_export_foreach_name = !{!3, !4}
53!\23rs_export_foreach = !{!5, !6}
54!\23rs_export_type = !{!7}
55!\25int5 = !{!8}
56
57; The following named metadata would not be present in a bitcode file,
58; but instead synthesized by bcc from the bitcode wrapper.  However,
59; for this test case, we're not running bcc, but instead opt, and so
60; we never get the opportunity to synthesize this named metadata.
61!\23rs_wrapper = !{!15}
62
63!0 = !{!"clang version 3.6 "}
64!1 = !{!"version", !"1"}
65!2 = !{!"java_package_name", !"foo"}
66!3 = !{!"root"}
67!4 = !{!"add1_int5"}
68!5 = !{!"0"}
69!6 = !{!"35"}
70!7 = !{!"int5"}
71!8 = !{!"data", !"<ConstantArray>"}
72!9 = !{!10, !10, i64 0}
73!10 = !{!"int", !11, i64 0}
74!11 = !{!"omnipotent char", !12, i64 0}
75!12 = !{!"Simple C/C++ TBAA"}
76!13 = !{i64 0, i64 20, !14}
77!14 = !{!11, !11, i64 0}
78!15 = !{!"0", !"3"}
79