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 3 4; PR17906 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. 9 10@a = global ptr null, align 8 11@e = global ptr @a, align 8 12@g = global i32 0, align 4 13@c = global i64 0, align 8 14@d = global i8 0, align 1 15 16define internal fastcc void @fn(ptr nocapture readonly %p1, ptr nocapture readonly %p2) { 17; CHECK-LABEL: define {{[^@]+}}@fn 18; CHECK-SAME: (i32 [[P1_0_VAL:%.*]], i64 [[P2_0_VAL:%.*]]) { 19; CHECK-NEXT: entry: 20; CHECK-NEXT: [[CONV:%.*]] = trunc i64 [[P2_0_VAL]] to i32 21; CHECK-NEXT: [[CONV1:%.*]] = trunc i32 [[P1_0_VAL]] to i8 22; CHECK-NEXT: store i8 [[CONV1]], ptr @d, align 1, !tbaa [[TBAA0:![0-9]+]] 23; CHECK-NEXT: ret void 24; 25entry: 26 %0 = load i64, ptr %p2, align 8, !tbaa !1 27 %conv = trunc i64 %0 to i32 28 %1 = load i32, ptr %p1, align 4, !tbaa !5 29 %conv1 = trunc i32 %1 to i8 30 store i8 %conv1, ptr @d, align 1, !tbaa !7 31 ret void 32} 33 34define i32 @main() { 35; CHECK-LABEL: define {{[^@]+}}@main() { 36; CHECK-NEXT: entry: 37; CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr @e, align 8, !tbaa [[TBAA3:![0-9]+]] 38; CHECK-NEXT: store ptr @g, ptr [[TMP0]], align 8, !tbaa [[TBAA3]] 39; CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr @a, align 8, !tbaa [[TBAA3]] 40; CHECK-NEXT: store i32 1, ptr [[TMP1]], align 4, !tbaa [[TBAA5:![0-9]+]] 41; CHECK-NEXT: [[G_VAL:%.*]] = load i32, ptr @g, align 4, !tbaa [[TBAA5]] 42; CHECK-NEXT: [[C_VAL:%.*]] = load i64, ptr @c, align 8, !tbaa [[TBAA7:![0-9]+]] 43; CHECK-NEXT: call fastcc void @fn(i32 [[G_VAL]], i64 [[C_VAL]]) 44; CHECK-NEXT: ret i32 0 45; 46entry: 47 %0 = load ptr, ptr @e, align 8, !tbaa !8 48 store ptr @g, ptr %0, align 8, !tbaa !8 49 %1 = load ptr, ptr @a, align 8, !tbaa !8 50 store i32 1, ptr %1, align 4, !tbaa !5 51 call fastcc void @fn(ptr @g, ptr @c) 52 53 ret i32 0 54} 55 56!1 = !{!2, !2, i64 0} 57!2 = !{!"long", !3, i64 0} 58!3 = !{!"omnipotent char", !4, i64 0} 59!4 = !{!"Simple C/C++ TBAA"} 60!5 = !{!6, !6, i64 0} 61!6 = !{!"int", !3, i64 0} 62!7 = !{!3, !3, i64 0} 63!8 = !{!9, !9, i64 0} 64!9 = !{!"any pointer", !3, i64 0} 65 66