1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals 2; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT 3; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC 4 5%struct.ss = type { i32, i64 } 6 7; Don't drop 'byval' on %X here. 8define internal i32 @f(ptr byval(%struct.ss) %b, ptr byval(i32) %X, i32 %i) nounwind { 9; 10; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) 11; CHECK-LABEL: define {{[^@]+}}@f 12; CHECK-SAME: (i32 [[TMP0:%.*]], i64 [[TMP1:%.*]], i32 [[TMP2:%.*]]) #[[ATTR0:[0-9]+]] { 13; CHECK-NEXT: entry: 14; CHECK-NEXT: [[X_PRIV:%.*]] = alloca i32, align 4 15; CHECK-NEXT: store i32 [[TMP2]], ptr [[X_PRIV]], align 4 16; CHECK-NEXT: [[B_PRIV:%.*]] = alloca [[STRUCT_SS:%.*]], align 8 17; CHECK-NEXT: store i32 [[TMP0]], ptr [[B_PRIV]], align 4 18; CHECK-NEXT: [[B_PRIV_B4:%.*]] = getelementptr i8, ptr [[B_PRIV]], i64 4 19; CHECK-NEXT: store i64 [[TMP1]], ptr [[B_PRIV_B4]], align 4 20; CHECK-NEXT: [[VAL1:%.*]] = load i32, ptr [[B_PRIV]], align 8 21; CHECK-NEXT: [[VAL2:%.*]] = add i32 [[VAL1]], 1 22; CHECK-NEXT: store i32 [[VAL2]], ptr [[B_PRIV]], align 8 23; CHECK-NEXT: store i32 0, ptr [[X_PRIV]], align 4 24; CHECK-NEXT: [[L:%.*]] = load i32, ptr [[X_PRIV]], align 4 25; CHECK-NEXT: [[A:%.*]] = add i32 [[L]], [[VAL2]] 26; CHECK-NEXT: ret i32 [[A]] 27; 28entry: 29 30 %val1 = load i32, ptr %b, align 4 31 %val2 = add i32 %val1, 1 32 store i32 %val2, ptr %b, align 4 33 34 store i32 %i, ptr %X 35 %l = load i32, ptr %X 36 %a = add i32 %l, %val2 37 ret i32 %a 38} 39 40; Also make sure we don't drop the call zeroext attribute. 41define i32 @test(ptr %X) { 42; 43; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 44; TUNIT-LABEL: define {{[^@]+}}@test 45; TUNIT-SAME: (ptr nofree nonnull readonly captures(none) [[X:%.*]]) #[[ATTR1:[0-9]+]] { 46; TUNIT-NEXT: entry: 47; TUNIT-NEXT: [[S:%.*]] = alloca [[STRUCT_SS:%.*]], align 8 48; TUNIT-NEXT: store i32 1, ptr [[S]], align 8 49; TUNIT-NEXT: [[VAL4:%.*]] = getelementptr [[STRUCT_SS]], ptr [[S]], i32 0, i32 1 50; TUNIT-NEXT: [[TMP0:%.*]] = load i32, ptr [[S]], align 8 51; TUNIT-NEXT: [[S_B4:%.*]] = getelementptr i8, ptr [[S]], i64 4 52; TUNIT-NEXT: [[TMP1:%.*]] = load i64, ptr [[S_B4]], align 8 53; TUNIT-NEXT: [[TMP2:%.*]] = load i32, ptr [[X]], align 4 54; TUNIT-NEXT: [[C:%.*]] = call i32 @f(i32 [[TMP0]], i64 [[TMP1]], i32 [[TMP2]]) #[[ATTR2:[0-9]+]] 55; TUNIT-NEXT: ret i32 [[C]] 56; 57; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(argmem: readwrite) 58; CGSCC-LABEL: define {{[^@]+}}@test 59; CGSCC-SAME: (ptr nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[X:%.*]]) #[[ATTR1:[0-9]+]] { 60; CGSCC-NEXT: entry: 61; CGSCC-NEXT: [[S:%.*]] = alloca [[STRUCT_SS:%.*]], align 8 62; CGSCC-NEXT: [[VAL4:%.*]] = getelementptr [[STRUCT_SS]], ptr [[S]], i32 0, i32 1 63; CGSCC-NEXT: [[TMP0:%.*]] = load i32, ptr [[X]], align 4 64; CGSCC-NEXT: [[C:%.*]] = call i32 @f(i32 noundef 1, i64 noundef 2, i32 [[TMP0]]) #[[ATTR2:[0-9]+]] 65; CGSCC-NEXT: ret i32 [[C]] 66; 67entry: 68 %S = alloca %struct.ss 69 store i32 1, ptr %S, align 8 70 %val4 = getelementptr %struct.ss, ptr %S, i32 0, i32 1 71 store i64 2, ptr %val4, align 4 72 73 %c = call i32 @f(ptr byval(%struct.ss) %S, ptr byval(i32) %X, i32 zeroext 0) 74 75 ret i32 %c 76} 77;. 78; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) } 79; TUNIT: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) } 80; TUNIT: attributes #[[ATTR2]] = { nofree nosync nounwind willreturn } 81;. 82; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) } 83; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree nosync nounwind willreturn memory(argmem: readwrite) } 84; CGSCC: attributes #[[ATTR2]] = { nofree nosync willreturn } 85;. 86