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