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