1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
2 ; RUN: opt < %s -passes=argpromotion -S | FileCheck %s
5 ; When we promote two arguments in a single function with different types,
6 ; before the fix, we used the same tag for the newly-created two loads.
7 ; This testing case makes sure that we correctly transfer the tbaa tags from the
8 ; original loads to the newly-created loads when promoting pointer arguments.
10 @a = global i32* null, align 8
11 @e = global i32** @a, align 8
12 @g = global i32 0, align 4
13 @c = global i64 0, align 8
14 @d = global i8 0, align 1
16 define internal fastcc void @fn(i32* nocapture readonly %p1, i64* nocapture readonly %p2) {
17 ; CHECK-LABEL: define {{[^@]+}}@fn
18 ; CHECK-SAME: (i32 [[P1_VAL:%.*]], i64 [[P2_VAL:%.*]])
20 ; CHECK-NEXT: [[CONV:%.*]] = trunc i64 [[P2_VAL]] to i32
21 ; CHECK-NEXT: [[CONV1:%.*]] = trunc i32 [[P1_VAL]] to i8
22 ; CHECK-NEXT: store i8 [[CONV1]], i8* @d, align 1, !tbaa !0
23 ; CHECK-NEXT: ret void
26 %0 = load i64, i64* %p2, align 8, !tbaa !1
27 %conv = trunc i64 %0 to i32
28 %1 = load i32, i32* %p1, align 4, !tbaa !5
29 %conv1 = trunc i32 %1 to i8
30 store i8 %conv1, i8* @d, align 1, !tbaa !7
35 ; CHECK-LABEL: define {{[^@]+}}@main()
37 ; CHECK-NEXT: [[TMP0:%.*]] = load i32**, i32*** @e, align 8, !tbaa !3
38 ; CHECK-NEXT: store i32* @g, i32** [[TMP0]], align 8, !tbaa !3
39 ; CHECK-NEXT: [[TMP1:%.*]] = load i32*, i32** @a, align 8, !tbaa !3
40 ; CHECK-NEXT: store i32 1, i32* [[TMP1]], align 4, !tbaa !5
41 ; CHECK-NEXT: [[G_VAL:%.*]] = load i32, i32* @g, align 4, !tbaa !5
42 ; CHECK-NEXT: [[C_VAL:%.*]] = load i64, i64* @c, align 8, !tbaa !7
43 ; CHECK-NEXT: call fastcc void @fn(i32 [[G_VAL]], i64 [[C_VAL]])
44 ; CHECK-NEXT: ret i32 0
47 %0 = load i32**, i32*** @e, align 8, !tbaa !8
48 store i32* @g, i32** %0, align 8, !tbaa !8
49 %1 = load i32*, i32** @a, align 8, !tbaa !8
50 store i32 1, i32* %1, align 4, !tbaa !5
51 call fastcc void @fn(i32* @g, i64* @c)
57 !2 = !{!"long", !3, i64 0}
58 !3 = !{!"omnipotent char", !4, i64 0}
59 !4 = !{!"Simple C/C++ TBAA"}
61 !6 = !{!"int", !3, i64 0}
64 !9 = !{!"any pointer", !3, i64 0}