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