1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes --check-attributes --check-globals 2; Deep Wrapper disabled 3 4; RUN: opt -attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=1 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM,CHECK_DISABLED,NOT_CGSCC_NPM_DISABLED,NOT_CGSCC_OPM_DISABLED,NOT_TUNIT_NPM_DISABLED,IS__TUNIT_____DISABLED,IS________OPM_DISABLED,IS__TUNIT_OPM_DISABLED 5; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=1 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM,CHECK_DISABLED,NOT_CGSCC_OPM_DISABLED,NOT_CGSCC_NPM_DISABLED,NOT_TUNIT_OPM_DISABLED,IS__TUNIT_____DISABLED,IS________NPM_DISABLED,IS__TUNIT_NPM_DISABLED 6 7; Deep Wrapper enabled 8 9; RUN: opt -attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=11 -attributor-allow-deep-wrappers -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM,CHECK_ENABLED,NOT_CGSCC_NPM_ENABLED,NOT_CGSCC_OPM_ENABLED,NOT_TUNIT_NPM_ENABLED,IS__TUNIT_____ENABLED,IS________OPM_ENABLED,IS__TUNIT_OPM_ENABLED 10; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=11 -attributor-allow-deep-wrappers -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM,CHECK_ENABLED,NOT_CGSCC_OPM_ENABLED,NOT_CGSCC_NPM_ENABLED,NOT_TUNIT_OPM_ENABLED,IS__TUNIT_____ENABLED,IS________NPM_ENABLED,IS__TUNIT_NPM_ENABLED 11 12; TEST 1: This function is of linkage `linkonce`, we cannot internalize this 13; function and use information derived from it 14; 15; CHECK-NOT: inner1.internalized 16define linkonce i32 @inner1(i32 %a, i32 %b) { 17; CHECK-LABEL: define {{[^@]+}}@inner1 18; CHECK-SAME: (i32 [[A:%.*]], i32 [[B:%.*]]) { 19; CHECK-NEXT: entry: 20; CHECK-NEXT: [[C:%.*]] = add i32 [[A]], [[B]] 21; CHECK-NEXT: ret i32 [[C]] 22; 23entry: 24 %c = add i32 %a, %b 25 ret i32 %c 26} 27 28; TEST 2: This function is of linkage `weak`, we cannot internalize this function and 29; use information derived from it 30; 31; CHECK-NOT: inner2.internalized 32define weak i32 @inner2(i32 %a, i32 %b) { 33; CHECK-LABEL: define {{[^@]+}}@inner2 34; CHECK-SAME: (i32 [[A:%.*]], i32 [[B:%.*]]) { 35; CHECK-NEXT: entry: 36; CHECK-NEXT: [[C:%.*]] = add i32 [[A]], [[B]] 37; CHECK-NEXT: ret i32 [[C]] 38; 39entry: 40 %c = add i32 %a, %b 41 ret i32 %c 42} 43 44; TEST 3: This function is of linkage `linkonce_odr`, which can be internalized using the 45; deep wrapper, and the IP information derived from this function can be used 46; 47define linkonce_odr i32 @inner3(i32 %a, i32 %b) { 48; CHECK_DISABLED-LABEL: define {{[^@]+}}@inner3 49; CHECK_DISABLED-SAME: (i32 [[A:%.*]], i32 [[B:%.*]]) { 50; CHECK_DISABLED-NEXT: entry: 51; CHECK_DISABLED-NEXT: [[C:%.*]] = add i32 [[A]], [[B]] 52; CHECK_DISABLED-NEXT: ret i32 [[C]] 53; 54entry: 55 %c = add i32 %a, %b 56 ret i32 %c 57} 58 59; TEST 4: This function is of linkage `weak_odr`, which can be internalized using the deep 60; wrapper 61; 62define weak_odr i32 @inner4(i32 %a, i32 %b) { 63; CHECK_DISABLED-LABEL: define {{[^@]+}}@inner4 64; CHECK_DISABLED-SAME: (i32 [[A:%.*]], i32 [[B:%.*]]) { 65; CHECK_DISABLED-NEXT: entry: 66; CHECK_DISABLED-NEXT: [[C:%.*]] = add i32 [[A]], [[B]] 67; CHECK_DISABLED-NEXT: ret i32 [[C]] 68; 69entry: 70 %c = add i32 %a, %b 71 ret i32 %c 72} 73 74; TEST 5: This function has linkage `linkonce_odr` but is never called (num of use = 0), so there 75; is no need to internalize this 76; 77; CHECK-NOT: inner5.internalized 78define linkonce_odr i32 @inner5(i32 %a, i32 %b) { 79; CHECK-LABEL: define {{[^@]+}}@inner5 80; CHECK-SAME: (i32 [[A:%.*]], i32 [[B:%.*]]) { 81; CHECK-NEXT: entry: 82; CHECK-NEXT: [[C:%.*]] = add i32 [[A]], [[B]] 83; CHECK-NEXT: ret i32 [[C]] 84; 85entry: 86 %c = add i32 %a, %b 87 ret i32 %c 88} 89 90; Since the inner1 cannot be internalized, there should be no change to its callsite 91; Since the inner2 cannot be internalized, there should be no change to its callsite 92; Since the inner3 is internalized, the use of the original function should be replaced by the 93; copied one 94; 95define i32 @outer1() { 96; CHECK_DISABLED-LABEL: define {{[^@]+}}@outer1() { 97; CHECK_DISABLED-NEXT: entry: 98; CHECK_DISABLED-NEXT: [[RET1:%.*]] = call i32 @inner1(i32 noundef 1, i32 noundef 2) 99; CHECK_DISABLED-NEXT: [[RET2:%.*]] = call i32 @inner2(i32 noundef 1, i32 noundef 2) 100; CHECK_DISABLED-NEXT: [[RET3:%.*]] = call i32 @inner3(i32 [[RET1]], i32 [[RET2]]) 101; CHECK_DISABLED-NEXT: [[RET4:%.*]] = call i32 @inner4(i32 [[RET3]], i32 [[RET3]]) 102; CHECK_DISABLED-NEXT: ret i32 [[RET4]] 103; 104; CHECK_ENABLED-LABEL: define {{[^@]+}}@outer1() { 105; CHECK_ENABLED-NEXT: entry: 106; CHECK_ENABLED-NEXT: [[RET1:%.*]] = call i32 @inner1(i32 noundef 1, i32 noundef 2) 107; CHECK_ENABLED-NEXT: [[RET2:%.*]] = call i32 @inner2(i32 noundef 1, i32 noundef 2) 108; CHECK_ENABLED-NEXT: [[RET3:%.*]] = call i32 @inner3.internalized(i32 [[RET1]], i32 [[RET2]]) 109; CHECK_ENABLED-NEXT: [[RET4:%.*]] = call i32 @inner4.internalized(i32 [[RET3]], i32 [[RET3]]) 110; CHECK_ENABLED-NEXT: ret i32 [[RET4]] 111; 112entry: 113 %ret1 = call i32 @inner1(i32 1, i32 2) 114 %ret2 = call i32 @inner2(i32 1, i32 2) 115 %ret3 = call i32 @inner3(i32 %ret1, i32 %ret2) 116 %ret4 = call i32 @inner4(i32 %ret3, i32 %ret3) 117 ret i32 %ret4 118} 119 120 121define linkonce_odr void @unused_arg(i8) { 122; CHECK_DISABLED-LABEL: define {{[^@]+}}@unused_arg 123; CHECK_DISABLED-SAME: (i8 [[TMP0:%.*]]) { 124; CHECK_DISABLED-NEXT: unreachable 125; 126 unreachable 127} 128 129define void @unused_arg_caller() { 130; CHECK_DISABLED-LABEL: define {{[^@]+}}@unused_arg_caller() { 131; CHECK_DISABLED-NEXT: call void @unused_arg(i8 noundef 0) 132; CHECK_DISABLED-NEXT: ret void 133; 134; CHECK_ENABLED: Function Attrs: nofree noreturn nosync nounwind readnone willreturn 135; CHECK_ENABLED-LABEL: define {{[^@]+}}@unused_arg_caller 136; CHECK_ENABLED-SAME: () #[[ATTR1:[0-9]+]] { 137; CHECK_ENABLED-NEXT: unreachable 138; 139; IS__CGSCC_____ENABLED: Function Attrs: nofree norecurse noreturn nosync nounwind readnone willreturn 140; IS__CGSCC_____ENABLED-LABEL: define {{[^@]+}}@unused_arg_caller 141; IS__CGSCC_____ENABLED-SAME: () #[[ATTR2:[0-9]+]] { 142; IS__CGSCC_____ENABLED-NEXT: unreachable 143 call void @unused_arg(i8 0) 144 ret void 145} 146 147; Don't crash on linkonce_odr hidden functions 148define linkonce_odr hidden void @__clang_call_terminate() { 149; CHECK_DISABLED-LABEL: define {{[^@]+}}@__clang_call_terminate() { 150; CHECK_DISABLED-NEXT: call void @__clang_call_terminate() 151; CHECK_DISABLED-NEXT: unreachable 152; 153 call void @__clang_call_terminate() 154 unreachable 155} 156 157; IS__CGSCC_____ENABLED: attributes #[[ATTR0:[0-9]+]] = { nofree nosync nounwind readnone willreturn } 158; IS__CGSCC_____ENABLED: attributes #[[ATTR1:[0-9]+]] = { nofree noreturn nosync nounwind readnone willreturn } 159; IS__CGSCC_____ENABLED: attributes #[[ATTR2]] = { nofree norecurse noreturn nosync nounwind readnone willreturn } 160;. 161; CHECK_ENABLED: attributes #[[ATTR0:[0-9]+]] = { nofree nosync nounwind readnone willreturn } 162; CHECK_ENABLED: attributes #[[ATTR1]] = { nofree noreturn nosync nounwind readnone willreturn } 163; CHECK_ENABLED: attributes #[[ATTR2:[0-9]+]] = { nounwind readnone } 164;. 165